Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,361 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Load level from string1 #248113
01/24/09 16:23
01/24/09 16:23
Joined: Nov 2008
Posts: 50
S
Secret_V Offline OP
Junior Member
Secret_V  Offline OP
Junior Member
S

Joined: Nov 2008
Posts: 50
I'm creating an RPG, so I need a lot of doors and teleports to other levels in my game world. Now, I don't want to use another action/function for every single door, so I want to load the level from the string1, which is manually set in WED. But I can't seem to get this working. This is my code up till now:

Code:
action door()
{
	set(my, POLYGON);
	my.emask |= ENABLE_CLICK;
	my.event = door_open;
}

function door_open()
{
	var door_percentage;
	if((event_type == EVENT_CLICK) && (vec_dist(player, my) <= 100))
	{
		while(door_percentage < 100)
		{
			ent_animate(my, "open", door_percentage, 0);
			door_percentage += 3 * time_step;
			wait(1);
		}
		level_load(my.string1);
		in_building = 1;
	}
}


I tried different contexts for string1, like:
"player_house.wmb"
player_house.wmb
But it loads an empty level each time.

Can anyone tell me what's the matter with my code? Cause I don't feel like using a different action for every door I use.

Re: Load level from string1 [Re: Secret_V] #248115
01/24/09 16:38
01/24/09 16:38
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
You haven't set the string.

Re: Load level from string1 [Re: Cowabanga] #248117
01/24/09 17:03
01/24/09 17:03
Joined: Nov 2008
Posts: 50
S
Secret_V Offline OP
Junior Member
Secret_V  Offline OP
Junior Member
S

Joined: Nov 2008
Posts: 50
What do you mean? What should I change or add then? Cause my.string1 is a string itself, right?

Re: Load level from string1 [Re: Secret_V] #248119
01/24/09 17:18
01/24/09 17:18
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
i think the level_load command destroys first the level (and your string1 too) and then loads the level. But at this time your string1 is = NULL so the engine loads an empty level.
Try this:

STRING* dummy = "#32";

...

str_cpy(dummy,my.string1);
level_load(dummy);


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Load level from string1 [Re: WretchedSid] #248128
01/24/09 18:04
01/24/09 18:04
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
uhm is you mouse activated + mouse_range?

does it work if you replace my.string1 true the normal name of the lvl "lvl.wmb"


"empty"
Re: Load level from string1 [Re: flits] #248132
01/24/09 19:00
01/24/09 19:00
Joined: Nov 2008
Posts: 50
S
Secret_V Offline OP
Junior Member
Secret_V  Offline OP
Junior Member
S

Joined: Nov 2008
Posts: 50
Well, I changed things to:

Code:
STRING* load_level = "#32";

action door()
{
	set(my, POLYGON);
	load_level = my.string1;
	my.emask |= ENABLE_CLICK;
	my.event = door_open;
}

function door_open()
{
	var door_percentage;
	if((event_type == EVENT_CLICK) && (vec_dist(player, my) <= 100))
	{
		while(door_percentage < 100)
		{
			ent_animate(my, "open", door_percentage, 0);
			door_percentage += 3 * time_step;
			wait(1);
		}
		in_building = 1;
		str_cpy(load_level, my.string1);
		if(door_percentage >= 100) level_load(load_level);
	}
}


But now I get the error message:

Error E1515

Invalid arguments in door_open

And then it loads an empty level.

My mouse is activated and I've set the mouse_range.

Yes, my level loads when I replace my.string1 with the real level name.

Re: Load level from string1 [Re: Secret_V] #248190
01/25/09 06:53
01/25/09 06:53
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
First of all you should put the level_load command into an own function that starts with

Code:
my=NULL;


to be sure that this function is still running after the level_load commnand has been executed, because you should add at least a

Code:
wait(1);


after the level_load();

Try something like that (I have not tested this code):

Code:
action door()
{
	set(my, POLYGON);
	my.emask |= ENABLE_CLICK;
	my.event = door_open;
}

void load_new_level(STRING* level_name)
{
	my = NULL;	
	level_load(level_name);
	wait(1);
}

function door_open()
{
	var door_percentage;
	if((event_type == EVENT_CLICK) && (vec_dist(player, my) <= 100))
	{
		while(door_percentage < 100)
		{
			ent_animate(my, "open", door_percentage, 0);
			door_percentage += 3 * time_step;
			wait(1);
		}
		in_building = 1;		
		if(door_percentage >= 100) load_new_level(str_create(my.string1));
	}
}


Regards,
Pegamode.

Re: Load level from string1 [Re: pegamode] #248214
01/25/09 13:11
01/25/09 13:11
Joined: Nov 2008
Posts: 50
S
Secret_V Offline OP
Junior Member
Secret_V  Offline OP
Junior Member
S

Joined: Nov 2008
Posts: 50
Great, your codes works perfectly! Thank you very much. smile

Secret V

Re: Load level from string1 [Re: Secret_V] #248236
01/25/09 15:27
01/25/09 15:27
Joined: Nov 2008
Posts: 50
S
Secret_V Offline OP
Junior Member
Secret_V  Offline OP
Junior Member
S

Joined: Nov 2008
Posts: 50
(Sorry for double posting)

Well, it works, but now something strange is happening... In the first map I used them everything works fine. But now, I loaded my door model into another map and attached it the same door action, but changed the string1 of course. But no matter how many times I click the door, nothing happens. The door doesn't even show it's "Open" animation, it doesn't do anything. When I attach another action to the model, the action works. But this particular action doesn't, any ideas?

Re: Load level from string1 [Re: Secret_V] #248253
01/25/09 16:40
01/25/09 16:40
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Since you changed level you probably have to re-activiate
the door with
set(my, POLYGON);
my.emask |= ENABLE_CLICK;
my.event = door_open;

place these lines in a function and after loadint the new level
call the function.

Ottawa smile

Page 1 of 2 1 2

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

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