View topic - Can't read global variable in gadget



All times are UTC + 1 hour


Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: 06 Jun 2011, 21:38 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
In one gadget I have in the synced part of the gadget a unit to be spawned in the following manner:
Code:
_G.dummyID=Spring.CreateUnit("dummy_land", x, y, z, "south", gaiaTeamID);

Then in a second gadget I try to read the global(in the unsynced part) but I get nil:
Code:
Spring.Echo("dummy has ID: ", _G.dummyID);

If I test this with a string it works perfectly but with the dummyID it doesn't. Why is that?


Top
 Offline Profile  
 
PostPosted: 06 Jun 2011, 22:19 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
you may have seen GG.foobar already in other gadgets


Top
 Offline Profile  
 
PostPosted: 06 Jun 2011, 23:03 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
Nope. Last time I was checking some gadgets was some months ago and everyone used _G. Anyway I renamed all my _G.foobar to GG.foobar but same thing happens. Not sure where to get an example from..


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 00:59 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
k didn't saw this
Pithikos wrote:
...in the synced part of the gadget
...in the unsynced part...


-> you did a logic error. how lua synced/unsynced works is explained on http://answers.springlobby.info/questions/


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 01:47 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
jK wrote:
k didn't saw this
Pithikos wrote:
...in the synced part of the gadget
...in the unsynced part...


-> you did a logic error. how lua synced/unsynced works is explained on http://answers.springlobby.info/questions/


Did a search there too for "globals synced", "globals unsynced", "synced unsynced" but got 0 results.

I solved my problem anyway. I use SetGameRulesParam() though there is null documentation in the wiki about it(at least from what I searched). I wanted to encapsulate a table with this but it seems that the function only accepts variables.


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 02:08 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
Pithikos wrote:
I use SetGameRulesParam() though there is null documentation in the wiki about it(at least from what I searched).
again wrong


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 02:53 
Spring Developer

Joined: 31 May 2009, 23:08
@Pithikos
http://answers.springlobby.info/questio ... per-gadget ?


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 07:44 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
jK wrote:
Pithikos wrote:
I use SetGameRulesParam() though there is null documentation in the wiki about it(at least from what I searched).
again wrong


http://springrts.com/wiki/Lua_System#Synced_2


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 10:30 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
FLOZi wrote:
jK wrote:
Pithikos wrote:
I use SetGameRulesParam() though there is null documentation in the wiki about it(at least from what I searched).
again wrong


http://springrts.com/wiki/Lua_System#Synced_2


Well seems to me that the function is in the wrong place. The Spring.GetGameRulesParam is in SyncedRead so I would expect Spring.SetGameRulesParam to be in SyncedCtrl. No idea what this "System Lua" is supposed to represent. A few words would not hurt whoever did it. :|


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.