GetBoolean within Get Input [Canceled]

Inside my game, I have a character who can upgrade your weapons for you. But I want it set so that they can only upgrade a certain type of weapon. The weapons which have this have a boolean attribute called electric, which defines the weapon as a special sort that the character can upgrade. But when i try it it throws this at me :

Error running script: Error compiling expression 'GetBoolean (result.electric)': Variable does not refer to an object: 'result'

if (player.money >44) {
  msg ("Alright. Tell me what you want upgraded and if I can do it I will. 45 dogebles per upgrade.")
  get input {
    if (GetBoolean (result.electric)) {
      result.dmg = result.dmg +25
      result.stockalias = result.stockalias + "upgraded"
      msg ("Alright. Your weapon has been upgraded. +25 dmg -45 dogebles")
      player.money = player.money -45
    }
    else {
      msg ("Sorry. That's not a weapon I can upgrade.")
    }
  }
}
else {
  msg ("Afraid you can't afford it.")
}

This is the code I have. It checks of the player has enough money, then gets input, but at the if script it checks if the weapon has the attribute which allows this character to upgrade it, and commences the script to upgrade the thing. Is there any way to make this error go away or will i have to use a switch script with all the weapons i want to be upgradeable?

EDIT : I CAN'T GET IT TO WORK PROPERLY. MAYBE I'M AN IDIOT, MAYBE IT DOESN'T WORK, EITHER WAY I'M REMOVING THE FEATURE.


result has a string value, but you want an object value to work with attributes.

If the object's alias (which the player must type in exactly) is identical to the object's name (also a string), you can use

obj = GetObject(result)
if (GetBoolean (obj.electric)) { // etc., etc.

Alternatively, you could use a menu to limit the player to valid choices only (e.g.,ScopeInventory()). The menu would use either an object list, or a string list of object aliases that you would use obj = GetObject(result) on.


well thing is, all of the objects have different names than the aliases, so I can't do that. On the other hand I really am not good with messing with Scope scripts and object lists. Oh well. Considering the length of the game I doubt anyone will reach it by the time I figure out a solution and push out some sort of hotfix.


Rather than using get input, wouldn't it be more practical to ask the player to choose from a list of weapons?

If you really want the player to type in the name of the weapon, you'd need to use GetObject(result) to get the actual object.

If you want the player to type in the alias of the weapon, you'd need to do something like:

  get input {
    result = Trim (LCase (result))
    result_handler => {
      result = GetObject (result)
      if (GetBoolean (result, "electric")) {
        result.dmg = result.dmg +25
        result.stockalias = result.stockalias + "upgraded"
        msg ("Alright. Your weapon has been upgraded. +25 dmg -45 dogebles")
        player.money = player.money - 45
      }
      else {
        msg ("Sorry. That's not a weapon I can upgrade.")
      }
    }
    fullmatches = NewObjectList()
    partialmatches = NewObjectList()
    foreach (weapon, ScopeInventory()) {
      CompareNames (LCase (GetDisplayName (weapon)), result, weapon, fullmatches, partialmatches)
      if (not weapon.alt = null) {
        foreach (altname, weapon.alt) {
          CompareNames (LCase (altname), result, weapon, fullmatches, partialmatches)
        }
      }
    }
    if (ListCount (fullmatches) = 1) {
      invoke (result_handler, QuickParams ("result", ListItem (fullmatches, 0)))
    }
    else if (ListCount (fullmatches) = 0 and ListCount (partialmatches) = 1) {
      invoke (result_handler, QuickParams ("result", ListItem (partialmatches, 0)))
    }
    else if (ListCount (fullmatches) + ListCount (partialmatches) = 0) {
      msg ("I don't have a '"+result+"'.")
    }
    else {
      ShowMenu ("Which weapon did you mean?", ListCompact (ListCombine (fullmatches, partialmatches)), true, result_handler)
    }
  }

get input {

  string_variable = result

  object_variable = GetObject (string_variable)

  if (object_variable = null) {

    foreach (obj, AllObjects ()) {

      if (obj.alias = string_variable) {

        object_variable = obj

      }

    }

  }

  if (object_variable = null) {

    msg ("Error: wrong input (inputted object doesn't exist)")

  } else {

    // whatever scripting  you want for your 'object_variable'

  }

}

So i've tried most of these responses, but i can't seem to get them to work quite right. Therefore, I will just omit this feature from the game.


You can change the names of your objects so that they match their aliases. Only difficulty would be if the aliases change in-game.


they do. and that would break a lot of stuff like the ammo system


just add an attribute to each weapon for what ammo it uses, that should not change through the game.


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

Support

Forums