The 'GetXXX' Scripts/Functions will return the Value of an Attribute, if that Attribute and its Value exists (which includes it having to be the correct Attribute/Value Type), and if that Attribute doesn't exist, then it returns either 'false' or 'null' (not sure which).
whereas, the 'HasXXX' Scripts/Functions only return whether the Attribute exists ('true'), else it returns 'false'
---------------
Attribute Types (
http://docs.textadventures.co.uk/quest/types/ ):
String Attribute:
player.alias = "HK"
game.state = "0"
npc.greeting = "Hi, what is your name?"
HK.favorite_color = "black"
etc etc etc
Boolean Attribute:
orc.dead = false
orc.dead = true // this is often (for more code efficiency/possibly less confusion), shortened to or understood by quest, as this: orc.dead
player.flying = false
player.flying = true
game.dragon_killed_mission_completed = false
game.dragon_killed_mission_completed = true
player.poisoned = true
player.poisoned = false
etc etc tc
Integer Attribute:
player.strength = 100
game.state = 0
orc.damage = 10
katana.damage = 50
Double Attribute:
player.damage = 37.291018
// I don't think it uses double quotes, as that should/would turn it into a String Attribute/Value (any Value/thing in double quotes is a String), I'm assuming anyways
Object Attribute:
the Value does/can NOT have double quotes, as double quotes turns it (the Value) into a String, instead of an Object
***********************************
but has two conditions:
1. the Value can't be: 'true' nor 'false', as these are special/reserved keywords for the Boolean Attribute's Values
2. the Value has to be (the name of) an actual/existing Object (see below)
<object name="player">
</object>
<object name="sword">
</object>
player.right_hand = sword
// NO error
VS
<object name="player">
</object>
player.right_hand = sword
// ERROR, as there's no existing 'sword' Object
*************************************
List Attribute:
game.sex_list = split ("male;female", ";")
game.condition_list = split ("normal;poisoned;paralyzed;petrified;stunned;asleep;dead;unconscious;silenced", ";")
player.condition_list = split ("poisoned;petrified", ";")
HK.favorite_color_list = split ("black;red", ";")
and the other (less main) Attribute Types... I'm getting lazy and/or they're outside of my knowledge of them
--------------------------------------------------------
so, how does the 'GetXXX' and 'HasXXX' work?
(I'm not sure if they return 'false' or 'null', not sure which it is, so that's why I use 'false/null' below, but you got to use either 'false' or 'null', and see which one works)
HAS:
it does NOT care at all about the Value of the Attribute; it only checks (true/false) if the Attribute exists.
the 'HasAttribute()' Script Function has internal coding that determines/parses what the Attribute Type it is, that it is checking for existance, so this is probably less efficient code-wise than using the specific Attribute Type 'HasSpecific_Attribute_Type()' Scripts/Functions, however, this means that the 'HasAttribute()' Script/Function is more powerful/useful, as it can be used when you don't know what Attribute Type you're using, and/or if you're using multiple Types of Attributes. Also, the 'HasAttribute()' works for List and Dictionary Attributes too (I think it's the only method... but I could be wrong).
HasSpecific_Attribute_Type: HasObject(), HasInt(), HasDouble(), HasString(), HasBoolean(), etc?
player.strength = 100
if (HasAttribute (player, "strength") = true) { // or shortened/efficient form: if (HasAttribute (player, "strength")) {
msg ("The 'player' Player Object indeed has a 'strength' Attribute")
} else if (HasAttribute (player, "strength") = false/null) { // or alternate/shortened/efficient form: if (not HasAttribute (player, "strength")) {
msg ("Sorry, but there is no 'player.strength' Attribute")
}
// output: The 'player' Player Object indeed has a 'strength' Attribute
// or, since we specifically have/know that 'player.strength' is an Integer Attribute, we can use the 'GetInt()' Script/Function instead:
player.strength = 100
if (HasInt (player, "strength") = true) { // or shortened/efficient form: if (HasInt (player, "strength")) {
msg ("The 'player' Player Object indeed has a 'strength' Attribute")
} else if (HasInt (player, "strength") = false/null) { // or alternate/shortened/efficient form: if (not HasInt (player, "strength")) {
msg ("Sorry, but there is no 'player.strength' Attribute")
}
// output: The 'player' Player Object indeed has a 'strength' Attribute
// vs:
player.endurance = 100
if (HasAttribute (player, "strength") = true) { // or shortened/efficient form: if (HasAttribute (player, "strength")) {
msg ("The 'player' Player Object indeed has a 'strength' Attribute")
} else if (HasAttribute (player, "strength") = false/null) { // or alternate/shortened/efficient form: if (not HasAttribute (player, "strength")) {
msg ("Sorry, but there is no 'player.strength' Attribute")
}
// output: Sorry, but there is no 'player.strength' Attribute
// or, since we specifically have/know that 'player.strength' is an Integer Attribute, we can use the 'GetInt()' Script/Function instead:
player.endurance = 100
if (HasInt (player, "strength") = true) { // or shortened/efficient form: if (HasInt (player, "strength")) {
msg ("The 'player' Player Object indeed has a 'strength' Attribute")
} else if (HasInt (player, "strength") = false/null) { // or alternate/shortened/efficient form: if (not HasInt (player, "strength")) {
msg ("Sorry, but there is no 'player.strength' Attribute")
}
// output: Sorry, but there is no 'player.strength' Attribute
// hopefully, you can understand how the other 'HasSpecific_Attribute_Type' work too, and now understanding how all the 'HasXXX' works...
-----------------
GET:
this DOES care about the Value of the Attribute. It is the 'HasXXX' as it checks if the Attribute exists, but it ALSO checks if its Value matches up too. So there's two checks/conditions: (1) does the Attribute exist and (2) does its Value match up, if both checks/conditions are true, then it is TRUE, doing that script of yours, if one or both checks/conditions are false, then it is FALSE, doing that script of yours
(I'm just using the 'GetInt()' for this example)
player.strength = 100
if (GetInt (player, "strength") = 100) {
msg ("blah1")
} else if (GetInt (player, "strength") >= 50) {
msg("blah2")
} else if (GetInt (player, "strength") = 30) {
msg ("blah3")
} else if (not Getint (player, "strength") = 100) {
msg ("blah4")
} else {
msg ("blah5")
}
// output: blah1
// vs:
player.strength = 70
if (GetInt (player, "strength") = 100) {
msg ("blah1")
} else if (GetInt (player, "strength") >= 50) {
msg("blah2")
} else if (GetInt (player, "strength") = 30) {
msg ("blah3")
} else if (not Getint (player, "strength") = 100) {
msg ("blah4")
} else {
msg ("blah5")
}
// output: blah2
// vs:
player.strength = 30
if (GetInt (player, "strength") = 100) {
msg ("blah1")
} else if (GetInt (player, "strength") >= 50) {
msg("blah2")
} else if (GetInt (player, "strength") = 30) {
msg ("blah3")
} else if (not Getint (player, "strength") = 100) {
msg ("blah4")
} else {
msg ("blah5")
}
// output: blah3
// vs:
player.strength = 10
if (GetInt (player, "strength") = 100) {
msg ("blah1")
} else if (GetInt (player, "strength") >= 50) {
msg("blah2")
} else if (GetInt (player, "strength") = 30) {
msg ("blah3")
} else if (not Getint (player, "strength") = 100) {
msg ("blah4")
} else {
msg ("blah5")
}
// output: blah4
// vs:
player.endurance = 100
if (GetInt (player, "strength") = 100) {
msg ("blah1")
} else if (GetInt (player, "strength") >= 50) {
msg("blah2")
} else if (GetInt (player, "strength") = 30) {
msg ("blah3")
} else if (not Getint (player, "strength") = 100) {
msg ("blah4")
} else {
msg ("blah5")
}
// output: blah5
// vs:
player.strength = "100"
if (GetInt (player, "strength") = 100) {
msg ("blah1")
} else if (GetInt (player, "strength") >= 50) {
msg("blah2")
} else if (GetInt (player, "strength") = 30) {
msg ("blah3")
} else if (not Getint (player, "strength") = 100) {
msg ("blah4")
} else {
msg ("blah5")
}
// output: blah5