a function inside an array inside a ds_queue

G

Gridma

Guest
hello,

here's the thing, i put an function in array[0] waits to be excuted and how long it will be delay (seconds) in array[1], then i drop them in to ds_queue using ds_queue_enqueue.

script:
var command;
command[0] = aScript();
command[1] = 1;
ds_queue_enqueue(global.dsqueue,command);

then when i dequeue it from somewhere else, trying to put it into another array, and it executes itself.

script:
if(!ds_queue_empty(global.dsqueue)){
var command;
command = ds_queue_dequeue(global.dsqueue); // executes aScript() and pass array to command
}

i wanted to delay the execution, but it executes immediately after dequeue. how do i fix it? or i simply find another way?

thanks for helping.
 
R

rui.rosario

Guest
hello,

here's the thing, i put an function in array[0] waits to be excuted and how long it will be delay (seconds) in array[1], then i drop them in to ds_queue using ds_queue_enqueue.

script:
var command;
command[0] = aScript();
command[1] = 1;
ds_queue_enqueue(global.dsqueue,command);

then when i dequeue it from somewhere else, trying to put it into another array, and it executes itself.

script:
if(!ds_queue_empty(global.dsqueue)){
var command;
command = ds_queue_dequeue(global.dsqueue); // executes aScript() and pass array to command
}

i wanted to delay the execution, but it executes immediately after dequeue. how do i fix it? or i simply find another way?

thanks for helping.
You're storing the result from executing the script in the array, not the script itself.

Code:
command[0] = aScript();
You should change it to:

Code:
command[0] = aScript;
And then execute it with:

Code:
execute_script(command);
 
G

Gridma

Guest
got it, thanks for replying
 
Last edited by a moderator:
Top