Calling Attribute In Online editor?

onimike
13 Sept 2016, 22:36Hey again got another minor yet annoying issue. In my game I have 'Weapon' as status attribute and on my weapon item a verb called "equip" and "unequip". Well my equip weapon works fine but for some reason can't seem to call attribute "If Weapon = (Equipped Weapon) then {do something}
Here is my equip code
dictionary remove (game.pov.statusattributes, "Weapon")
dictionary add (game.pov.statusattributes, "Weapon", "Weapon = Beretta")
And here is my unequip code
if (game.pov.Weapon = Beretta) {
dictionary remove (game.pov.statusattributes, "Weapon")
dictionary add (game.pov.statusattributes, "Weapon", "Weapon = None")
}
Im using game.pov because the player changes so i want it to always get the correct character. I know im making a string variable and probably better way the resetting string each time but don't think im calling it right but do not receive errors from the code so a little lost lol. Thanks in Advance
Mike
hegemonkhan
14 Sept 2016, 00:19remember, that the built-in 'statusattributes' String Dictionary Attribute, is merely to DISPLAY an Attribute, but you got to actually create the Attribute itself, too!
so create/add an Object Attribute (or you can use an Object List Attribute, if you want more complexity for your more advanced equipment system) to your Player Object, for example in code:
player.right_hand = sword
player.left_hand = shield
Axe's Verb (equiping the axe):
player.right_hand = axe
// which you can now use this Attribute VARIABLE, in/for your 'if' Script's condition location, for example:
if (player.right_hand = sword) {
msg ("Right Hand: " + player.right_hand.name)
} else if (player.right_hand = axe) {
msg ("Right Hand: " + player.right_hand.name)
}
~OR~
if (player.right_hand.name = "sword") {
msg ("Right Hand: " + player.right_hand.name)
} else if (player.right_hand.name = "axe") {
msg ("Right Hand: " + player.right_hand.name)
}
and the used Objects have to actually exist too, of course:
<object name="sword">
</object>
</object name="shield">
</object>
<object name="axe">
</object>
-----------------
the 'statusattributes' (and Object Attributes) should look like this, for example in code:
<object name="player">
<attr name="weapon" type="object">unarmed</attr>
<attr name="shield" type="object">unarmed</attr>
<attr name="helmet" type="object">unarmed</attr>
<attr name="armor" type="object">unarmed</attr>
<attr name="boots" type="object">unarmed</attr>
// etc body parts/slots
<statusattributes type="simplestringdictionary">weapon = Weapon: !; shield = Shield: !; helmet = Helmet: !; armor = Armor: !; boots = Boots: !</statusattributes>
</object>
<object name="unarmed">
<attr name="damage" type="int">1</attr>
<attr name="defense" type="int">0</attr>
</object>
<object name="katana">
<attr name="damage" type="int">50</attr>
<attr name="equip" type="script">
if (not player.weapon = this) {
player.weapon = this
msg ("You equip the " + this.name)
} else {
msg ("You're already equipped with the " + this.name + ", silly.")
}
</attr>
<attr name="unequip" type="script">
if (player.weapon = this) {
player.weapon = unarmed
msg ("You unequip the " + this.name)
} else {
msg ("You're already not equipped with the " + this.name + ", silly.")
}
</attr>
</object>
// etc weapons, shields, armors, helmets, boots, etc equipment Objects
<verb>
<property>equip</property>
<pattern>equip</pattern>
<defaultexpression>You can't equip that!</defaultexpression>
</verb>
<verb>
<property>unequip</property>
<pattern>unequip</pattern>
<defaultexpression>You can't unequip that!</defaultexpression>
</verb>
----------------------------------------
explanation of the String Dictionary Attribute's syntax:
<attr name="NAME_OF_YOUR_STRING_DICTONARY_ATTRIBUTE" type="simplestringdictionary">NAME_OF_YOUR_ATTRIBUTE_1_TO_BE_DISPLAYED = WHAT_YOU_WANT_TO_DISPLAY/OUTPUT/TEXT/STRING; NAME_OF_YOUR_ATTRIBUTE_2_TO_BE_DISPLAYED = WHAT_YOU_WANT_TO_DISPLAY/OUTPUT/TEXT/STRING; ETC ETC ETC</attr>
the '!' is a special keyword/keysymbol/keycommand, which will be replaced (automaticaly by quest) by the Value of your Attribute; think of the '!' as a VARIABLE that holds the Attribute's Value or think of the '!' as a 'Get/Return Attribute's Value' Function.
so, for example and its output:
<object name="mithril_katana"></object>
<object name="unarmed"></object>
<object name="mithril_full_plate_armor"></object>
<object name="mithril_warlord_helmet"></object>
<object name="mithril_war_boots"></object>
player.weapon = mithril_katana
player.shield = unarmed
player.armor = mithril_full_plate_armor
player.helmet = mithril_warlord_helmet
player.boots = mithril_war_boots
<statusattributes type="simplestringdictionary">weapon = Weapon: !; shield = Shield: !; armor = Armor: !; helmet = Helmet: !; boots = Boots: !</statusattributes>
displayment in the right pane during game play:
Weapon: mithril_katana
Shield: unarmed
Armor: mithril_full_plate_armor
Helmet: mithril_warlord_helmet
Boots: mithril_war_boots
------
<object name="adamantium_claymore"></object>
player.weapon = adamantium_claymore
displayment in the right pane during game play:
Weapon: adamantium_claymore
Shield: unarmed
Armor: mithril_full_plate_armor
Helmet: mithril_warlord_helmet
Boots: mithril_war_boots
P.S.
see these links for more detail:
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375 (statusattributes step by step guide+demo game)
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk (attributes and 'if' script giude)
The Pixie
14 Sept 2016, 07:15To summarise HK, if you do this in game.start:
dictionary add (game.pov.statusattributes, "Weapon", "Weapon = !")
... then Quest will automatically substitute the exclamation mark with the current value of game.pov.Weapon. If working off-line, use the Status Attributes section of the Attributes tab to do that.
Your equip is just:
game.pov.Weapon = "Beretta"

onimike
17 Sept 2016, 05:52Thanks HK you gave me alot of ideas on how to handle weapons ver much appreciated. And Pixie thats awesome worked perfect with replacing ! with null.
Thanks again both of you all are a major part what makes learning quest some much easier.
Mike