Data Realms Fan Forums
http://45.55.195.193/

Refering to another actor through variables
http://45.55.195.193/viewtopic.php?f=73&t=17710
Page 1 of 1

Author:  Dr. Evil [ Mon Feb 01, 2010 2:43 am ]
Post subject:  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?

Author:  Grif [ Mon Feb 01, 2010 5:26 am ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/