I was recently asked to help with a simple save system using save points, and I figured it would make a nice little how-to here on the forum.
Goal
- The game starts on a title screen
- On the title screen the player can select "New Game" or, if save data exists, "Continue"
- Selecting "Continue" will start the player at their last saved location
- "Save point" items will automatically save when walked over
- "Computer" sprites will offer the choice of "Save" or "Quit" when interacted with
- Pressing "B" will restart the game (for easier testing)
Example project
Save Point Demo.zip (2.6 KB)
Code
player script
on draw do
if event.room=="title" then
hide
end
end
on cancel do
fin "Restarting game... " at 2,12,19,1
end
title room script
on enter do
restore "continue_room"
menu at 7,10 then
if continue_room!=0 then
option "Continue" then
restore
goto continue_x,continue_y in continue_room
end
end
option "New Game" then
toss
goto 12,8 in "middle"
end
end
end
save point item script
on collect do
continue_room = event.room
continue_x = event.x
continue_y = event.y
store "continue_room"
store "continue_x"
store "continue_y"
store
say "Game saved!" at 6,12,11,1
end
computer sprite script
on interact do
menu at 9,11,4,2 then
option "Save" then
continue_room = event.room
continue_x = event.px
continue_y = event.py
store "continue_room"
store "continue_x"
store "continue_y"
store
say "Game saved!" at 6,12,11,1
end
option "Quit" then
tell event.player to
call "cancel"
end
end
end
end
Maybe this will be of help to someone else!