Question about editing the changedparent script

I remember from when I had access to the desktop version of Quest there was a built-in changedparent attribute on the player object. Just want to ask what the built-in script is because I want to overwrite it (if it's even possible in the web editor).
If I remember correctly every object had the same changedparent script, but I am not sure if there is more to the player object.


If I remember correctly every object had the same changedparent script, but I am not sure if there is more to the player object.

Every object has the same changedparent script, which is inherited from the defaultobject type. For most objects this is irrelevant; it's only there in case they become the player.

The default script is:

      if (game.pov = this) {
        if (IsDefined("oldvalue")) {
          OnEnterRoom(oldvalue)
        }
        else {
          OnEnterRoom(null)
        }
        if (game.gridmap) {
          MergePOVCoordinates
        }
      }
      this.hasbeenmoved = true

I want to overwrite it (if it's even possible in the web editor).

You can't directly override attributes in the web editor; the nearest you can get is giving the object an initialisation script something like:

this.changedparent => {
  // whatever you want the script to be goes here
}

Note that if you are including a new changedparent for an object that the player might control, you need to make sure you're not missing out any of the important bits. In particular, MergePOVCoordinates must be run whenever the player moves in order for the map to work correctly; and OnEnterRoom is responsible for most of the stuff that happens when the player moves to another room, including showing the description, clearing the screen between rooms (if enabled), and checking whether it needs to run any room enter/exit scripts.


Note that if you are including a new changedparent for an object that the player might control, you need to make sure you're not missing out any of the important bits. In particular, MergePOVCoordinates must be run whenever the player moves in order for the map to work correctly; and OnEnterRoom is responsible for most of the stuff that happens when the player moves to another room, including showing the description, clearing the screen between rooms (if enabled), and checking whether it needs to run any room enter/exit scripts.

Thanks, that's quite important to know.


Log in to post a reply.

Support

Forums