menu at x,y,w,h then
option "One" then
goto 5,9 in "room1"
end
option "Two" then
if unlocked2==true then
goto 6,11 in "room2"
if unlocked2==false then
say "can't enter"
end
end
end
end
end
but it goes to room2 even if false.. i'm trying to make an unlock level thingy and manually changing unlocked2, any advise?
It's because there are no true and false in Pulp. Those are interpreted as variables, by default initialized with value 0. If unlocked2 is also 0, the first if checks true and the goto statement is executed. You're also missing an else or elseif for the second check. unlocked2 should have values of 0 (interpreted as false) or 1 (as true). Your second part of the code should look something like this:
option "Two" then
if unlocked2==1 then
goto 6,11 in "room2"
else
say "can't enter"
end
end
You need to store the variables. In your case, when you enter room2, you can have this code:
on enter do
unlocked2 = 1
store "unlocked2"
end
Of course, if you have more rooms, you want to extend this. So my suggestion is something like this, in each room's enter:
on enter do
currentRoom = 5 //change this number to the room index
if unlockedRooms < currentRoom then
unlockedRooms = currentRoom
store "unlockedRooms"
end
end
Then, in the game's load event you just have to call restore so that your variables are set to whatever was previously stored on disk:
on load do
restore
end
In the menu you'll need to have options for all the rooms in the game. Although I suggest having a different method, especially if you have lots of rooms, but I'll leave that to your imagination. If you use the menu options, you'll need something like this:
option "Five" then
if unlockedRooms >= 5 then
goto 6,11 in "room5"
else
say "can't enter"
end
end
ok great! Ill look into all this. I have on cancel restart = 1
store "restart"
wait 0 then
fin "Restart" if that makes any difference. Yes im trying to think instead of a main room maybe on confirm load levels..will keep looking at it thanks again
hmm it didnt seem to work on device. do i have to have: restore "unlocked2" or just the word restore? I set up just room2 to test, does it only unlock after i exit room2 fully (which i didnt test yet)?!
Using just restore means you restore every variable you've saved. If you use restore "unlocked2" it restores only the variable unlocked2.
Regarding why it's not saved to disk, this is from the docs: Persistent storage is written to disk between the exit and enter events when changing rooms or when the Player reaches an ending.
So it means you need to exit a room to flush the stored data to disk. In my game, I set the unlockedRooms in the collect event of an item I pick up on the room exit - it's placed on the same location as the exit. currentRoom is set in the enter event of the room, then the code for the item is this:
on collect do
if unlockedRooms < currentRoom then
unlockedRooms = currentRoom
store "unlockedRooms"
end
end