Object Children in Inventory

Don't know if this was ever solved. I have seen several references to this issue but could not find an answer, as the subject changed in the thread or just went unanswered.

If you have a sword and make a child object such as hilt, so player can interact with it, it will show the hilt object in the inventory pane. You can hide it till looked at but then your stuck with it.

I added to the changedparent of the sword.

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

Then added to the changedparent script of the sword.

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

Now it can be interacted with as usual. At least I haven't found any issues/bugs.

The hilt starts as an object in the same room as sword as scenery. It follows the sword, staying in the parent room of the player if the sword is carried with them. If dropped it will stay with the sword parent.

This is probably simple for talented coders and may be "sloppy" (I couldn't tell the difference) but it works. Took me an entire day of searching to figure it out.

Please let me know if there is an improvement to be made.


Log in to post a reply.

Support

Forums