How to hide and show status attributes in the middle of the game?

Like the title says, I wanna know how to hide or show statuses using scripts, either by entering a room or picking up an object.


status attributes are stored in one of three possible dictionaries:

  • game.pov.statusattributes - status attributes which are attributes of the specific player object (so will disappear if the player takes control of a different character). These are edited on the 'Attributes' tab of the player object.
  • game.povstatusattributes - attributes of the player, regardless of what object the player is (the health and money features use this one; it is edited on the "Player" tab of the game)
  • game.statusattributes - attributes of the game object (the score feature uses this. It is edited on the 'Attributes' tab of the game object)

So, if you've just found some object that allows you to use magic, you might want to give the player some magic points. You could use a script like:

dictionary add (game.pov.statusattributes, "mp", "Magic Points: !")

This is assuming that you have already added the mp attribute itself, for example by doing:

game.pov.mp = 90

In thar example, mp is the attribute name that you use in your code to refer to the attribute, and Magic Points: ! is a format, the text that will be shown in the Status Attributes pane. Within that format, a ! will be replaced by the current value.

To remove a status attribute again, you would use a line like:

dictionary remove (game.pov.statusattributes, "mp", "Magic Points: !")

It might also be better to check if the status attributes dictionary exists, so that it won't cause an error if this is the first status attribute the player has. And check if they have that attribute, so it doesn't cause a bug if they do the event twice. So you would add an attribute by using:

if (not HasAttribute (game.pov, "statusattributes")) {
  game.pov.statusattributes = NewStringDictionary()
}
if (not DictionaryContains (game.pov.statusattributes, "mp")) {
  dictionary add (game.pov.statusattributes, "mp", "Magic Points: !")
}

and remove it using:

if (HasAttribute (game.pov, "statusattributes")) {
  if (DictionaryContains (game.pov.statusattributes, "mp")) {
    dictionary remove (game.pov.statusattributes, "mp")
  }
}

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

Support

Forums