Toggling Health/Score/Etc. On/Off

Is there a way to toggle the items in the "Features" tab (under the "game" object) on and off during gameplay? Setting game.showhealth to false does not seem to work.


Quest has two dictionaries that it uses to determine what to display, one for the player and one for he game. Health is on the player, so you would need to remove it from the dictionary:

DictionaryRemove (player.statusattributes, "Health")

To add it back:

DictionaryAdd (player.statusattributes, "Health", "")

Hmm... When I try to use those functions, I'm told they don't exist when I boot up the game.


I think those functions are new in the latest version of Quest.

They look like:

  <function name="DictionaryAdd" parameters="dict, key, val">
    if (dict = null or TypeOf(dict)="object") {
      error ("DictionaryAdd:  Dictionary does not exist!")
    }
    if (DictionaryContains(dict, key)) {
      dictionary remove (dict, key)
    }
    dictionary add (dict, key, val)
  </function>

  <function name="DictionaryRemove" parameters="dict, key">
    if (dict = null or TypeOf(dict)="object") {
      error ("DictionaryAdd:  Dictionary does not exist!")
    }
    if (DictionaryContains(dict, key)) {
      dictionary remove (dict, key)
    }
  </function>

Or you could just use dictionary add, but that will cause an error if you try to turn an attribute off when it's already off, so you need to be more careful with it.


Oh, that's good to know. Thanks! That puts me one step closer.

However, when I try to use The Pixie's code, it tells me "Error running script: DictionaryAdd: Dictionary does not exist!" whether I use the add or remove function.


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

Support

Forums