Status attribute string script. Gaaaaaaaah.

CheeseMyBaby
10 May 2018, 07:48I have a status attribute called "Encumbrance" which is supposed to return different strings depending on how encumbered the player is.
Everything is set up and working except for that last part. I've been trying to do it with an IF script but I'm not sure how to specify that the string returned depending on the state is really the !
value of the status attribute.
Wow. I really did not explain that too well, did I?
mrangel
10 May 2018, 08:43Not sure I'm understanding you right. You mean you have an attribute called 'encumberance' but you want to display a string based on the number, rather than the number itself?
If so, here's the way I'd do it:
player.changedencumberance => {
if (this.encumberance = 0) {
this.encumber_string = "You're not carrying anything"
}
else if (this.encumberance < 20) {
this.encumber_string = "You have some stuff in your pockets"
}
else if (this.encumberance < 60) {
this.encumber_string = "Your pockets are full"
}
else if (this.encumberance < 90) {
this.encumber_string = "You are struggling under the weight of your stuff"
}
else {
this.encumber_string = "You are carrying way too much"
}
}
And then the actual status attribute is the string.
Or maybe I'm misunderstanding?

CheeseMyBaby
10 May 2018, 09:21Yeah, I really didn't explain it too well.
I have a status attribute called encumb
It displays as ENCUMBRANCE: !
Every item the player can carry has a weight
attribute which adds up to the player.weight
attribute.
I want the status attribute to display this:
ENCUMBRANCE: none
ENCUMBRANCE: <font color=yellow>light</font>
ENCUMBRANCE: <font color=orange>medium</font>
(or something like that)
... based on the value of player.weight
So if player.weight
is less than, say 20 kilos, it displays "none".
If player.weight
is around 30 kilos, it displays "light"
and so on.
Edit:
In other words.
I want the !
to switch between none
, light
, medium
depending on the value currently stored in player.weight
(maybe that's what I should've asked for to start with =))

CheeseMyBaby
10 May 2018, 09:51I took your code (above) and tried to alter it to the situation.
It's not working (the status attribute displays nothing).
However, it's not throwing any errors so I guess I'm not that far off?
This is what I changed it to:
player.changedweight => {
if (player.weight < 30) {
this.encumb_string = "none"
}
else if (this.encumb < 50) {
this.encumb_string = "low"
}
else if (this.encumb < 70) {
this.encumb_string = "moderate"
}
else if (this.encumb < 90) {
this.encumb_string = "high"
}
else {
this.encumb_string = "extreme"
}
}
hegemonkhan
10 May 2018, 10:21here's a step by step guide demo game that you create and can play/study on using the built-in 'statusattributes' String Dictionary:
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375
(it's a really old version of quest, so probably won't work with current version, but you can try it, if not, let me know, and I'll help you with using statusattributes, if you can't understand them from my code)
you would do this, as your String Attribute is 'encumb', as-which you want the 'statusattribute' to display:
player.encumb = "unknown"
player.weight = 0
player.changedweight => {
if (this.weight < 30) {
this.encumb = "none"
}
else if (this.weight < 50) {
this.encumb = "low"
}
else if (this.weight < 70) {
this.encumb = "moderate"
}
else if (this.weight < 90) {
this.encumb = "high"
}
else {
this.encumb = "extreme"
}
}
player.statusattributes = NewStringDictionary ()
list add (player.statusattributes, "encumb", "ENCUMBRANCE: " + !)
// or (I don't know how to do the syntax for it the '!' usage):
// list add (player.statusattributes, "encumb", "ENCUMBRANCE: !")
// let me know if neither of these syntaxes work... and I'll try to figure out what's the correct syntax for it to work, lol
it should look like this:
<object name="player">
<attr name="weight" type="int">0</attr>
<attr name="encumb" type="string">unknown</attr>
<attr name="changedweight" type="script">
if (this.weight < 30) {
this.encumb = "none"
}
else if (this.weight < 50) {
this.encumb = "low"
}
else if (this.weight < 70) {
this.encumb = "moderate"
}
else if (this.weight < 90) {
this.encumb = "high"
}
else {
this.encumb = "extreme"
}
</attr>
<statusattributes type="stringdictionary">
<item>
<key>encumb</key>
<value>ENCUMBRANCE: !</value>
</item>
</statusattributes>
</object>
as for the color formatting... you'll probably have to do that within the 'changedweight' Script Attribute, setting the 'encumb' String Attribute's Value to having the color formatting in it... but I'm not sure... maybe you'll have to do the color formatting within the 'statusattributes' String Dictionary's 'encumb' key's Value
others (like KV, Mrangel, Pixie) can help you with the color formatting, as I've not used it yet, and so don't know how to do it very well myself
hegemonkhan
10 May 2018, 10:30if you want a min-max weight limit/range (using 0-100 for the example):
<object name="player">
<attr name="weight" type="int">0</attr>
<attr name="encumb" type="string">unknown</attr>
<attr name="changedweight" type="script">
if (this.weight < 0) {
this.weight = 0
}
else if (this.weight > 100) {
this.weight = 100
}
if (this.weight < 30) {
this.encumb = "none"
}
else if (this.weight < 50) {
this.encumb = "low"
}
else if (this.weight < 70) {
this.encumb = "moderate"
}
else if (this.weight < 90) {
this.encumb = "high"
}
else {
this.encumb = "extreme"
}
</attr>
<statusattributes type="stringdictionary">
<item>
<key>encumb</key>
<value>ENCUMBRANCE: !</value>
</item>
</statusattributes>
</object>

CheeseMyBaby
10 May 2018, 13:36
player.weight = 0
player.changedweight => {
if (this.weight < 30) {
this.encumb = "none"
}
else if (this.weight < 50) {
this.encumb = "low"
}
else if (this.weight < 70) {
this.encumb = "moderate"
}
else if (this.weight < 90) {
this.encumb = "high"
}
else {
this.encumb = "extreme"
}
}
This did the trick!
(and the colour formatting won't be a problem)
Thanks guys!!!