|
the engine crashes on level load....
#203983
04/25/08 14:30
04/25/08 14:30
|
Joined: Apr 2008
Posts: 28 India,Kolkata
ayan
OP
Newbie
|
OP
Newbie
Joined: Apr 2008
Posts: 28
India,Kolkata
|
when i am tryin to change level m engine crashes....here is the code i am usin to change level...i am using A7.07
function level_change()
{
//wait(1); // i put comment it because it is preventing
// this function to work
if (EVENT_TYPE == event_impact)
{
my = NULL;
freeze_mode = 1;
level_load(“level2.wmb”);
wait(2);
freeze_mode = 0;
}
}
action zone_block
{
my.enable_impact = on;
my.event = level_change;
}
Last edited by ayan; 04/25/08 14:31.
|
|
|
Re: the engine crashes on level load....
[Re: ayan]
#203990
04/25/08 15:07
04/25/08 15:07
|
Joined: Jan 2006
Posts: 59 Desert Zone
WolfCoder
Junior Member
|
Junior Member
Joined: Jan 2006
Posts: 59
Desert Zone
|
If this is an event as a part of an entity, then it's crashing because I think level_loads aren't supposed to be called by an entity (because the entities get wasted and die, or something). I don't know if my way is anywhere near the best way, but it works ^^
var change_level_now = 0;
string new_level_str;
function handle_level_change()
{
while(1)
{
if(change_level_now == 1)
{
// Plus you can add cool transitions and stuff here with freeze mode and such ^^
change_level_now = 0;
level_load(new_level_str);
}
wait(1);
}
}
function change_the_level(newlevel)
{
// Can be safely called in entities events and stuff
new_level_str = newlevel;
change_level_now = 1;
}
function main()
{
... stuff
handle_level_change(); // Get it goin'
... stuff
}
Once the handler has been called once in main ya can just use change_the_level("level.wmb"); to do it within the event and eventually and hopefully, safety, it will change the level. That's back when I didn't use C++ to write Acknex games.
Last edited by WolfCoder; 04/25/08 15:09.
|
|
|
Re: the engine crashes on level load....
[Re: ayan]
#204002
04/25/08 15:56
04/25/08 15:56
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
AFAIK there is nothing like you cant call level_load from entities. You can use it every possible place. i use this way: the level block entity's string1 is set to next levels name(say "level2.wmb") and i have a function like that:
function baslat(){
SOUND* wwry = "wwry.ogg";
var i;
for (i =0;i <= 5;i++) {kollar[i] = 0; }
//above are initialazition of the global variables, that needs to be set 0 on every level starts
level_load(level);//i have a STRING* level;
freeze_mode = 0;
wait(-1);
snd_stopall(4);
snd_loop(wwry,10,0);
}
and in the impact event i use if (EVENT_TYPE == event_impact)
{
level = my.string1;
baslat();
}
Last edited by Quadraxas; 04/25/08 15:57.
3333333333
|
|
|
Re: the engine crashes on level load....
[Re: ayan]
#204008
04/25/08 16:43
04/25/08 16:43
|
Joined: Apr 2008
Posts: 28 India,Kolkata
ayan
OP
Newbie
|
OP
Newbie
Joined: Apr 2008
Posts: 28
India,Kolkata
|
changing levels within entity event driven function is resulting in engine crash
Last edited by ayan; 04/25/08 16:49.
|
|
|
Re: the engine crashes on level load....
[Re: ayan]
#204009
04/25/08 16:48
04/25/08 16:48
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
you cannot pass paramaters to events. but you can use "my" as usual in the events.
3333333333
|
|
|
Re: the engine crashes on level load....
[Re: Quad]
#204010
04/25/08 16:55
04/25/08 16:55
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
sorry for double posting but, it doent crashes. Problem is that the impact event called over and over instantly, thus you are calling level_load too many times, this make engine crash. function level_event(){
my.emask &= ~ENABLE_IMPACT;
ent_remove(me);
wait(-1);
my = NULL;
you = NULL;
level_load("level.wmb");
wait(2);
} works fine.
3333333333
|
|
|
Re: the engine crashes on level load....
[Re: ayan]
#204013
04/25/08 17:03
04/25/08 17:03
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
i dont know if you read my prev post but the reason is the event is called too many times during impact.
at first impact if you make it non-sensitive to impact by "my.emask &= ~ENABLE_IMPACT;" line, your entity wont respond to further impacts and it will work fine.
3333333333
|
|
|
|