What is wrong with this code (Making cloned NPC's Follow)

I'm trying to set up a follower function for generic npcs(Essentially randomized clones) and not sure why its not working.. Here is the logic/code

I've set up an attribute on the player.previousroom that logs where the player last stepped
//on speaking to npc

SetObjectFlagOn (this, "Following") 

//and a move generic npcs turnscript

foreach (obj, ScopeReachableForRoom(player.previousroom)) {
  if (GetBoolean(obj, "Following")) {
    SetTimeout (1) {
      MoveObject (obj, player.parent)
    }
  }
} 

I would guess the issue is that the local variable, obj, does not exist inside the SetTimeout block. It may work better if you put the whole lot inside the SetTimeout block:

SetTimeout (1) {
  foreach (obj, ScopeReachableForRoom(player.previousroom)) {
    if (GetBoolean(obj, "Following")) {
      MoveObject (obj, player.parent)
    }
  }
} 

Log in to post a reply.

Support

Forums