• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Broken objects / create_event activated multiple times

fawf

Member
This is an strange issue I couldn't find mentioned anywhere and thought I should bring it up in case anyone else encounters it.

Somehow one of the objects I was working on became faulty. When creating an instance of this particular object, the create event would run for ALL instances of that object.

I then duplicated the object to see if the problem persisted but now the create event for this new object did not run at all. Undefined variable errors were being thrown at me for variables defined in the create event, and message functions put in there deliberately did not appear. (show_message and show_debug_message )


The fix

I seem to have fixed it by creating a new object and manually copy pasting the scripts manually. Everything seems to function normally, as do the other objects in-game, leading me to believe this original object was somehow defective, which carried over to the duplicated object.

In terms of object info all three objects are identical.


btw, does this forum support spoiler tags? I would like to post object info but there's quite a bit there.

:edit:

Original object:
Information about object: obj_coin_chain_casper
Sprite: spr_treasureChest_down
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask: spr_coin
No Physics Object
Create Event:
for all obj_coin_chain_casper: execute code:

step=0;

image_speed = 0;

A_x = x-90;
A_y = y - 30;

B_x = x+90;
B_y = y;

line_dist = 0;
line_dir = 0;

/*
movement types

constant
xspeed
yspeed
rotate around centre

*/

movement_type = "constant";

xspeed = 0
yspeed = 0

/* coin data
*/

ds_coin_list = ds_list_create();
i_s = 5;
coins = 0
max_coins = 30
c_timer = 40

alarm[0] = c_timer;

show_debug_message("event create for "+string(id))

Destroy Event:
execute code:

ds_list_destroy(ds_coin_list);

Alarm Event for alarm 0:
execute code:

/*
ds_coin_list contains coin data

i_s = total number of stored values ( 5 )

coin data:

i | value

0 - spr_sprite
1 - distance from A
2 - speed
3 - x offset
4 - y offset
--
5 -
6 -
7 -
8 -
9 -
--

*/


ds_list_add(ds_coin_list,
choose(spr_coin,spr_coin2,spr_coin3),
0,
2,
irandom(8)-4,
irandom(8)-4,
);

coins++;

if coins < max_coins
alarm[0] = c_timer;

//scr_ds_list_show_contents(ds_coin_list,"coin list")


Step Event:
execute code:

line_dir = point_direction(A_x,A_y,B_x,B_y);
line_dist = point_distance(A_x,A_y,B_x,B_y);

/* movement
*/
if movement_type = "rotate"
{
B_x += lengthdir_x(1,line_dir-90);
B_y += lengthdir_y(1,line_dir-90);

A_x += lengthdir_x(1,line_dir+90);
A_y += lengthdir_y(1,line_dir+90);
}
if movement_type = "constant"
{
A_x += xspeed
B_x += xspeed
A_y += yspeed
B_y += yspeed
}
/*
*/

/* coins
*/
if coins>0
{
var del = -1;

for(i = 0; i< coins-1; i++)
{
var d, s, xo, yo, xx, yy;

d = ds_coin_list[| 1 +(i*i_s)]
s = ds_coin_list[| 2 +(i*i_s)]
xo = ds_coin_list[| 3 +(i*i_s)]
yo = ds_coin_list[| 4 +(i*i_s)]
xx = A_x + lengthdir_x(d, line_dir) + xo;
yy = A_y + lengthdir_y(d, line_dir) + yo;

d += s;

ds_coin_list[| 1 +(i*i_s)] = d
//
if place_meeting(xx,yy,obj_bern)
{
scr_attack(0,3)
}
//
if d>line_dist
del = i;
}

if del!=-1
{
coins--;
repeat(i_s)
ds_list_delete( ds_coin_list, 0 +(del*i_s) );
}
}

Draw Event:
execute code:

draw_sprite(sprite_index,-1,A_x,A_y)
draw_sprite(sprite_index,-1,B_x,B_y)
//draw_line(A_x,A_y,B_x,B_y)

