How do I make my vehicle remember where I parked it?

Jump to: navigation, search

The Easy Way[edit]

Starting with the ubersetzung release you can go into the map editor and go into the general map data editor and configure your map to keep track of where all NPCs on the map are located. However, this data is not stored in your saved game, so you will probably still need to write a vehicle plotscript as described below.

The Hard Way[edit]

A vehicle is just a special NPC, and the locations of NPCs on a map are not recorded when you leave the map. However, when you make a vehicle, you usually want it to remember where you parked it when you leave the map and come back. What if you fly your airship out to a town on a remote island? When you are done in the town, the airship had better still be there, or you are stranded!

There is a way to do this, but it requires plotscripting *gasp! not plotscripting!*

The first thing you need to do is read the Plotscripting Tutorial, which will educate you about how to make a script, compile it, and get it into your game. Then you can come back and try out these sample scripts for saving and restoring your vehicle's location in global variables


global variable(1,used vehicle)
global variable(2,vehicle X)
global variable(3,vehicle Y)


plotscript,Map Autorun,begin
  if (used vehicle)
    # replace 0 with the NPC number of your vehicle
    set NPC position(0,vehicle X,vehicle Y)


plotscript,Dismount Vehicle,begin
  # replace the 0 with the NPC number of your vehicle
  vehicle X := NPC X(0)
  vehicle Y := NPC Y(0)
  used vehicle := true

After compiling and importing the script, you need to assign the first script as the map autorun script on the map where the vehicle is located (you do that in the Edit General Map Data menu) Then you need to assign the second script to the vehicle as it's dismount script

So, any time you dismount the vehicle, its location is written to the two variables vehicle X and vehicle Y, and any time you enter that map, it checks to see if the vehicle's location is saved already (thats what the used vehicle variable is for) and restores it