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:
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.