Set[Game/Team/Unit]RulesParam should allow Tables.

Set[Game/Team/Unit]RulesParam should allow Tables.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Erik »

Having the option to have tables for these parameters would be absolutely awesome sauce.
Example: Imbue a unit/team with lots of custom data that can be read and displayed by the UI (obeying vision limitations).

Not sure about the difficulty of implementing this tough.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Silentwings »

The bad side of this is that RulesParams data is accessible from everywhere - possibly from different threads on different cores that don't share the same cache, etc etc. So there is an overhead for the transfer (and unfortunately, lua is not a strongly typed language which forces tables to be quite complicated data structures).

If you explain in more detail what data you are trying to send where, someone might be able to offer you a better idea.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by smoth »

String parsing...
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Erik »

You mean converting the table into a megalong string?
Should work, not sure about how efficient string operations are in lua compared to tables.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Silentwings »

iirc, in general more efficient but still pretty horrible.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by knorke »

There is global GG table that is shared among gadgets.
Does that cover your need maybe?

http://springrts.com/wiki/LuaTutorials: ... unications
not explained there yet, hm.

Basically can do like:
GG.myTable[someIndex].bla
etc

Instead of the actual tables being share you can also have a global GG.function.
http://springrts.com/phpbb/viewtopic.php?f=23&t=27025 is simple example. (not the best though, and in this case RulesParam might have been better. but well, as example..)
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by CarRepairer »

knorke wrote:There is global GG table that is shared among gadgets.
Erik wrote:custom data that can be read and displayed by the UI
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by jK »

1. you don't say anything at all what you are doing (that pisses off any dev when reading such topics)
2. RulesParams are saved in c++ containers and are not lua objects! so saving tables is nearly impossible w/o fuck-ya-brain.
3. you don't need tables in rulesparams, everything there is is enough! (see (1) when you want an answer _how_ to do it right!)

finished (annoyed by improper feature request)
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Google_Frog »

I've had experience with string parsing. It was really slow. Your best bet at the moment could be to do gadgetHandler:AddSyncAction in the unsynced part of a gadget and then Script.LuaUI.YourWidgetFunction to send it to luaUI. There are a few examples of this spread around ZK.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Erik »

Google_Frog wrote: Your best bet at the moment could be to do gadgetHandler:AddSyncAction in the unsynced part of a gadget and then Script.LuaUI.YourWidgetFunction to send it to luaUI. There are a few examples of this spread around ZK.
I'm pretty sure SendToUnsynced can't take tables for an argument either.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by Silentwings »

Googlefrog is not suggesting you use SendToUnsynced, he is suggesting you use AddSyncAction. SendToUnsynced sends to unsynced gadget, not to widget.

(I never tried to send a table via either of them - my advice is don't send complicated data from synced to any unsynced state, just think of more intelligent ways to communicate less data).
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by jK »

close please
thread creator is avoiding real solution and ppl create offtopic trails, just increasing confusion & misinformation
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Set[Game/Team/Unit]RulesParam should allow Tables.

Post by knorke »

not enought details/research/wubwap for feature quest, moved to Lua.
Post Reply

Return to “Lua Scripts”