How to get ShowMenu to run scripts based off selections

I would like selecting Security Alert from Show Menu to cause a drone object to be moved to the room they're in so it can start attacking them. I can worry about all the combat side of it later, I'm just trying to figure out the best way to move the drone object as I'm not sure how to make it so that if "Security Alert" is picked than move object. Any ideas?

ShowMenu ("What do you want to access on the computer?", options, true) {
  switch (result) {
    case ("Emails") {
      msg ("There are only three emails currently available whose subject lines include 'Unfriended', 'Trouble Brewing' and 'Damn Salvagers'.  Type READ and then the name of the email you would like to read.")
    }
    case ("Security Alert") {
      msg ("The words: DRONE RELEASED flashes across the screen.")
    }
    case ("ID List") {
      msg ("A list of names appears on the screen.  You can 'Ask Computer' about a person's name to see if they are on the ID List and what information security may have on them.")
    }
    case ("Security Manifest") {
      msg ("This seems to be a basic rulebook on how to provide effective security in the facility.  It's rather long.  You don't have the time to go through it right now.")
    }
    case ("Leave It Alone") {
      msg ("You leave the computer alone.")
    }
  }
}

(filler for getting my edited post, updated/posted, grr)


containment/parent-child hierarchy is controlled by the built-in 'parent' Object (reference/pointer) Attribute:

player.parent = room // the 'player' Player Object is within the 'room' Room Object
player.parent = room99 // the 'player' Player Object is now within the 'room99' Room Object

player.parent = room // the 'player' Player Object is now back within the 'room' Room Object
npc.parent = player.parent // the 'npc' Object is within the 'room' Room Object
player.parent = room99 // the 'player' Player Object is now back within the 'room99' Room Object
npc.parent = player.parent // the 'npc' Object is within the 'room99' Room Object


some many versions ago, quest added a feature for having multiple Player Objects (you can switch control amongst multiple Player Objects):

http://docs.textadventures.co.uk/quest/changing_the_player_object.html

game.pov = NAME_OF_CURRENTLY_CONTROLLING/USING_PLAYER_OBJECT

game.pov = player
game.pov = player99

// or, using the helper Script/Function:

ChangePov (player)
ChangePov (player99)


most people use the 'player' Player Object, but if you change the 'name' of it, and/or use multiple Player Objects, then it's useful/needed to use (the 'game.pov' can always be used, so that's why I'm using it in my code example at the bottom of this post):

game.pov

so, you can do this too (replace 'player' with 'game.pov'):

game.pov = HK // 'HK' is the currently controlled Player Object
game.pov.parent = room // 'HK' is within the 'room' Room Object
npc.parent = game.pov.parent // the 'npc' Object is within the 'room' Room Object
game.pov.parent = room99 / 'HK' is within the 'room99' Room Object
npc.parent = game.pov.parent // the 'npc' Object is within the 'room99' Room Object


there's three ways to move Objects via scripting:

  1. the built-in 'MoveObject' helper Script/Function (it's actually just doing #2 for you underneath):

MoveObject (NAME_OF_MOVING_OBJECT, NAME_OF_DESTINATION_OBJECT)

  1. the built-in 'parent' Object (reference/pointer) Attribute:

NAME_OF_MOVING_OBJECT.parent = NAME_OF_DESTINATION_OBJECT

  1. the built-in 'set' Script/Function (it's, the or doing-the, same thing as #2):

set (NAME_OF_MOVING_OBJECT, "parent", NAME_OF_DESTINATION_OBJECT)


I'm assuming you got a 'drone' Object (change my 'drone' to whatever you named your drone Object as):

quest IS upper-lower case sensitive, for an example:

'drone' is NOT the same as 'Drone'

ShowMenu ("What do you want to access on the computer?", options, true) {
  switch (result) {
    case ("Emails") {
      msg ("There are only three emails currently available whose subject lines include 'Unfriended', 'Trouble Brewing' and 'Damn Salvagers'.  Type READ and then the name of the email you would like to read.")
    }
    case ("Security Alert") {
      drone.parent = game.pov.parent // the 'drone' Object is (moved/set/re-set) within the same room as you are in
      msg ("The words: DRONE RELEASED flashes across the screen.")
    }
    case ("ID List") {
      msg ("A list of names appears on the screen.  You can 'Ask Computer' about a person's name to see if they are on the ID List and what information security may have on them.")
    }
    case ("Security Manifest") {
      msg ("This seems to be a basic rulebook on how to provide effective security in the facility.  It's rather long.  You don't have the time to go through it right now.")
    }
    case ("Leave It Alone") {
      msg ("You leave the computer alone.")
    }
  }
}

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

Support

Forums