Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: SteelRat on April 01, 2015, 08:49:26 am
-
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
-
How do I pass a variable from one context to another context
You can't. What do you want to achieve?
-
How do I pass a variable from one context to another context
You can't. What do you want to achieve?
My idea was to have one object "Logic", after its establishment, give it the necessary data to solve any of the current task.
By analogy:
spawnCode ([params], code) //this logic
createTrigger ([params], condition code, activate code) //this trigger
-
It's not possible (and it would be dangerous) to access foreign contexts and variables from vehicle scripts. It will be possible to access vehicles from game script in the future, but there will be a mechanism for it, so that the script can get only the objects it's allowed to see, and perform only some tasks. Basically, a coordinated AI for some tasks.
-
It's not possible (and it would be dangerous) to access foreign contexts and variables from vehicle scripts. It will be possible to access vehicles from game script in the future, but there will be a mechanism for it, so that the script can get only the objects it's allowed to see, and perform only some tasks. Basically, a coordinated AI for some tasks.
PytonPago translate please!
Я и предполагал такое развитие событий, просто я знакомлюсь с миром по ближе).
-
PytonPago translate please!
Я и предполагал такое развитие событий, просто я знакомлюсь с миром по ближе).
"I thought it might be so, i just getting into this stuff a little more."
-
Thank you.
-
Thank you.
No need to thank the Pyton translator. Just use it like the google one ... whyteout those rude slang words. =D
-
Hi developers!
It would be great to have such
// global variables in user name space
var $Uns = this.$query_interface("ot::js::userNameSpace.get");
$Uns.setVariable( "varName", value);
var varName = $Uns.getVariable( "varName");
var varName = $Uns.getVariable( "varName", value); // Option. If the variable is not defined, it returns the specified value
$Uns.deleteVariable( "varName");