[solved] How can I edit the 'changedparent' script?

Yeah, it's a default script and want to edit it...


If you're using the desktop editor, I believe you can find it (along with all other attributes) on an object's "Attributes" tab. I wouldn't know more about that, as I'm on linux and can't run the desktop editor.

If you're using the web editor, you can't edit attributes directly, but you can set them in a script. For example, in your start script you could do:

some_object_name.changedparent => {
  // new script goes here
}

But that replaces the default script. Depending what you're doing, it might be a good idea to make sure you include some parts of the default changedparent script.
For reference, this is what the built-in changedparent script does:

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

Which breaks down as:

  • if (game.pov = this) { - if this object is currently the player
    • if (IsDefined("oldvalue")) { - if parent previously had a value
      • OnEnterRoom(oldvalue) - Run the room exit scripts for oldvalue, room enter scripts for the current room, and show the room description
    • else {
      • OnEnterRoom(null) - Run room enter scripts and show the room description
    • if (game.gridmap) { - if the map is enabled
      • MergePOVCoordinates - some stuff related to working out where the new room should be drawn on the map
  • this.hasbeenmoved = true - the only thing that matters for non-player objects; set a flag to say that the object has been moved

Depending what you're doing, it might be a good idea to make sure you include some parts of the default changedparent script.

Yes, that's bothering me. I want to keep the default script and make some additions.

I am using the desktop version for windows. I can see the attribute in the attributes tab, but can't edit it. Quest offers me to create an editable copy of the script but I am sure not what that means and what it does...


Creating an editable copy just means that the object has its own version, instead of using the one inherited from the defaultobject type. I think it should copy all the default code in there, so you can just add whatever you need to it.


additionally, to what mrangel said:

the main reason the GUI/Editor, forces you to 'copy', before you change anything, is to protect the default quest internal coding, so if you mess up on the coding, only your game is messed up (until it gets its messed up code fixed), instead of messing up the quest software/program/engine itself (requiring it to either be fixed, or to remove it and re-download and install it, but this can't happen if you use the GUI/Editor, due to it forcing you to 'copy', before you make any changes)

(you can go into the quest coding directly, via its various 'core' and/or 'english/whatever' library files in its folder, make changes to it, and change or mess up, quest)

(this is also a good way to learn some more advanced coding, go into the files and see how they're coded/done by ex creator Alex and co/team, and now by Pixie and whoever else helping/contributing with quest's internal/engine coding/updating/patches)


Thanks, creating a copy worked great. Just wanted to know what that was exactly...


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums