Jump to content


Photo

Mouse Click Script Repeating?


  • This topic is locked This topic is locked
4 replies to this topic

#1 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 17 July 2009 - 02:32 PM

hi guys, i have a really odd bug that shouldn't happen, i have this code:
show_debug_message("started")
//formula is y=x*x+c
//yy=inum_create(mouse_x,mouse_y)
xx=inum_create(mouse_x/mul-inc,mouse_y/mul-inc)
iter=0
ox=mouse_x
oy=mouse_y
surface_set_target(suf)
draw_clear(c_white)
do
{
yy=inum_mul(xx,xx)
ny=inum_add(yy,c)
inum_destroy(yy)
yy=ny
draw_line(yy.x*mul+inc,yy.y*mul+inc,ox*mul+inc,oy*mul+in
c)
ox=yy.x
oy=yy.y
xx=yy
iter+=1
show_debug_message(string(iter)+" iterations from "+string(id))
}
until (iter>100 or yy.x+yy.y>1000)
surface_reset_target()
show_debug_message("ended")
the contents off those scripts doesn't matter, since i get this debug output:

started
1 iterations from 1000002
2 iterations from 1000002
started
1 iterations from 1000002
2 iterations from 1000002

which keeps repeating itself, now if you look at my code the show_debug_message("started") isn't even in a loop, so how is it possible that it repeats itself(within one step), note that this is all inside a global mouse released event, only one object in the room(the scripts do create/destroy some objects, but those don't have code...), how is this possible?
  • 0

#2 Mnementh

Mnementh

    15151

  • GMC Elder
  • 6328 posts
  • Version:GM:Studio

Posted 17 July 2009 - 02:35 PM

show_debug_message("started by: " + string(id));

  • 0

#3 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 17 July 2009 - 02:47 PM

show_debug_message("started by: " + string(id));

can't test that right now, computer decided to reboot, lost my work(except that script here...)
but how can a script possibly be continued by an object that didn't start it?
  • 0

#4 Big J

Big J

    GMC Member

  • GMC Member
  • 2852 posts
  • Version:GM8.1

Posted 20 July 2009 - 02:48 AM

In order to understand this, we'd need the Game Maker source file of your project. Otherwise there is no way to know. Even if you think the content of a script doesn't matter, it does matter. I don't do shot-in-the-dark debugging, and I'm sure most others don't prefer to either.

EDIT: However, I decided to indent your code to make it easier to read:
show_debug_message("started");
//formula is y=x*x+c
//yy=inum_create(mouse_x,mouse_y);
xx = inum_create(mouse_x/mul-inc,mouse_y/mul-inc);
iter = 0;
ox = mouse_x;
oy = mouse_y;
surface_set_target(suf);
draw_clear(c_white);
do
{
	yy = inum_mul(xx,xx);
	ny = inum_add(yy,c);
	inum_destroy(yy);
	yy = ny;
	draw_line(yy.x*mul+inc,yy.y*mul+inc,ox*mul+inc,oy*
mul+inc);
	ox = yy.x;
	oy = yy.y;
	xx = yy;
	iter += 1;
	show_debug_message(string(iter)+" iterations from "+string(id));
}
until (iter > 100 or yy.x+yy.y > 1000);
surface_reset_target();
show_debug_message("ended");
For all I know this code could be a script and could be called by other scripts which you have omitted.

The following 4 scripts (and perhaps some others) are omitted:

inum_create()
inum_add()
inum_mul()
inum_destroy()

I understand that you lost your work because you forgot to save, but once you re-create what you lost, provide the source as a .gm6 or .gmk file and I'll gladly take a look at the whole picture. Until then, good luck. :GM071:

Edited by Big J, 20 July 2009 - 03:01 AM.

  • 0

#5 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 20 July 2009 - 09:49 AM

In order to understand this, we'd need the Game Maker source file of your project. Otherwise there is no way to know. Even if you think the content of a script doesn't matter, it does matter. I don't do shot-in-the-dark debugging, and I'm sure most others don't prefer to either.

EDIT: However, I decided to indent your code to make it easier to read:

show_debug_message("started");
//formula is y=x*x+c
//yy=inum_create(mouse_x,mouse_y);
xx = inum_create(mouse_x/mul-inc,mouse_y/mul-inc);
iter = 0;
ox = mouse_x;
oy = mouse_y;
surface_set_target(suf);
draw_clear(c_white);
do
{
	yy = inum_mul(xx,xx);
	ny = inum_add(yy,c);
	inum_destroy(yy);
	yy = ny;
	draw_line(yy.x*mul+inc,yy.y*mul+inc,ox*mul+inc,oy*
mul+inc);
	ox = yy.x;
	oy = yy.y;
	xx = yy;
	iter += 1;
	show_debug_message(string(iter)+" iterations from "+string(id));
}
until (iter > 100 or yy.x+yy.y > 1000);
surface_reset_target();
show_debug_message("ended");
For all I know this code could be a script and could be called by other scripts which you have omitted.

The following 4 scripts (and perhaps some others) are omitted:

inum_create()
inum_add()
inum_mul()
inum_destroy()

I understand that you lost your work because you forgot to save, but once you re-create what you lost, provide the source as a .gm6 or .gmk file and I'll gladly take a look at the whole picture. Until then, good luck. :GM071:

basically those scripts were for complex number support, they created dummy objects and edited the x/y from those, add just adds the x/y off two objects(the complex number way) and mul multiplies them, create and destroy are not that hard to guess, all scripts were one liners in the form off
return inum_create(argument0.x+argument1.x,argument0.y+argument1.
y)
and inum_create was something like
return instance_create(argument0,argument1,global.dummy)
destroy was
with(argument0){instance_destroy()}

the only scripts actually calling functions are create and destroy, that's all the code that was in there(this is all from memory so there my be some mistakes...)
EDIT:all the code i gave was alone in a mouseclick event

Edited by ditdingiscool, 20 July 2009 - 09:50 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users