Question: How Do I Reset Attributes?

How can I revert an action to a previous setting? Say for example I set "player.attribute + 3" after a player selects an option. But then when asked to confirm if it is correct, the player selects "No." Well, instead of revert to the original setting of the attribute, the "player.attribute + 3" remains, changing the attribute to "+6" after running the menu option again. I hope that this is making sense. Thank you in advance!


The obvious answer here is to not add the +3 to the attribute until after they have confirmed it. If they select "no" then just don't do anything to the attribute so it remains as it was.


I'm still a novice when it comes to navigating this framework. What is wrong with this code? Why will it add an object to the player but if the player decides to change character, the item doesn't go away. Subsequently, selecting another player will add another item into the player's possession.

charactermenu = NewStringList()
list add (charactermenu, "Body Builder")
list add (charactermenu, "Dark Magician")
list add (charactermenu, "Ex Military")
list add (charactermenu, "Engine Mechanic")
list add (charactermenu, "Fashioneer")
list add (charactermenu, "High School Athlete")
list add (charactermenu, "Medical Student")
list add (charactermenu, "Mystic")
list add (charactermenu, "Pick Pocket")
list add (charactermenu, "Private Detective")
list add (charactermenu, "Street Savy")
list add (charactermenu, "Tech Nerd")
ShowMenu ("Please select a character class", charactermenu, false) {
  msg ("You selected " +result+".")
  Ask ("Is this the correct character type: " +result+"?") {
    if (result = True) {
      ClearScreen
      msg ("You are now  " +player.class+".")
      msg ("Press any key to continue.")
      wait {
        MoveObject (player, Stats)
      }
    }
    else if (result = False) {
      msg ("Let's try again.")
      CharacterSelect
    }
  }
  player.class = result
  switch (result) {
    case ("Body Builder") {
      iron knuckle gloves.parent = player
    }
    case ("Dark Magician") {
      small knife.parent = player
    }
    case ("Ex Military") {
      small knife.parent = player
    }
    case ("Engine Mechanic") {
      walking cane.parent = player
    }
    case ("Fashioneer") {
      small knife.parent = player
    }
    case ("High School Athlete") {
       tactical club.parent = player
    }
    case ("Medical Student") {
      walking cane.parent = player
    }
    case ("Mystic") {
      combat staff.parent = player
    }
    case ("Pick Pocket") {
      small knife.parent = player
     }
     case ("Private Detective") {
      walking cane.parent = player
    }
    case ("Street Savy") {
      hand gun.parent = player
    }
     case ("Tech Nerd") {
       screwdriver.parent = player
    }
     default {
      MoveObject (player, Stats)
    }
  }
}

The problem is with the control flow around the Ask statement.

The general structure is:

Ask ("Some question?") {
  // This code will be saved until later
  // to be run when the question is answered
}
// This code will be run immediately after displaying the question.

So I suspect that what you want is:

charactermenu = NewStringList()
list add (charactermenu, "Body Builder")
list add (charactermenu, "Dark Magician")
list add (charactermenu, "Ex Military")
list add (charactermenu, "Engine Mechanic")
list add (charactermenu, "Fashioneer")
list add (charactermenu, "High School Athlete")
list add (charactermenu, "Medical Student")
list add (charactermenu, "Mystic")
list add (charactermenu, "Pick Pocket")
list add (charactermenu, "Private Detective")
list add (charactermenu, "Street Savy")
list add (charactermenu, "Tech Nerd")
ShowMenu ("Please select a character class", charactermenu, false) {
  msg ("You selected " +result+".")
  player.class = result
  Ask ("Is this the correct character type: " +result+"?") {
    if (result) {
      ClearScreen
      msg ("You are now  " +player.class+".")
      switch (player.class) {
        case ("Body Builder") {
          iron knuckle gloves.parent = player
        }
        case ("Dark Magician") {
          small knife.parent = player
        }
        case ("Ex Military") {
          small knife.parent = player
        }
        case ("Engine Mechanic") {
          walking cane.parent = player
        }
        case ("Fashioneer") {
          small knife.parent = player
        }
        case ("High School Athlete") {
           tactical club.parent = player
        }
        case ("Medical Student") {
          walking cane.parent = player
        }
        case ("Mystic") {
          combat staff.parent = player
        }
        case ("Pick Pocket") {
          small knife.parent = player
        }
        case ("Private Detective") {
          walking cane.parent = player
        }
        case ("Street Savy") {
          hand gun.parent = player
        }
        case ("Tech Nerd") {
           screwdriver.parent = player
        }
        default {
          MoveObject (player, Stats)
        }
      }
      msg ("Press any key to continue.")
      wait {
        MoveObject (player, Stats)
      }
    }
    else {
      msg ("Let's try again.")
      CharacterSelect
    }
  }
}

Thank you for the reply mrangel. Once I added the new code into Quest, it seems like now it is not assigning the "result" after the player confirms the selection. No items or class assignments are being transferred to the player object.


Sorry, that was me being careless. Once you've done the Ask, it sets result to true. So you'd need to change switch (result) { to switch (player.class) {.
I edited the script in my post above.


Success! Thank you mrangel. I struggle with this thing for hours, mainly because I've never had the anyone walk me through some of this stuff that might seem obvious for a person with a background in programming. The forum has been huge in terms working through the places I get stuck. Thanks for your help!


(when it comes to "resetting" an attribute, there's one more thing it might be worth mentioning; though it's probably not useful in this case. If you set an attribute to null, that will reset it to its last inherited value. For many of the attributes which have to be enabled on the "Features" tab, this will reset them to their default value. This is rarely useful; but I thought I should mention it because if someone wants to do that, this topic will probably come up in their search results)


(I'll use a hypothetical language, but the logic is similar across different languages)

Your hypothetical language is clearly Python written pretty badly. And the method you give is only suitable for languages which have a blocking input method, which Quest doesn't.

If you're on a forum for a particular engine, try giving answers that actually work with that engine.

(in this case, increases it by 3).

Hey, spambot, why is the comma in that line an obfuscated link?


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

Support

Forums