NPC Carrying/Wearing #1542
Doctor-Agon
started this conversation in
General
Replies: 1 comment
-
Hello, If you are using the <!--Saved by Quest 5.9.9166.36226-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="NPC Carrying and Wearing">
<gameid>da15d6aa-2a47-4185-b584-2d8dc3e7105c</gameid>
<version>1.0</version>
<firstpublished>2025</firstpublished>
<start type="script">
// Create a list of objects for Fred to wear call NPCWear (must be done for each NPC)
list = NewObjectList()
list add (list, toga)
NPCWear (Fred, list)
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="Fred">
<inherit name="editor_object" />
<inherit name="namedmale" />
<inherit name="surface" />
<feature_container />
<contentsprefix>who has</contentsprefix>
<hidechildren />
<addscript type="script">
msg ("Fred probably wouldn't like that.")
</addscript>
<object name="foo">
<inherit name="editor_object" />
</object>
<object name="toga">
<inherit name="editor_object" />
<inherit name="wearable" />
<feature_wearable />
</object>
</object>
</object>
<function name="NPCWear" parameters="object, clothing">
// Disable the changescript which normally handles changes of POV:
changescript = game.changedpov
game.changedpov = null
// change POV without displaying a new descriptions
game.pov = object
// handle wearing the stuff:
foreach (n, clothing) {
WearGarment (n)
}
// put the player back in control
game.pov = player
// and enable all the changed-pov magic again
game.changedpov = changescript
</function>
<function name="ListObjectContents" parameters="object"><![CDATA[
if ((GetBoolean(object, "isopen") or GetBoolean(object, "transparent")) and GetBoolean(object, "listchildren")) {
if (GetBoolean(object, "hidechildren")) {
object.hidechildren = false
}
if (HasString(object, "listchildrenprefix")) {
listprefix = object.listchildrenprefix
}
else {
listprefix = DynamicTemplate("ObjectContains", object)
}
list = FormatObjectList(listprefix, object, Template("And"), ".")
if (list <> "") {
msg (list)
}
}
else if (DoesInherit(object, "npc_type")) {
objects = GetDirectChildren(object)
objects_held = FilterByNotAttribute(objects, "worn")
objects_worn = ListExclude(objects,objects_held)
pre = CapFirst(GetDisplayName(object)) + " " + Conjugate(object, "be")
printed_something = false
if (ListCount(objects_held) > 0) {
held = FormatList(objects_held, ",", ", and", "nothing")
OutputTextNoBr (" " + pre + " carrying " + held + ".")
printed_something = true
}
if (ListCount(objects_worn) > 0) {
worn_objects = NewStringList()
foreach (o, objects_worn) {
list add (worn_objects, Replace(GetDisplayName(o), " (worn)", ""))
}
worn = FormatList(worn_objects, ",", ", and", "nothing")
OutputTextNoBr (" " + pre + " wearing " + worn + ".")
printed_something = true
}
if (printed_something) {
msg ("")
}
}
]]></function>
</asl> Note I made Fred a surface in order to be able to interact with the objects held/worn, and I changed the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Everyone,
I don't know if this question has been asked before. I couldn't find it on any previous discussions. But, at the moment when an NPC is wearing clothes and carrying objects, when you look at the NPC, the description doesn't seem to differentiate between the two.
Is there a way I can split the two and have the look at NPC print out
Fred is carrying a torch. Fred is wearing a coat and hat. Or whatever...
Rather than
Fred is carrying a torch, hat, and coat.
Hope you can help. Many thanks.
Beta Was this translation helpful? Give feedback.
All reactions