Creating a status attribute with a script

Hey, I'm a first-time poster and I'm trying to make a game that has quests and side quests. For a hidden side quest, I have items a player can collect, since they are hidden I thought it would be a good idea to have a status attribute that shows up once the player starts the quest to show how many are in the area, any ideas?


There are three places status attributes are stored. They are processed in order, so by deciding which dictionary to put them in, you can decide where in the list they appear.

The dictionaries are:

  1. game.statusattributes (these have their values stored in attributes of the game object - this includes score if the feature is enabled)
  2. game.povstatusattributes (these have their values stored in attributes of the current player object - this includes health and money if they are enabled)
  3. game.pov.statusattributes (these have their values stored in attributes of the current player object)

Note that for both of the last two, the attributes are attributes of the player object. The difference between them is that game.pov.statusattributes is also an attribute of the player object; so any changes you make to it will no longer be displayed if the player changes to controlling a different character.

So when you get the sidequest you could do something like:

// First, create the dictionary if it doesn't exist:
if (not HasAttribute (game, "povstatusattributes")) {
  game.povstatusattributes = NewStringDictionary()
}

// set the attribute to a sensible value:
game.pov.sidequestitems = 0

// And add it to the status attributes:
dictionary add (game.povstatusattributes, "sidequestitems", "Hidden items found: !/6")

Does that help?


Oh… when the sidequest is over, you can just do:

dictionary remove (game.povstatusattributes, "sidequestitems")

(not sure if you know that; some people seem to have trouble understanding dictionaries)


Ok, thank you, it works perfectly but how can I change the attribute when you get an item?


What I want is for the number to go up no matter the order you get the items in.


Edit: Never mind, disregard this post.


What I want is for the number to go up no matter the order you get the items in.

Just add to it. So like:

game.pov.sidequestitems = game.pov.sidequestitems + 1

each time you get one. Depending how the player gets them, you might want to put that in a firsttime block so that it only happens once for each item.

Or if you want to check how many of those objects are in the inventory at the same time, you'd have a turnscript to count them. Something like:

game.pov.sidequestitems = 0
foreach (itemname, Split("item1;item2;item3;item4;item5")) {
  if (Got (GetItem (itemname))) {
    game.pov.sidequestitems = game.pov.sidequestitems + 1
  }
}

I was able to figure out a way to make the number go up, thanks for the help!


Log in to post a reply.

Support

Forums