Hi cameni!
The script is invoked from the console
/*
Spawn logic object
*/
var obj = "ptm/Logic/Logic";
var initCode = 'this.log_inf("Object logic created");';
Object.prototype.ptm = {initCode: initCode}
$con.exec("var $world = $eview.$query_interface('ot::js::world.get')");
$con.exec("var logic = $world.create_instance(obj, #(pos 10), #rot, false)");
// Here everything is fine
// logic.ptm.initCode == 'this.log_inf("Object logic created");'
print(logic.ptm.initCode);
next
/*
package: ptm/Logic/Logic
script: logic.js
*/
var init = false;
function init_chassis(param) {
}
function init_vehicle() {
}
function update_frame() {
if (!init) {
if (this.ptm) { // here always this.ptm == undefined
eval(this.ptm.initCode);
init = true;
this.log_inf("Logic initialized");
}
}
}
Where is my mistake?
I have two links to the same object, but the new property is available only where I have added a new property to the prototype object.
I have thought about this, but I'm not sure.
Question
How do I pass a variable from one context to another context