for(i = 0; i< coins-1; i++)
{
var s, d, xo, yo, xx,yy;
s = ds_coin_list[| 0 +(i*i_s)]
d = ds_coin_list[| 1 +(i*i_s)]
xo = ds_coin_list[| 3 +(i*i_s)]
yo = ds_coin_list[| 4 +(i*i_s)]

xx = A_x + lengthdir_x(d, line_dir) + xo;
yy = A_y + lengthdir_y(d, line_dir) + yo;

draw_sprite(s,0,xx,yy);
}

Duplicate Object:
Information about object: obj_chain2
Sprite: spr_treasureChest_down
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask: spr_coin
No Physics Object
Create Event:
for all obj_coin_chain_casper: execute code:

step=0;

image_speed = 0;

A_x = x-90;
A_y = y - 30;

B_x = x+90;
B_y = y;

line_dist = 0;
line_dir = 0;

/*
movement types

constant
xspeed
yspeed
rotate around centre

*/

movement_type = "constant";

xspeed = 0
yspeed = 0

/* coin data
*/

ds_coin_list = ds_list_create();
i_s = 5;
coins = 0
max_coins = 30
c_timer = 40

alarm[0] = c_timer;

show_debug_message("event create for "+string(id))
show_message("heyo");

Destroy Event:
execute code:

ds_list_destroy(ds_coin_list);

Alarm Event for alarm 0:
execute code:

/*
ds_coin_list contains coin data

i_s = total number of stored values ( 5 )

coin data:

i | value

0 - spr_sprite
1 - distance from A
2 - speed
3 - x offset
4 - y offset
--
5 -
6 -
7 -
8 -
9 -
--

*/


ds_list_add(ds_coin_list,
choose(spr_coin,spr_coin2,spr_coin3),
0,
2,
irandom(8)-4,
irandom(8)-4,
);

coins++;

if coins < max_coins
alarm[0] = c_timer;

//scr_ds_list_show_contents(ds_coin_list,"coin list")


Step Event:
execute code:

line_dir = point_direction(A_x,A_y,B_x,B_y);
line_dist = point_distance(A_x,A_y,B_x,B_y);

/* movement
*/
if movement_type = "rotate"
{
B_x += lengthdir_x(1,line_dir-90);
B_y += lengthdir_y(1,line_dir-90);

A_x += lengthdir_x(1,line_dir+90);
A_y += lengthdir_y(1,line_dir+90);
}
if movement_type = "constant"
{
A_x += xspeed
B_x += xspeed
A_y += yspeed
B_y += yspeed
}
/*
*/

/* coins
*/
if coins>0
{
var del = -1;

for(i = 0; i< coins-1; i++)
{
var d, s, xo, yo, xx, yy;

d = ds_coin_list[| 1 +(i*i_s)]
s = ds_coin_list[| 2 +(i*i_s)]
xo = ds_coin_list[| 3 +(i*i_s)]
yo = ds_coin_list[| 4 +(i*i_s)]
xx = A_x + lengthdir_x(d, line_dir) + xo;
yy = A_y + lengthdir_y(d, line_dir) + yo;

d += s;

ds_coin_list[| 1 +(i*i_s)] = d
//
if place_meeting(xx,yy,obj_bern)
{
scr_attack(0,3)
}
//
if d>line_dist
del = i;
}

if del!=-1
{
coins--;
repeat(i_s)
ds_list_delete( ds_coin_list, 0 +(del*i_s) );
}
}

Draw Event:
execute code:

draw_sprite(sprite_index,-1,A_x,A_y)
draw_sprite(sprite_index,-1,B_x,B_y)
//draw_line(A_x,A_y,B_x,B_y)

for(i = 0; i< coins-1; i++)
{
var s, d, xo, yo, xx,yy;
s = ds_coin_list[| 0 +(i*i_s)]
d = ds_coin_list[| 1 +(i*i_s)]
xo = ds_coin_list[| 3 +(i*i_s)]
yo = ds_coin_list[| 4 +(i*i_s)]

xx = A_x + lengthdir_x(d, line_dir) + xo;
yy = A_y + lengthdir_y(d, line_dir) + yo;

draw_sprite(s,0,xx,yy);
}

