E
Edoran
Guest
Help! I can't figure out why this isn't working.
I am making a game where at the beginning, a board is created from a random selection of tiles in a random order. There can only be so many of each tile on the board at a time.
Here is my code for the first tile placement
///Tile 1
//Randomizer
if irandom(6)=0
{
global.ran1=0
}
else
if irandom(6)=1
{
global.ran1=1
}
else
if irandom(6)=2
{
global.ran1=2
}
else
if irandom(6)=3
{
global.ran1=3
}
else
if irandom(6)=4
{
global.ran1=4
}
else
if irandom(6)=5
{
global.ran1=5
}
else
if irandom(6)=6
{
global.ran1=6
}
//1st tile
if (global.ran1 = 0) && (global.p0 > 0) then
{
instance_create(192,160,obj_p0)
}
if (global.ran1 = 1) && (global.p1 > 0) then
{
instance_create(192,160,obj_p1)
}
if (global.ran1 = 2) && (global.p2 > 0) then
{
instance_create(192,160,obj_p2)
}
if (global.ran1 = 3) && (global.p3 > 0) then
{
instance_create(192,160,obj_p3)
}
if (global.ran1 = 4) && (global.p4 > 0) then
{
instance_create(192,160,obj_p4)
}
if (global.ran1 = 5) && (global.p5 > 0) then
{
instance_create(192,160,obj_p5)
}
if (global.ran1 = 6) && (global.p6 > 0) then
{
instance_create(192,160,obj_p6)
}
It comes back at me with this error
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_setup:
global variable <unknown built-in variable>(-1610512734, -2147483648) not set before reading it.
at gml_Script_scr_tile1a (line 42) - if (global.ran1 = 1) && (global.p1 > 0) then
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_tile1a (line 42)
called from - gml_Object_obj_setup_CreateEvent_1 (line 1) - script_execute(scr_tile1a)
Each instance of a certain tile created reduces the global.p(number of tile) by 1, so that when it = 0 it won't create any more.
I am quite new to Game Maker, so this might be the completely wrong way to go about it in the first place, any help appreciated
Thanks,
I am making a game where at the beginning, a board is created from a random selection of tiles in a random order. There can only be so many of each tile on the board at a time.
Here is my code for the first tile placement
///Tile 1
//Randomizer
if irandom(6)=0
{
global.ran1=0
}
else
if irandom(6)=1
{
global.ran1=1
}
else
if irandom(6)=2
{
global.ran1=2
}
else
if irandom(6)=3
{
global.ran1=3
}
else
if irandom(6)=4
{
global.ran1=4
}
else
if irandom(6)=5
{
global.ran1=5
}
else
if irandom(6)=6
{
global.ran1=6
}
//1st tile
if (global.ran1 = 0) && (global.p0 > 0) then
{
instance_create(192,160,obj_p0)
}
if (global.ran1 = 1) && (global.p1 > 0) then
{
instance_create(192,160,obj_p1)
}
if (global.ran1 = 2) && (global.p2 > 0) then
{
instance_create(192,160,obj_p2)
}
if (global.ran1 = 3) && (global.p3 > 0) then
{
instance_create(192,160,obj_p3)
}
if (global.ran1 = 4) && (global.p4 > 0) then
{
instance_create(192,160,obj_p4)
}
if (global.ran1 = 5) && (global.p5 > 0) then
{
instance_create(192,160,obj_p5)
}
if (global.ran1 = 6) && (global.p6 > 0) then
{
instance_create(192,160,obj_p6)
}
It comes back at me with this error
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_setup:
global variable <unknown built-in variable>(-1610512734, -2147483648) not set before reading it.
at gml_Script_scr_tile1a (line 42) - if (global.ran1 = 1) && (global.p1 > 0) then
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_tile1a (line 42)
called from - gml_Object_obj_setup_CreateEvent_1 (line 1) - script_execute(scr_tile1a)
Each instance of a certain tile created reduces the global.p(number of tile) by 1, so that when it = 0 it won't create any more.
I am quite new to Game Maker, so this might be the completely wrong way to go about it in the first place, any help appreciated
Thanks,