Page 1 of 1

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

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

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

Posted: 08 Apr 2014, 19:59
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.

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

Posted: 08 Apr 2014, 22:29
by smoth
String parsing...

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

Posted: 08 Apr 2014, 22:50
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.

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

Posted: 09 Apr 2014, 00:28
by Silentwings
iirc, in general more efficient but still pretty horrible.

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

Posted: 09 Apr 2014, 07:19
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..)

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

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

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

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

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

Posted: 09 Apr 2014, 14:52
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.

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

Posted: 10 Apr 2014, 09:34
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.

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

Posted: 10 Apr 2014, 09:43
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).

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

Posted: 10 Apr 2014, 10:18
by jK
close please
thread creator is avoiding real solution and ppl create offtopic trails, just increasing confusion & misinformation

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

Posted: 10 Apr 2014, 10:26
by knorke
not enought details/research/wubwap for feature quest, moved to Lua.