Legacy GM [Solved] Set variable is not considered set.

A

Azerim

Guest
I started making a simple game and I have a problem.
In create event of a bullet (obj_plyt) I have:

var a = 0

and in step event I have:


if(a==0)
{
a=1
var r = irandom_range(0,1.99);
}

if(r<1)
{
than do stuff
}
else
{
then do other stuff
}
if(r<1)
{
do stuff
}

When I try to make bullet (obj_plyt) I get this error:

FATAL ERROR in
action number 1
of Step Event0
for object obj_plyta:

Variable obj_plyta.a(100002, -2147483648) not set before reading it.
at gml_Object_obj_plyta_StepNormalEvent_1 (line 1) - if(a==0)
 
var is keyword for local variable, that is, a variable that only exists in the codeblock in which it was specified.
Remove "var" from "var a = 0" and you'll be fine.
 
A

Azerim

Guest
var is keyword for local variable, that is, a variable that only exists in the codeblock in which it was specified.
Remove "var" from "var a = 0" and you'll be fine.
Thank you! Also removed var from "var r = ..."
 
Top