[Scripting] global variables?
Anyone knows how to create a variable in REDkit script which I can access from different classes?
I tried
public class _global
{
public var tmpl4: CEntityTemplate;
}
but when using _global.tmpl4 I get the error: member of void.
I tried it with
struct _glob
{
editable var tmpl3: CEntityTemplate;
}
but to get access to it I have to put a
var globTest: _glob ;
in the scope where I'm calling from, for example a function not allowing global access.
The background: I'm spawning a Nekker in a state of a CStateMachine derived class. This is working fine:
tmpl1 = (CEntityTemplate)LoadResource("nekker_strong");
theGame.CreateEntity(tmpl1, pos, rot);
with var tmpl1 : CEntityTemplate;
But I need access to tmpl1 from outside the class to alter the behavior of the Nekker after spawning.
Any ideas?
edit: Looks like the vars in a state are being preserved.
So calling an additional entry function in the state should do the trick.
Anyone knows how to create a variable in REDkit script which I can access from different classes?
I tried
public class _global
{
public var tmpl4: CEntityTemplate;
}
but when using _global.tmpl4 I get the error: member of void.
I tried it with
struct _glob
{
editable var tmpl3: CEntityTemplate;
}
but to get access to it I have to put a
var globTest: _glob ;
in the scope where I'm calling from, for example a function not allowing global access.
The background: I'm spawning a Nekker in a state of a CStateMachine derived class. This is working fine:
tmpl1 = (CEntityTemplate)LoadResource("nekker_strong");
theGame.CreateEntity(tmpl1, pos, rot);
with var tmpl1 : CEntityTemplate;
But I need access to tmpl1 from outside the class to alter the behavior of the Nekker after spawning.
Any ideas?
edit: Looks like the vars in a state are being preserved.
So calling an additional entry function in the state should do the trick.
Last edited: