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 » 08 Apr 2014, 19:53

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.
0 x

User avatar
Silentwings
Moderator
Posts: 3586
Joined: 25 Oct 2008, 00:23

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

Post by Silentwings » 08 Apr 2014, 19:59

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.
0 x

User avatar
smoth
Posts: 22298
Joined: 13 Jan 2005, 00:46

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

Post by smoth » 08 Apr 2014, 22:29

String parsing...
0 x

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

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

Post by Erik » 08 Apr 2014, 22:50

You mean converting the table into a megalong string?
Should work, not sure about how efficient string operations are in lua compared to tables.
0 x

User avatar
Silentwings
Moderator
Posts: 3586
Joined: 25 Oct 2008, 00:23

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

Post by Silentwings » 09 Apr 2014, 00:28

iirc, in general more efficient but still pretty horrible.
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

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

Post by knorke » 09 Apr 2014, 07:19

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..)
0 x

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 » 09 Apr 2014, 07:43

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
0 x

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 » 09 Apr 2014, 09:47

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)
0 x

Google_Frog
Moderator
Posts: 2435
Joined: 12 Oct 2007, 09:24

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

Post by Google_Frog » 09 Apr 2014, 14:52

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.
0 x

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

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

Post by Erik » 10 Apr 2014, 09:34

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.
0 x

User avatar
Silentwings
Moderator
Posts: 3586
Joined: 25 Oct 2008, 00:23

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

Post by Silentwings » 10 Apr 2014, 09:43

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).
0 x

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 » 10 Apr 2014, 10:18

close please
thread creator is avoiding real solution and ppl create offtopic trails, just increasing confusion & misinformation
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

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

Post by knorke » 10 Apr 2014, 10:26

not enought details/research/wubwap for feature quest, moved to Lua.
0 x

Post Reply

Return to “Lua Scripts”