Missing features for Unsynced Luarules

Missing features for Unsynced Luarules

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

Moderator: Moderators

Post Reply
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Missing features for Unsynced Luarules

Post by lurker »

Apparently the unsynced side of gadgets is missing such features as being able to send any form of command or net traffic, forcing many things to be repeated for each person in synced code, or requiring a relay widget that you pray the user doesn't turn off. Unless there are any objections, I'd like to add some of these functions, and I'd like this topic to serve as a list of what's missing from the unsynced gadget interface. So list away.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Missing features for Unsynced Luarules

Post by Argh »

The biggest thing I've seen thus far is that when you access tables from Sync, grabbing global variables from another Gadget, it appears that their indice values are constantly getting changed in memory, which strikes me as incredibly inefficient.

As an experiment, try this out (apologize in advance for some missing basic stuff, I am lazy and it's 1AM, baaaw).

First, write a Gadget like this:

Code: Select all

local MyTable = {MyValue1, MyValue2}

if (gadgetHandler:IsSyncedCode()) then

function gadget:Initialize()
table.insert (MyTable,{1,2})
gadgetHandler:RegisterGlobal("MyTable", MyTable)
end

end
Then write another Gadget, like this:

Code: Select all

if (gadgetHandler:IsSyncedCode()) then
else

function gadget:DrawWorldPreUnit()
MyNewTable = SYNCED.MyTable
for k,v in spairs(MyNewTable) do
Spring.Echo (k,v)
end

end
The value of k is constantly changing, when I tested this. Is this because of memory management? Seems very strange to me, given that it's just the indice of a given table, and we'd want it to remain the same, I'd think, unless it was deleted and reinitialized...

Lastly, maybe I'm just doing something wrong, but I cannot seem to get the SYNCED portions of two Gadgets to communicate, at all. They refuse to return a value for global variables that the other has stored, which is very... inconvenient. Please tell me if I'm just doing it wrong, I had to place certain code in an awkward place because of this, and I'd rather move it to where it'll make more sense, for people trying to use / read / maintain what I've been working on lately...
Last edited by Argh on 15 Mar 2008, 18:41, edited 1 time in total.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Missing features for Unsynced Luarules

Post by KDR_11k »

shouldn't it be for k,v in spairs(MyTable) do?

Also I think the biggest ommission for unsynced gadget code is mouse interaction.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Missing features for Unsynced Luarules

Post by Argh »

Er, yeah, sorry, it was late. <fixes>

At any rate, does anybody else have input on communicating global variables between two Gadgets on the sync side?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Missing features for Unsynced Luarules

Post by KDR_11k »

Nope, it works fine for me.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Re: Missing features for Unsynced Luarules

Post by LordMatt »

Perhaps I don't know what I am talking about, but wouldn't this make cheating easier?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Missing features for Unsynced Luarules

Post by lurker »

LordMatt wrote:Perhaps I don't know what I am talking about, but wouldn't this make cheating easier?
:? How?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Missing features for Unsynced Luarules

Post by Argh »

By exposing variables. Answer, no, it doesn't, because messing with them still causes desync, unless the host is the one doing the cheating. It just struck me as weird that their indice value was constantly changing, but meh, it's not that important anyhow. I just noticed that, and thought it was weird, was all.
Post Reply

Return to “Lua Scripts”