Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
*Solved* Help finding my coding error? #236728
11/16/08 05:16
11/16/08 05:16
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Hello everyone, I am working on a game and I wasn't having problems until I converted to .c files for the scripts instead of .wdl because I needed to use panels, but now when I go to call a function I get an error.

The error I get is "Crash in Main" when I press the space bar, which calls the gun_shoot() action. Any help is appreciated, below is the code for the main and gun_shoot().

Code:
action gun_shoot()
{
	ent_create("muzzleflash.mdl", vector(my.x + 130, my.y, my.z + 9), gun_flash);
	ent_create("bullet.mdl", vector(my.x + 135, my.y, my.z + 9), ball_fall);
	my.tilt += 15;
	wait (10);
	my.tilt -= 15;
	set(my,PASSABLE);
}

function main()
{	
	level_load ("Test.wmb");
	wait (2);
	while(1)
	{
		if (key_space == 1)
		{
			gun_shoot();
			wait(2);
		}
		else
		{
			wait(1);
		}
	}
}



Last edited by MattyTheG; 11/16/08 17:02.
Re: Help finding my coding error? [Re: MattyTheG] #236779
11/16/08 15:40
11/16/08 15:40
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You are using the my pointer in the gun_shoot action. That is not allowed as gun_shoot is not attached to an entity. I guess what you wanted to do was:

Code:
action gun_shoot()
{
	ent_create("muzzleflash.mdl", vector(my.x + 130, my.y, my.z + 9), gun_flash);
	you = ent_create("bullet.mdl", vector(my.x + 135, my.y, my.z + 9), ball_fall);
	your.tilt += 15;
	wait (10);
	your.tilt -= 15;
	set(your,PASSABLE);
}



Always learn from history, to be sure you make the same mistakes again...
Re: Help finding my coding error? [Re: Uhrwerk] #236782
11/16/08 15:53
11/16/08 15:53
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Thank you I will give that a shot. I was unaware that it was unattached to the entity since I set it as it's behavior in WDL, but none the less I shall try that code instead.

Is there any preference as to which is better, attaching the action to the entity, or using your instead of my?

Re: Help finding my coding error? [Re: MattyTheG] #236784
11/16/08 15:59
11/16/08 15:59
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Usually attaching an action to an entity is the better way as it is mor intuitive and understandable by more people. But at least maybe just a matter of personal preferences...

If you attach gun_shoot to an entity in WED this will of course work. But you're calling gun_shoot from the main function and the main function is of course not attached to anything.


Always learn from history, to be sure you make the same mistakes again...
Re: Help finding my coding error? [Re: Uhrwerk] #236791
11/16/08 17:01
11/16/08 17:01
Joined: Jul 2007
Posts: 48
M
MattyTheG Offline OP
Newbie
MattyTheG  Offline OP
Newbie
M

Joined: Jul 2007
Posts: 48
Thank you, I see what I was doing wrong now. I didn't realize that since it was already attached to an entity that I didn't have to call it or anything. I moved the while loop into the gun_shoot action and it works now. I have to fix it though since for some reason my physics doesn't work right now that I moved from .wdl scripts to .c , but that is for another time.


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