View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:02 am



Reply to topic  [ 2 posts ] 
 Refering to another actor through variables 
Author Message
User avatar

Joined: Mon Aug 17, 2009 3:00 am
Posts: 242
Location: The Great White North
Reply with quote
Post Refering to another actor through variables
Alright. Sorry for the second topic in less than a week.

In the script for an actor:

Code:
self.Number = 5;

local That = CreateAEmitter ("Thingamabob", "Faction.rte");
That.ParentVariable = self;
MovableMan:AddParticle(That);


In the script for "Thingamabob" :

Code:
self.ParentVariable.Number = self.ParentVariable.Number + 8;


However, this this causes a console error which reads something like
Error: (filepath to Thingamabob) Attempt to index field 'ParentVariable' (a nil value)

Thingamabob is only ever created through the actor's lua script.

How might I go about changing one object's variable from another using lua?


Mon Feb 01, 2010 2:43 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Refering to another actor through variables
The easiest method that doesn't involve global variables (which can cause problems due to nonspecific scope) is changing presetname or goldcost, which will 'stick' to a specific instance of any particular actor or particle.


Mon Feb 01, 2010 5:26 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users


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 © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.049s | 13 Queries | GZIP : Off ]