Level places player?

I'm trying to set up a way for the rooms to have a variable that places the player in a start coordinate. So I have this in the room script:

on enter do
start_pos_x = 7
start_pos_y = 10
end

then in player script:

on emter do
goto event.player_pos_x,event.player_pos_y
end

What am I doing wrong?

Is emter (in the player script) a typo in your post or in your code?

1 Like

No, the typo is here, not in the code :slight_smile:

Hmm, player_pos_x and player_pos_y aren't properties of event.

1 Like

I'm sorry, what do you mean?

Those aren’t valid variables. That is effectively saying goto 0,0.

1 Like

How do I make them valid variables?

What I mean is those variables don’t exist. event contains a predefined, set of read-only variables. You can’t assign new ones to it. You probably meant something like goto start_pos_x,start_pos_y.

But in your specific example I would probably just tell the player where to go from the room’s enter handler like so:

on enter do
    goto 7,10
end
1 Like

Oh man! That is so much simpler! I didn't know you could do that. I thought everything that affects the player had to be in the player script! Sorry, I'm new to this (second day). :frowning: Thank you!!!

1 Like

I’ve updated my answer. I completely forgot that goto always and only applies to the player so there’s no need to tell event.player here.