Strange issue with string attribute
JenniferKline
26 Jun 2017, 22:51Back again!
Trying out a clothing system that consists of upper and lower armour. If a player is wearing both an upper of light armour and a lower of light armour they get a matching set bonus. If they're wearing an upper of heavy and a lower of heavy, the same. If they've got no armour on upper or lower they get no bonus and are classed as 'nude'. Well, not nude, they have clothes, but you get what I mean.
Now, I made the string attributes:
player.upper
which is currently at"nothing"
to start at.
player.lower
which is currently at "nothing"
to start at.
player.clothed
which is currently at ""
to start at until it is given its value.
Then I have a turn script. I tried this with an attribute change script too, but had the same issue.
if (player.upper = "nothing") {
if (player.lower = "nothing") {
player.clothed = nude
}
}
I'm using if object attribute equals
and set variable or attribute
. I also tried the set an object 's attribute (named by an expression)
and had no dice.
if (player.lower = "nothing") {
player.clothed = nude
}
}
Which doesn't look right. Weird, because I'm sure these things should work, they worked fine for me altering attributes in the past, but I don't think I've really tried to use the whole if object attribute equals
before.
To add, my test function is a command that I use to debug and give me current stats.
SetInc (150)
msg ("{player.plevel}")
msg ("{player.purity}")
msg ("{player.clothed}")
msg ("{player.upper}")
msg ("{player.lower}")
I'm told my lower and upper is "nothing"
so I probably need to remove the quotation marks there, but my player.clothed
value just returns ""
Any help would be appreciated, pretty sure I'm missing something simple but it's really annoying. Turn script is set to be on when the game begins, too.
JenniferKline
26 Jun 2017, 23:02Hmmh, I appear to have fixed it by removing the "
nothing"
. Perhaps the quotation marks I thought had to be there to let the game know it wasn't something (I forget) confused it when placed into a String attribute then needing to be called on in scripts?
hegemonkhan
27 Jun 2017, 00:28Data Types must match up and when doing scripting of Attributes, quest parses its Value to determine the Attribute Type (if you already set the Atttribute's Type through the GUI/Editor, then your Value must match up with it.
any thing in double quotes is a String Value
any non-decimal number is an Integer Value
any decimal number is a Double Value
any thing that is not in double quotes and is not a number and is not a special/reserved word, is an Object (reference/pointer) Value
'true' and 'false' are reserved-as Boolean Values
'this' is a special Value that GETS the parent Object
a String Attribute holds String Values, example:
player.strength_string_attribute = "100" // even numbers become String values, when encased in double quotes
game.greeting = "hi"
player.right_hand_string_attribute = "sword" // notice the double quotes on 'sword'
a Object Attribute holds Object (reference/pointer: name_of_object) Values, example:
player.right_hand_object_attribute = sword // NO double quotes on the 'sword'
// there has to actually be a 'sword' Object too (or else an ERROR):
<object name="sword">
</object>
a Boolean Attribute holds Boolean Values, example: orc.dead = false
an Integer Attribute holds Integer Values: player.strength_integer = 100
a Double Attribute holds Double Values: player.damage = 57.23
if you're using Object Attributes for your equipment, those Objects need to actually exist (or else an ERROR), for example:
player.right_hand = sword // or: unarmed // or: unknown // or: nothing
player.left_hand = shield // or: unarmed // or: unknown // or: nothing
player.torso = unarmed // or: naked // or: unknown // or: mail // or: nothing
<object name="sword">
<attr name="damage" type="int">10</attr>
</object>
<object name="unarmed">
<attr name="damage" type="int">1</attr>
</object>
<object name="unknown">
<attr name="damage" type="int">1</attr>
</object>
<object name="naked">
<attr name="damage" type="int">1</attr>
</object>
<object name="shield">
</object>
<object name="mail">
</object>
<object name="nothing">
<attr name="damage" type="int">1</attr>
</object>
// and you'd do something like this for scirpting:
<object name="player">
<attr name="damage" type="int">1</attr>
<attr name="right_hand" type="object">unknown</attr>
<attr name="changedright_hand" type="script">
player.damage = player.right_hand.damage
</attr>
</object>
if you're just/purely using String Attributes, then you don't need the Objects existing:
player.right_hand = "sword" // or: "unarmed" // or: "unknown" // or: "nothing"
but, then you'd have to do something like this for scripting:
<object name="player">
<attr name="right_hand" type="string">unknown</attr>
<attr name="damage" type="int">1</attr>
<attr name="changedright_hand" type="script">
if (player.right_hand = "unarmed" or player.right_hand = "nothing" or player.right_hand = "unknown" or player.right_hand = "naked") {
player.damage = 1
} else if (player.right_hand = "sword") {
player.damage = 10
}
</attr>
</object>
you can also use String Attributes but then use the String Attribute/Value to get/use Objects: with GetObject(STRING_NAME_OF_OBJECT)
P.S.
there's also a blank value:
player.right_hand_string_attribute = ""
player.right_hand_object_attribute =
<object name="player">
<attr name="right_hand_string_attribute" type="string"></attr>
<attr name="right_hand_object_attribute" type="object"></attr>
</object>
and there's also a 'null' value too:
player.right_hand_string_attribute = null
player.right_hand_object_attribute = null
<object name="player">
<attr name="right_hand_string_attribute" type="string">null</attr>
<attr name="right_hand_object_attribute" type="object">null</attr>
</object>
hegemonkhan
27 Jun 2017, 00:51You are using String Attributes for your equipment Attributes:
player.upper which is currently at"nothing" to start at.
player.lower which is currently at "nothing" to start at.
player.clothed which is currently at "" to start at until it is given its value.
so, you need the double quotes on 'nude':
if (player.upper = "nothing") {
if (player.lower = "nothing") {
player.clothed = "nude" // <---------- you didn't have double quotes on 'nude'
}
}
// --------------
SetInc (150)
msg ("{player.plevel}")
msg ("{player.purity}")
msg ("{player.clothed}")
msg ("{player.upper}")
msg ("{player.lower}")
now, it should work for you.
The Pixie
27 Jun 2017, 06:54How are you setting player.upper
and player.lower
in the first place? If you are doing so via the Attributes tab, there should be no quotes. If you are doing it in a script, then there should be quotes.
With regards:
if (player.upper = "nothing") {
if (player.lower = "nothing") {
player.clothed = nude
}
}
"nude" should be in quotes. You also need some code that will set player.clothed
to some other value when the player is not nude (but perhaps you just did not show).
JenniferKline
27 Jun 2017, 09:12Yeah, Pixie, the attributes had quotes on. player.upper
, player.lower
and player.clothed
were all added on the player's attribute tab. I'd put quotes on all of them, which did lead to them printing with quotes on and the turn script I'd set to try and calculate when the player was nude to not be working.
Moment I took away the quotes, things started working with my test command.
Turn Script
if (player.upper = "nothing") {
if (player.lower = "nothing") {
set (player, "clothed", "nude")
}
}
Test Command
SetInc (150)
msg ("{player.plevel}")
msg ("{player.purity}")
msg ("{player.clothed}")
msg ("{player.upper}")
msg ("{player.lower}")
Attributes
String: player.clothed:
String: player.upper: nothing
String: player.lower: nothing
I now get my nude
value as desired. Maybe I didn't fix or work it the proper way, but as long as it works >.> <.< then it's all good.