Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, AndrewAMD, TedMar), 837 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Makes no sense!! #235473
11/07/08 20:41
11/07/08 20:41
Joined: Aug 2008
Posts: 218
U.S.
GamerX Offline OP
Member
GamerX  Offline OP
Member

Joined: Aug 2008
Posts: 218
U.S.
Ok i have spent all day on this and it should work it looks perfect to me but everytime it crashes. So heres The code ill explain after it.

Code:
function move()
{
c_setminmax(me);
set(my,FLAG2);

	while(my.x > posa.x)///this crashes!!
	{
	 c_move (my, vector(20 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | IGNORE_FLAG2);
	 my.pan = 180;
		wait(1);
	}



}

action test_spawn()
{
	while(1)
	{
	ent_create("ship.mdl",vector(my.x,my.y,ship.z),move); 
		wait(-5);
	}

}
action ship_move()
{
	ship = my;

	while(1)
	{
		
	if (key_w) c_move (my, vector(40 * time_step, 0, 0), nullvector,GLIDE | IGNORE_FLAG2);
    	if (key_s) c_move (my, vector(-40 * time_step, 0, 0), nullvector, GLIDE | IGNORE_FLAG2);
    	if (key_d) 	c_move (my, vector(0 ,-40* time_step , 0), nullvector,GLIDE | IGNORE_FLAG2);
    	if (key_a) 	c_move (my, vector(0 , 40* time_step , 0), nullvector,GLIDE | IGNORE_FLAG2);  
    	wait(1);
    	my.pan = 0; my.tilt= 0; my.roll = 0;
    	}

}


So basically it creates a ship model every 5 seconds and the ship model get the action move() and im trying to make it move while the .x position is greater than posa.x. There is a file included called defines.c that has posa in it it looks like this.

Code:
ENTITY* enemy;
ENTITY* ship;
ENTITY* pos1;
ENTITY* pos2;
ENTITY* pos3;
ENTITY* pos4;
ENTITY* pos5;
ENTITY* pos6;
ENTITY* pos7;
ENTITY* pos8;
ENTITY* pos9;
ENTITY* pos10;
ENTITY* posa;
ENTITY* posb;
ENTITY* posc;
ENTITY* posd;

action pos1_action()
{
	pos1 = my;
}

action pos2_action()
{
		pos2 = my;
}

action pos3_action()
{
		pos3 = my;
}

action pos4_action()
{
		pos4 = my;
}

action pos5_action()
{
		pos5 = my;
}

action pos6_action()
{
		pos6 = my;
}

action pos7_action()
{
		pos7 = my;
}

action pos8_action()
{
		pos8 = my;
}

action pos9_action()
{
		pos9 = my;
}

action pos10_action()
{
		pos10 = my;
}

action posa_action()
{
		posa = my;
}

action posb_action()
{
		posb = my;
}

action posc_action()
{
		posc = my;
}

action posd_action()
{
		posd = my;
}


there is a block in the level that has the posa action attached to it. But the problem is when i run the script it crashes. Sometimes it crashes in move() and sometimes in test_spawn. However it does work if i put ship.x in referring to the pointer attached to the ship_move function. I have tried changing the names i have tried doing just about everything i know how to. It looks perfectly fine to me and i don't see the problem. It really makes no sense so either it is a bug or it is right in front of my eyes and i am so annoyed i don't see it. So if You see the reason could you help me? I have done all this before (in a different project) and it worked fine. I have been working with GS for a couple of months know on and off and should be able to blow right through this since it is so easy but i must be missing something. I have fixed problems harder than this heck i have helped other people with bigger problems but this one is just so simple it has me beet.

Thanks.

Last edited by GamerX; 11/07/08 20:42.

"You may never know what results come of your action, but if you do nothing there will be no result."
-Mahatma Gandhi
Re: Makes no sense!! [Re: GamerX] #235476
11/07/08 21:06
11/07/08 21:06
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
First initialize all your pointers with NULL, i.e.

Code:
ENTITY* enemy;
ENTITY* ship = NULL;
ENTITY* pos1 = NULL;
ENTITY* pos2 = NULL;
ENTITY* pos3 = NULL;
//etc.


Second change your function move to:
Code:
function move()
{
  c_setminmax(me);
  set(my,FLAG2);
  while (posa == NULL)
    wait(1);
  while(my.x > posa.x)///this crashes!!
  {
    c_move (my, vector(20 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | IGNORE_FLAG2);
// and the rest of your code.


Most probably the move action is executed before your pointers were initialized. Common mistake.


Always learn from history, to be sure you make the same mistakes again...
Re: Makes no sense!! [Re: Uhrwerk] #235478
11/07/08 21:14
11/07/08 21:14
Joined: Aug 2008
Posts: 218
U.S.
GamerX Offline OP
Member
GamerX  Offline OP
Member

Joined: Aug 2008
Posts: 218
U.S.
Awsome thanks, didn't even think of that.


"You may never know what results come of your action, but if you do nothing there will be no result."
-Mahatma Gandhi

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1