Code sample - How to exclude an object from being listed when the command is GET/TAKE ALL

To exclude an object from TAKE/GET ALL

Created an attribute called 'not_all' for the object. (NOTE: You can use a Boolean and set it to "True" to maintain a professional appearance. You can also just leave it as an empty string. Either, way the code remains the same. (Thanks Pixie!))

Altered script for the command 'take':

anything_to_take = false
foreach (obj, object) {
  if (not HasAttribute(obj, "not_all")) {
    DoTake (obj, multiple)
    anything_to_take = true
    //this signals the presence of an object that is included in TAKE ALL
  }
}
if (not anything_to_take) {
  ///Meaning there is not an object that would be included in TAKE ALL present
  msg ("There is no all to take.")
}

And that's it!

If there is nothing to get, it will print, "There is no all to take."

Otherwise, it will take everything marked 'can be taken', printing each object's takemsg, just like it normally would.


awesome, thank you for posting this, will be of great help to a lot of people, we need a lot more public guides/libraries/codes for people to be able to use! As quest is such a good engine/software/program... but we've not made as many publically available guides/libraries/codes as we should have over the years.


Log in to post a reply.

Support

Forums