Toggling Health/Score/Etc. On/Off

Shadecerule
09 Sept 2018, 08:23

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.


The Pixie
09 Sept 2018, 08:41

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", "")

Shadecerule
09 Sept 2018, 08:47

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


mrangel
09 Sept 2018, 09:21

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.


Shadecerule
09 Sept 2018, 10:34

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.