About "Level_load" ??

Posted By: AMIR_REZAs

About "Level_load" ?? - 04/30/12 18:36

Hello

I try to load my second level by "level_load"
my code:

Code:
function Golevel(){
			level_load("2.wmb"); 
}

action player_action()
{
	while(1)
	{
		if(score <= 0){
			
			set(last_txt,SHOW);
			media_stop(f_m);
media_play("robot 7.wav",NULL,170);			
			wait(-3); 
Golevel();   
			
			
			} 

		wait(1);
	}
}




but it crashed in "player_action" code ....How can I solve this problem?

thanks.
Posted By: Ch40zzC0d3r

Re: About "Level_load" ?? - 04/30/12 18:43

You are using a while(1).
It will never end and when you delete the ent via level_load there is an empty pointer.
Try while(me)
Posted By: WretchedSid

Re: About "Level_load" ?? - 04/30/12 19:24

You could make the code more readable by promoting the condition up into the while loop:

Code:
action player_action()
{
	while(score > 0)
		wait(1);


	set(last_txt,SHOW);

	media_stop(f_m);
	media_play("robot 7.wav",NULL,170);	

	wait(-3); 
	Golevel();
}



(For code readability your goal should always be to nest as narrowly as possible)
Posted By: AMIR_REZAs

Re: About "Level_load" ?? - 05/01/12 09:56

I tested while(me) but it didn't work.... confused

Posted By: AMIR_REZAs

Re: About "Level_load" ?? - 05/01/12 10:45

Crashing has been solved but I want to kill all my level1 scripts after that.
And import my new scripts and level?

thanks
Posted By: AMIR_REZAs

Re: About "Level_load" ?? - 05/02/12 09:47

plz help me...
Posted By: Widi

Re: About "Level_load" ?? - 05/02/12 15:33

You don`t can "kill" your script and load a new one if you change the level. You have to do all in one script.
© 2024 lite-C Forums