Third object:
Information about object: obj_thirdChain
Sprite: spr_treasureChest_down
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask: spr_coin
No Physics Object
Create Event:
execute code:

step=0;

image_speed = 0;

A_x = x-90;
A_y = y - 30;

B_x = x+90;
B_y = y;

line_dist = 0;
line_dir = 0;

/*
movement types

constant
xspeed
yspeed
rotate around centre

*/

movement_type = "constant";

xspeed = 0
yspeed = 0

/* coin data
*/

ds_coin_list = ds_list_create();
i_s = 5;
coins = 0
max_coins = 30
c_timer = 40

alarm[0] = c_timer;

show_debug_message("event create for "+string(id))

Destroy Event:
execute code:

ds_list_destroy(ds_coin_list);

Alarm Event for alarm 0:
execute code:

/*
ds_coin_list contains coin data

i_s = total number of stored values ( 5 )

coin data:

i | value

0 - spr_sprite
1 - distance from A
2 - speed
3 - x offset
4 - y offset
--
5 -
6 -
7 -
8 -
9 -
--

*/


ds_list_add(ds_coin_list,
choose(spr_coin,spr_coin2,spr_coin3),
0,
2,
irandom(8)-4,
irandom(8)-4,
);

coins++;

if coins < max_coins
alarm[0] = c_timer;

//scr_ds_list_show_contents(ds_coin_list,"coin list")


Step Event:
execute code:

line_dir = point_direction(A_x,A_y,B_x,B_y);
line_dist = point_distance(A_x,A_y,B_x,B_y);

/* movement
*/
if movement_type = "rotate"
{
B_x += lengthdir_x(1,line_dir-90);
B_y += lengthdir_y(1,line_dir-90);

A_x += lengthdir_x(1,line_dir+90);
A_y += lengthdir_y(1,line_dir+90);
}
if movement_type = "constant"
{
A_x += xspeed
B_x += xspeed
A_y += yspeed
B_y += yspeed
}
/*
*/

/* coins
*/
if coins>0
{
var del = -1;

for(i = 0; i< coins-1; i++)
{
var d, s, xo, yo, xx, yy;

d = ds_coin_list[| 1 +(i*i_s)]
s = ds_coin_list[| 2 +(i*i_s)]
xo = ds_coin_list[| 3 +(i*i_s)]
yo = ds_coin_list[| 4 +(i*i_s)]
xx = A_x + lengthdir_x(d, line_dir) + xo;
yy = A_y + lengthdir_y(d, line_dir) + yo;

d += s;

ds_coin_list[| 1 +(i*i_s)] = d
//
if place_meeting(xx,yy,obj_bern)
{
scr_attack(0,3)
}
//
if d>line_dist
del = i;
}

if del!=-1
{
coins--;
repeat(i_s)
ds_list_delete( ds_coin_list, 0 +(del*i_s) );
}
}

Draw Event:
execute code:

draw_sprite(sprite_index,-1,A_x,A_y)
draw_sprite(sprite_index,-1,B_x,B_y)
//draw_line(A_x,A_y,B_x,B_y)

for(i = 0; i< coins-1; i++)
{
var s, d, xo, yo, xx,yy;
s = ds_coin_list[| 0 +(i*i_s)]
d = ds_coin_list[| 1 +(i*i_s)]
xo = ds_coin_list[| 3 +(i*i_s)]
yo = ds_coin_list[| 4 +(i*i_s)]

xx = A_x + lengthdir_x(d, line_dir) + xo;
yy = A_y + lengthdir_y(d, line_dir) + yo;

draw_sprite(s,0,xx,yy);
}
 
Last edited:

rIKmAN

Member
btw, does this forum support spoiler tags? I would like to post object info but there's quite a bit there.
Sure does, just put [ spoiler] before the text, and [ /spoiler] after it to enclose it inside the tags (remove the spaces at the start - I've added them so it doesn't actually create the spoiler.
 
Top