by Ty Halderman » Fri Jul 18, 2003 7:30 pm
I seem to be able to declare global (world) variable arrays okay if I put them in a common #include file and reference them from code in each of 2 maps' scripts, but if I call common library routines to manipulate them, it seems that the values get lost between maps. Is it possible that variables used in libraries aren't being initialized right? In particular, that they are perhaps initializing when they shouldn't?
This happens whether the library declares the variables or includes a common file to do so--it keeps track fine while in a single map, but when the map changes, the values are all zeroed. Map change is "normal" (not a IDCLEV cheat) and is within the same hub, even.
Picture this, basically:
Code: Select all
world int 42:fred[]; // in the #included file for maps and library
MAP01:
// supposed to store 37 to subscript 2 of fred[]
f_putval(2,37);
x = getval(2); // returns 37
MAP02:
// supposed to retrieve said value from fred[2]
x = f_getval(2); // returns zero
LIBUTIL:
function void f_putval(int ix, int amount)
{
fred[ix] = amount;
}
function int f_getval(int ix)
{
return fred[ix];
}
I wrote that from scratch in this post--forgive any minor syntax errors.
I seem to be able to declare global (world) variable arrays okay if I put them in a common #include file and reference them from code in each of 2 maps' scripts, but if I call common library routines to manipulate them, it seems that the values get lost between maps. Is it possible that variables used in libraries aren't being initialized right? In particular, that they are perhaps initializing when they shouldn't?
This happens whether the library declares the variables or includes a common file to do so--it keeps track fine while in a single map, but when the map changes, the values are all zeroed. Map change is "normal" (not a IDCLEV cheat) and is within the same hub, even.
Picture this, basically:
[code]world int 42:fred[]; // in the #included file for maps and library
MAP01:
// supposed to store 37 to subscript 2 of fred[]
f_putval(2,37);
x = getval(2); // returns 37
MAP02:
// supposed to retrieve said value from fred[2]
x = f_getval(2); // returns zero
LIBUTIL:
function void f_putval(int ix, int amount)
{
fred[ix] = amount;
}
function int f_getval(int ix)
{
return fred[ix];
}[/code]
I wrote that from scratch in this post--forgive any minor syntax errors.