Missing features for Unsynced Luarules
Moderator: Moderators
Missing features for Unsynced Luarules
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.
Re: Missing features for Unsynced Luarules
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:
Then write another Gadget, like this:
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...
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
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
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.
Re: Missing features for Unsynced Luarules
shouldn't it be for k,v in spairs(MyTable) do?
Also I think the biggest ommission for unsynced gadget code is mouse interaction.
Also I think the biggest ommission for unsynced gadget code is mouse interaction.
Re: Missing features for Unsynced Luarules
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?
At any rate, does anybody else have input on communicating global variables between two Gadgets on the sync side?
Re: Missing features for Unsynced Luarules
Nope, it works fine for me.
Re: Missing features for Unsynced Luarules
Perhaps I don't know what I am talking about, but wouldn't this make cheating easier?
Re: Missing features for Unsynced Luarules
LordMatt wrote:Perhaps I don't know what I am talking about, but wouldn't this make cheating easier?

Re: Missing features for Unsynced Luarules
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.