Need Help Creating Attribute for Status Window
![](https://i.imgur.com/Gj269XFb.png)
Summa_Civis
04 Sept 2023, 16:12I want to be able to assign a RANK: Trainee, Cadet, Officer, Corporal, ect. ect.. to my player at the beginning of the game. I don't understand how to navigate the status attribute interface and where to place the code. I've tried to follow along with some of the info in the forum, but only ran into problems.. Any help would be immensely appreciated.
![](https://i.imgur.com/SFWbOxsb.png)
ThatGoddess
05 Sept 2023, 11:22Go to your player object and navigate to the "Attributes" tab! There, add a new item in the Status Attributes list at the very top.
The first thing you enter is the key, aka which attribute the status will display. So if you enter a key of "rank" and your player.rank attribute is a string named "Trainee", it will grab that string.
The second half is the actual, displayed text that will be shown on the status pane. It'll display whatever you type, but substitute "!" with the key's string.
So, if your key is "rank", the player.rank attribute's string is "Trainee" and the key's value is "RANK: !", the status pane will display:
"RANK: Trainee"
And if you change the player.rank attribute to, say, "Cadet", Quest will automatically update the status to:
"RANK: Cadet"
![](https://i.imgur.com/Gj269XFb.png)
Summa_Civis
06 Sept 2023, 15:00This is helpful. Thanks!
How would I be able to set the rank attribute using an integer?
mrangel
06 Sept 2023, 19:08How would I be able to set the rank attribute using an integer?
For something like that, you'd normally have one attribute containing the integer, and one containing the string. So if you have an int called rank_number
, you could create a script attribute called changedrank_number
(which will be run every time the int changes), and make its code something like:
ranks = Split("Trainee;Cadet;Officer;Corporal;Sergeant;Lieutenant;Captain;Major;Colonel;Brigadier;Admiral")
if (this.rank_number < 0) {
this.rank_number = 0
}
else if (this.rank_number >= ListCount (ranks)) {
this.rank_number = ListCount (ranks) - 1
}
else {
this.rank = ListItem(ranks, this.rank_number)
}
In this case, it checks that the rank_number
isn't negative or too high before changing the rank
attribute to the appropriate rank name. (Note that when you make a list like this, the first rank on the list will correspond to rank_number 0)
Hope that helps.
![](https://i.imgur.com/Gj269XFb.png)
Summa_Civis
07 Sept 2023, 04:13This worked! Kudos mrangel!