|
Crash in main? What?
#320433
04/21/10 18:53
04/21/10 18:53
|
Joined: Mar 2010
Posts: 56 Hertfordshire, England
Panda_Dude
OP
Junior Member
|
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 :
#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: Redeemer]
#320463
04/21/10 20:35
04/21/10 20:35
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
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: Widi]
#320496
04/21/10 22:56
04/21/10 22:56
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
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
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
ball_force vector shouldnt be a pointer, it should be a declaration. change: to this: and it works  (tested ;)) regards,
|
|
|
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
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
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. 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  regards,
|
|
|
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
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,660
North America
|
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.
|
|
|
|