Equip / Unequip!

Anonynn
15 Mar 2016, 20:05I was wondering if anyone knows the basic code to equip and unequip a weapon? That is to say that the word "equip" appears next to the weapon. Thanks!
Quantus
15 Mar 2016, 20:38The way i do it is to create two objects for that item:
SWORD its verb is EQUIP
{SWORD} its verb is UNEQUIP
The verb moves the object out of inventory, and moves the other object into the inventory. The brackets indicate to the player that the sword is equipped.
Its worked for me. The other option would be to change the alias and change the verb which never worked for me on the web version of Quest.
SWORD its verb is EQUIP
{SWORD} its verb is UNEQUIP
The verb moves the object out of inventory, and moves the other object into the inventory. The brackets indicate to the player that the sword is equipped.
Its worked for me. The other option would be to change the alias and change the verb which never worked for me on the web version of Quest.

Anonynn
16 Mar 2016, 00:34I'm not quite sure that'll work in the way I'm used to using items, although it's a fantastic alternative. Any other suggestions?
HegemonKhan
16 Mar 2016, 10:32Chase's Wearables and/or Pixie's guides has the most simplified code for this:
http://docs.textadventures.co.uk/quest/ ... alias.html
(I'm just guessing at the code, so it could be wrong, lol)
-------------
the displayment of 'equipment_name (equipped)', is from/due to using:
GetDisplayAlias // this gets the current alias displayment!
conceptually:
weapon_1.alias = "sword"
// output: sword
GetDisplayAlias = weapon_1.alias = "sword"
returns: sword
weapon_1. alias = [GetDisplayAlias] + " (equipped)"
weapon_1.alias = [sword] + " (equipped)"
output: sword (equipped)
*******
what would happen if we did this? :
weapon_1.alias = "sword"
weapon_1.alias = GetDisplayAlias + " (equipped 1)"
weapon_1.alias = GetDisplayAlias + " (equipped 99)"
Answer:
sword (equipped 1) (equipped 99)
conceptually:
weapon_1.alias = "sword"
output: sword
weapon_1.alias = [GetDisplayAlias] + " (equipped 1)"
weapon_1.alias = [sword] + " (equipped 1)"
output: sword (equipped 1)
weapon_1.alias = [GetDisplayAlias] + " (equipped 99)"
weapon_1.alias = [sword (equipped 1)] + " (equipped 99)"
output: sword (equipped 1) (equpped 99)
******
however, it's a bit more complicated, in the removal of the displayment of "equipped", as you got to restore the "alias" String Attribute's value from 'GetDisplayAlias + " (equipped)" to just "sword" (it's original/default alias), which is why we have to store/save "sword", so we can then load it back into being the "alias" when we unequip it.
--------------------------
as you can probably attest, this is quite complicated/complex/advanced stuff...
if you can do without the "equipped" displayment in your inventory, there's a much easier design for equipment, of just setting (and re-setting) an Object Attribute to the desired weapon, and use that. Having the displayment of "equipped" is what adds a lot of complexity to using equipment ...
http://docs.textadventures.co.uk/quest/ ... alias.html
(I'm just guessing at the code, so it could be wrong, lol)
<object name="player">
<attr name="equipped" type="object">unarmed</attr>
</object>>
<object name="unarmed_weapon">
<attr name="alias" type="string">unarmed</attr>
<attr name="damage" type="int">1</attr>
</object>
<object name="sword_weapon_1">
<inherit name="equipment" />
<attr name="alias" type="string">katana</attr>
<attr name="damage" type="int">50</attr>
</object>
<object name="sword_weapon_2">
<inherit name="equipment" />
<attr name="alias" type="string">claymore</attr>
<attr name="damage" type="int">75</attr>
</object>
<object name="axe_weapon_1">
<inherit name="equipment" />
<attr name="alias" type="string">hand axe</attr>
<attr name="damage" type="int">25</attr>
</object>
<object name="axe_weapon_2">
<inherit name="equipment" />
<attr name="alias" type="string">battle axe</attr>
<attr name="damage" type="int">100</attr>
</object>
<type name="equipment">
<attr name="equip" type="script">
if (this.parent = player and not player.equipped = this) {
player.equipped.alias = player.equipped.old_alias
player.equipped = this
this.old_alias = this.alias
this.alias = GetDisplayAlias + " (equipped)"
}
</attr>
<attr name="unequip" type="script">
if (this.parent = player and player.equipped = this) {
player.equipped = unarmed
this.alias = this.old_alias
</attr>
<attr name="inventoryverbs" type="simplestringlist">equip;unequip</attr>
</type>
<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 equip that!"</defaultexpression>
</verb>
-------------
the displayment of 'equipment_name (equipped)', is from/due to using:
GetDisplayAlias // this gets the current alias displayment!
conceptually:
weapon_1.alias = "sword"
// output: sword
GetDisplayAlias = weapon_1.alias = "sword"
returns: sword
weapon_1. alias = [GetDisplayAlias] + " (equipped)"
weapon_1.alias = [sword] + " (equipped)"
output: sword (equipped)
*******
what would happen if we did this? :
weapon_1.alias = "sword"
weapon_1.alias = GetDisplayAlias + " (equipped 1)"
weapon_1.alias = GetDisplayAlias + " (equipped 99)"
Answer:
sword (equipped 1) (equipped 99)
conceptually:
weapon_1.alias = "sword"
output: sword
weapon_1.alias = [GetDisplayAlias] + " (equipped 1)"
weapon_1.alias = [sword] + " (equipped 1)"
output: sword (equipped 1)
weapon_1.alias = [GetDisplayAlias] + " (equipped 99)"
weapon_1.alias = [sword (equipped 1)] + " (equipped 99)"
output: sword (equipped 1) (equpped 99)
******
however, it's a bit more complicated, in the removal of the displayment of "equipped", as you got to restore the "alias" String Attribute's value from 'GetDisplayAlias + " (equipped)" to just "sword" (it's original/default alias), which is why we have to store/save "sword", so we can then load it back into being the "alias" when we unequip it.
--------------------------
as you can probably attest, this is quite complicated/complex/advanced stuff...
if you can do without the "equipped" displayment in your inventory, there's a much easier design for equipment, of just setting (and re-setting) an Object Attribute to the desired weapon, and use that. Having the displayment of "equipped" is what adds a lot of complexity to using equipment ...