Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, OptimusPrime, AndrewAMD), 14,882 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Crash in main? What? #320433
04/21/10 18:53
04/21/10 18:53
Joined: Mar 2010
Posts: 56
Hertfordshire, England
Panda_Dude Offline OP
Junior Member
Panda_Dude  Offline OP
Junior Member

Joined: Mar 2010
Posts: 56
Hertfordshire, England
I've hit a brick wall. When I run my script it says "Crash in Main" and it loads the level and the entity I want but I cant do anything with the entitiy.
Here's my code :
Code:
#include <acknex.h>
#include <default.c>

VECTOR* ball_force;
ENTITY* ball;

function main ()
{
	level_load ("level.wmb");
	ball = ent_create ("ball.mdl", vector (622,-674,0), NULL);
	ph_setgravity (vector (0,0,-450));
	phent_settype (ball, PH_RIGID, PH_SPHERE);
	phent_setmass (ball, 3, PH_SPHERE);
	phent_setfriction (ball, 80);
	phent_setdamping (ball, 70,70);
	phent_setelasticity (ball, 50, 20);
	while (1)
	{
		ball_force.x = 180 * time_step * (key_cur-key_cul);
		ball_force.y = 180 * time_step * (key_cuu-key_cud);
		ball_force.z = 0;
		phent_addtorqueglobal (ball, ball_force);
		camera.x = ball.x -300;
		camera.y = ball.y;
		camera.z = 1000;
		camera.tilt = -60;
		wait(1);
	}
}


I don't see anything obviously wrong. What's going on here?

Re: Crash in main? What? [Re: Panda_Dude] #320436
04/21/10 19:00
04/21/10 19:00
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Tried to add a
Code:
wait(3);


after the level_load instruction?

Re: Crash in main? What? [Re: Xarthor] #320440
04/21/10 19:07
04/21/10 19:07
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Before you create any entities in your level, you must use a "wait(3);" instruction. Otherwise your script will crash.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Crash in main? What? [Re: Redeemer] #320463
04/21/10 20:35
04/21/10 20:35
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Originally Posted By: Redeemer
Before you create any entities in your level, you must use a "wait(3);" instruction. Otherwise your script will crash.
That's just not true, unless the use of physics entities is a special case I haven't heard about.

Have you tried commenting out one line at a time to see if you can make it work?

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Crash in main? What? [Re: JibbSmart] #320481
04/21/10 21:23
04/21/10 21:23
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
I tried it right now: without a wait(3) after level_load, ent_create gives a crash !

Re: Crash in main? What? [Re: Widi] #320496
04/21/10 22:56
04/21/10 22:56
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
That's very strange, because I checked my projects before I opened my mouth -- they ent_create huge bunches of entities straight after a "level_load".

It isn't mentioned in the manual, either. AFAIK that's a very old issue that has been resolved a long time ago.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Crash in main? What? [Re: JibbSmart] #320518
04/22/10 07:47
04/22/10 07:47
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
ball_force vector shouldnt be a pointer, it should be a declaration.

change:
Code:
VECTOR* ball_force;



to this:
Code:
VECTOR ball_force;



and it works laugh
(tested ;))

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Crash in main? What? [Re: Helghast] #320519
04/22/10 07:54
04/22/10 07:54
Joined: Apr 2008
Posts: 594
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 594
Austria
I often see that when something does not work, some users always give the advice to add a wait(), no matter if it makes sense or not.

wait(3) after level loading makes no sense. If a code really works after adding a wait(), there is likely something else wrong with the project. The only situation where you really need a wait is when you want to wait until some other function or an event is finished.

laugh

Re: Crash in main? What? [Re: Petra] #320520
04/22/10 08:12
04/22/10 08:12
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Originally Posted By: Petra
I often see that when something does not work, some users always give the advice to add a wait(), no matter if it makes sense or not.

wait(3) after level loading makes no sense. If a code really works after adding a wait(), there is likely something else wrong with the project. The only situation where you really need a wait is when you want to wait until some other function or an event is finished.

laugh


on the level_load it does make sense, untill this thread, I was still under the impression that like in old A6, you did need a wait(3) to initialise all the map entities, models etc etc. It's just an old habit I guess tongue

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Crash in main? What? [Re: Helghast] #320531
04/22/10 13:53
04/22/10 13:53
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Quote:
wait(3) after level loading makes no sense. If a code really works after adding a wait(), there is likely something else wrong with the project. The only situation where you really need a wait is when you want to wait until some other function or an event is finished.


It makes perfect sense. After calling level_load, you must wait a few frames before you create any objects, because it takes a few cycles to finish loading the level.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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