Thanks! Now is perfectly clear
Vianellos
@Vianellos
Posts made by Vianellos
-
RE: Main script running twice
Ok, thank you. It's much clearer now. I understand that use javascript global variables is deprecated and it's better to use the Memory method if I want to maintain persistence between the different ticks.
What do you mean with "Also note that this memory will get periodically reset"? Is there any reliable way to store values between the script iterations?
-
Main script running twice
Hello, I'm trying to understand the architecture of this game, but I'm having some issues.
I'm playing in my standalone server and I'm experiencing this strange behaviour:
Main code is executed twice on the start and then keep running in two different instances. Every tick the system runs only one of those two, but they are not alternate. It looks more like that system randomly runs only one of the two instances every tick. This is the code I'm using to show the problem I'm talking about:
var scriptnum= Math.floor((Math.random() * 1000) + 1); console.log('start script number '+scriptnum) var loopnum = 0
module.exports.loop = function() { // executed every tick console.log("time:"+Game.time+'; script '+scriptnum+'; loop num '+loopnum + ";") loopnum++ }
As I launch this code this is the output:
[14:09:34]start script number 414 [14:09:34]time:15467; script 414; loop num 0; [14:09:35]start script number 386 [14:09:35]time:15468; script 386; loop num 0; [14:09:36]time:15469; script 386; loop num 1; [14:09:37]time:15470; script 386; loop num 2; [14:09:38]time:15471; script 414; loop num 1; [14:09:39]time:15472; script 386; loop num 3; [14:09:40]time:15473; script 386; loop num 4; [14:09:41]time:15474; script 414; loop num 2;
Why is the code executed twice in this strange way?
Thank you