TM123 wrote:I reproduced the error by making a wearable object then setting it to "cannot be worn."
This leaves in the "wear_slots" attribute which the "DoWear" function checks for as a way to test for wearability,
but removes the "worn" attribute. When the "worn" attribute is missing, "item.worn = true" will give that error.
So I would check your inventory (specifically ScopeReachableInventory) for an item with a "wear_slots" attribute, but no "worn" attribute - probably something set to "cannot be worn."
And/or stick a "if(HasAttribute(item,"worn"))" into the DoWear and DoRemove function just before the "if(item.worn = true)"
if (not HasAttribute(object,"worn")) {
msg (DynamicTemplate("WearUnsuccessful", object))
}
else if (object.parent = player and object.worn = true) {
msg (DynamicTemplate("AlreadyWearing", object))
}
else if (not ListContains(ScopeInventory(), object)) {
msg (DynamicTemplate("WearUnsuccessful", object))
}
else {
isLayerProblem = false
conflictedItem = null
if (HasAttribute(object,"wear_slots")) {
foreach (item, ScopeReachableInventory()) {
if (HasAttribute(item,"wear_slots")) {
if (HasAttribute(item,"worn")) {
}
if (item.worn = true) {
foreach (itemSlot, item.wear_slots) {
if (ListContains(object.wear_slots,itemSlot)) {
if (object.wear_layer < item.wear_layer) {
conflictedItem = item
isLayerProblem = true
}
else if (object.wear_layer = item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}
if (conflictedItem = null) {
object.worn = True
object.original_drop = object.drop
object.original_alias = object.alias
object.drop = false
object.display = GetDisplayName(object)
object.alias = GetDisplayAlias(object) + " (worn)"
if (object.wearmsg = null) {
msg (DynamicTemplate("WearSuccessful",object))
}
else {
msg (object.wearmsg)
}
// do after
if (HasScript(object, "onafterwear")) {
do (object, "onafterwear")
}
else if (HasString(object, "onafterwear")) {
msg (object.onafterwear)
}
}
else if (isLayerProblem = true) {
msg (DynamicTemplate("CannotWearOver",conflictedItem))
}
else {
msg (DynamicTemplate("CannotWearWith",conflictedItem))
}
}
if (not object.parent = player or not object.worn or not object.removeable) {
if (object.removemsg = null) {
msg (DynamicTemplate("RemoveUnsuccessful",object))
}
else {
msg (object.removemsg)
}
}
else {
conflictedItem = null
// check if we are wearing anything over it
if (HasAttribute(object,"wear_slots")) {
foreach (item, ScopeReachableInventory()) {
if (HasAttribute(item,"wear_slots")) {
if (HasAttribute(item,"worn")) {
}
if (item.worn = true) {
foreach (itemSlot, item.wear_slots) {
if (ListContains(object.wear_slots,itemSlot)) {
if (object.wear_layer < item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}
if (conflictedItem = null) {
if (object.removemsg = null) {
msg (DynamicTemplate("RemoveSuccessful",object))
}
else {
msg (object.removemsg)
}
object.worn = false
object.drop = object.original_drop
object.alias = object.original_alias
object.original_drop = null
object.original_alias = null
object.display = null
// do after
if (HasScript(object, "onafterremove")) {
do (object, "onafterremove")
}
else if (HasString(object, "onafterremove")) {
msg (object.onafterremove)
}
}
else {
msg (DynamicTemplate("RemoveFirst", conflictedItem))
}
}
<function name="DoWear" parameters="object"><![CDATA[
if(not HasAttribute(object,"worn")) {
msg (DynamicTemplate("WearUnsuccessful", object))
} else if (object.parent = player and GetBoolean(object, "worn")) {
msg (DynamicTemplate("AlreadyWearing", object))
} else if (not ListContains(ScopeInventory(), object)) {
msg (DynamicTemplate("WearUnsuccessful", object))
} else {
isLayerProblem = false
conflictedItem = null
if(HasAttribute(object,"wear_slots")) {
foreach(item, ScopeReachableInventory()) {
if(HasAttribute(item,"wear_slots")) {
if(GetBoolean(item, "worn")) {
foreach(itemSlot,item.wear_slots) {
if(ListContains(object.wear_slots,itemSlot)) {
if(object.wear_layer < item.wear_layer) {
conflictedItem = item
isLayerProblem = true
} else if(object.wear_layer = item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}
if(conflictedItem = null) {
object.worn = True
object.original_drop = object.drop
object.original_alias = object.alias
object.drop = false
object.display = GetDisplayName(object)
object.alias = GetDisplayAlias(object) + " (worn)"
if(object.wearmsg = null) {
msg (DynamicTemplate("WearSuccessful",object))
} else {
msg(object.wearmsg)
}
//do after
if (HasScript(object, "onafterwear")) {
do(object, "onafterwear")
} else if(HasString(object, "onafterwear")) {
msg(object.onafterwear)
}
} else if(isLayerProblem = true) {
msg(DynamicTemplate("CannotWearOver",conflictedItem))
} else {
msg(DynamicTemplate("CannotWearWith",conflictedItem))
}
}
]]></function>
<function name="DoRemove" parameters="object"><![CDATA[
if (not object.parent = player or not GetBoolean(object, "worn") or not GetBoolean(object, "removeable")) {
if(object.removemsg = null) {
msg (DynamicTemplate("RemoveUnsuccessful",object))
} else {
msg (object.removemsg)
}
} else {
conflictedItem = null
//check if we are wearing anything over it
if(HasAttribute(object,"wear_slots")) {
foreach(item, ScopeReachableInventory()) {
if(HasAttribute(item,"wear_slots")) {
if(GetBoolean(item, "worn")) {
foreach(itemSlot,item.wear_slots) {
if(ListContains(object.wear_slots,itemSlot)) {
if(object.wear_layer < item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}
if(conflictedItem = null) {
if(object.removemsg = null) {
msg (DynamicTemplate("RemoveSuccessful",object))
} else {
msg(object.removemsg)
}
object.worn = false
object.drop = object.original_drop
object.alias = object.original_alias
object.original_drop = null
object.original_alias = null
object.display = null
//do after
if (HasScript(object, "onafterremove")) {
do(object, "onafterremove")
} else if(HasString(object, "onafterremove")) {
msg(object.onafterremove)
}
} else {
msg (DynamicTemplate("RemoveFirst", conflictedItem))
}
}
]]></function>
Neonayon wrote:It seems that if a PC is wearing the item of clothing...and they try to drop it (while wearing it), the game prints the drop message, even though the item is still worn on the player.
Is this for all items or some?
Does the PC start the game wearing these items?
You mean it is like this:
> inv
You are carrying a pants.
> wear pants
You put it on.
> inv
You are carrying a pants (worn).
> drop pants
You drop it.
> inv
You are carrying a pants (worn).
> look
You are in a room. --- (you don't see any pants)
The DoWear sets the worn object's .drop attribute to false, and doesn't mess around with anything else having to do with dropping. If .drop = false then you can't drop it. If DoWear makes a mistake and .drop = true then you can drop it.
The core library handles that. I would guess the false drop message is coming from a script.
Could you post the code for one of the clothing objects?
<object name="cute_headband">
<inherit name="editor_object" />
<inherit name="wearable" />
<alias>Cute Headband</alias>
<look><![CDATA[<br/>A cute black headband with a shimmering silk strip down the center. ]]></look>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<alt type="stringlist">
<value>cute headband</value>
<value>head band</value>
<value>black headband</value>
<value>cute black headband</value>
</alt>
<take />
<volume type="int">1</volume>
<takemsg>You take the headband in hand. </takemsg>
<dropmsg><![CDATA[{once:(You have to "<i>Remove</i>" it before you can drop it)} You drop the headband. ]]></dropmsg>
<attr name="wear_layer" type="int">9</attr>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Drop</value>
<value>Wear</value>
<value>Remove</value>
</inventoryverbs>
</object>
<dropmsg><![CDATA[{once:(You have to "<i>Remove</i>" it before you can drop it)} You drop the headband. ]]></dropmsg>
<dropmsg><![CDATA[{if cute_headband.worn:You can't drop it.{once: You have to "<i>Remove</i>" it before you can drop it.}} {if not cute_headband.worn:You drop the headband.}]]></dropmsg>
naked = true
foreach(o, ScopeInventory ()) {
if (GetBoolean(o, "worn")) {
naked = false
}
}
if (naked) {
msg("He freaks out, what with you being naked.")
}
naked = true
foreach(o, ScopeInventory ()) {
if (GetBoolean(o, "worn")) {
if (o.wear_slots = "chest" or o.wear_slots = "groin") {
naked = false
}
}
}
if (naked) {
msg("He freaks out, what with you being naked.")
}
The bowtie{if bowtie.worn: that you are wearing} is black.
[quote]naked = true
foreach(o, ScopeInventory ()) {
if (GetBoolean(o, "worn")) {
if (o.wear_slots = "chest" or o.wear_slots = "groin") {
naked = false
}
}
}
if (naked) {
msg("He freaks out, what with you being naked.")
}[/quote]
Neonayon wrote:^--- what is the "o" in o.wear_slots? This will likely be the one I'll be using for most events if the player is indeed nekkid, haha.