Stack Dont Work !

H

Hosein_namju

Guest
Hi
i have the code bellow in a script


vertex = argument[0];
n = vertex.instance_list_numerator; // Get Number Of Childs
if (n == 0) // If No Child Do The Self Print
global.stdy_statement += vertex.onit;


for(i = 0; i < n; i++) // If Child Do the Self & Other Print
{
global.count++;
global.stdy_statement += vertex.onit;
if(instance_exists(vertex.instance_list(i))
{
global.stdy_statement += vertex.instance_line(i).name;
script_stack(vertex.instance_list(i));
}
}

ignore the work that the code do, but if a set any value of 'n' variable, this function only run once, why ?
 
Last edited by a moderator:

TheSnidr

Heavy metal viking dentist
GMC Elder
You're using scripts that you haven't posted the source for, so it's difficult to say. My guess is that you use the variable i somewhere in the other scripts as well. You need to declare variables that should only be used in the current script with the "var" command at the start of the script, like this:
var i, n;
 
H

Hosein_namju

Guest
You're using scripts that you haven't posted the source for, so it's difficult to say. My guess is that you use the variable i somewhere in the other scripts as well. You need to declare variables that should only be used in the current script with the "var" command at the start of the script, like this:
var i, n;
the whole code you see above is "script_stack", i just forget to mention //SCRIPT STACK in , and iam sure the variables dont used any other sites, and all values are ok since i used the Debug mode with breakpoints to check it, but i cant understand why it dont make an stack as it suppose to do !
 
GM doesn't like recursive functions. You'll have to find another way to do the action, perhaps using an actual ds_stack of vertex instances (i.e. while (ds_stack_size(vertex_stack) > 0) { // Do stuff, adding a new instance to the stack at the end until there's no more instances } ).
 
H

Hosein_namju

Guest
GM doesn't like recursive functions. You'll have to find another way to do the action, perhaps using an actual ds_stack of vertex instances (i.e. while (ds_stack_size(vertex_stack) > 0) { // Do stuff, adding a new instance to the stack at the end until there's no more instances } ).
yes, i need use stack data structure manually. tnx for your help
 
Top