Plot:Save map state

From OHRRPGCE-Wiki

Jump to: navigation, search
save map state (whichdata, customid)

Saves the state of the current map to a temporary file which will be loaded (unless the map is set to ignore that particular data) when you reenter the current map, in the same way as a map set to save (remember) NPC or tile data: the saved state will be used instead of the map data in the RPG file. Both arguments are optional and are only for advanced uses.

Map state is not saved in saved games, and the temporary files will be deleted when you load or start a new a game!

whichdata is an or'd combination of the following constants, which specify exactly what you want to save:


  • mapstate:all = mapstate:mapsettings, or, mapstate:npcs, or, mapstate:tiles
  • mapstate:npcs = mapstate:npclocations, or, mapstate:npcdefinitions
  • mapstate:tiles = mapstate:tilemap, or, mapstate:passmap
  • mapstate:mapsettings
  • mapstate:npclocations
  • mapstate:npcdefinitions
  • mapstate:tilemap
  • mapstate:passmapThe default is mapstate:all.

If customid is passed, it is used to save the state in a separate state file with an id number of customid which can only be loaded with load map state. There are 32 available slots for use: 0 - 31.

Note that mapstate:mapsettings (also saved by mapstate:all) is special in that if you save it, it will always be loaded when the map is loaded regardless of settings. It saves all the settings found in the General Map Settings menu like the tileset, ambient music, footoffset, map trigger scripts, and so forth.

[edit] Examples

plotscript, generic menu screen, begin
  variable (remember map, remember x, remember y)
  remember map := current map
  remember x := hero x
  remember y := hero y
  # we want NPCs and things to stay in the same place after we come back from the menu
  save map state

  fade screen out
  wait
  teleport to map (map:generic menu)
  fade screen in
  wait

  # menu code here
  #...
  #...

  fade screen out
  wait
  teleport to map (remember map, remember x, remember y)
  # assume the map is set to load state only, the default (otherwise, use load map state)
  fade screen in
  wait

  # we want the map to go back to resetting whenever you enter/exit it (like normal)
  delete map state
end
Personal tools