Integral Objects and Body Parts
K.V.
30 May 2021, 20:14Okay. . .
This all assumes the object is part of its parent and the parent is either transparent or a surface or an open container.
The integral
type:
- has
not_all
set totrue
- has this
take
script:msg ("You can't take " + this.article + " off of " + GetDefiniteName(this.parent) + ".")
NOTE: I decided to leave up to the author whether or not it is scenery.
The body_part
type:
- inherits the
integral
type - has
scenery
set totrue
- has this
drop
script:msg ("You can't do that with body parts.")
I altered DoTake
, changing this:
if (object.parent = game.pov) {
msg (prefix + DynamicTemplate("AlreadyTaken", object))
}
...to this:
if (object.parent = game.pov) {
if (not GetBoolean(object, "body_part_type")) {
msg (prefix + DynamicTemplate("AlreadyTaken", object))
}
else {
OutputTextNoBr (prefix)
do (object, "take")
}
}
I feel liked I've overlooked something.
What am I overlooking?
(Note that the put
command will defer to an object's drop
attribute script, if it exists.)
K.V.
30 May 2021, 20:15Example game:
<!--Saved by Quest 5.8.7753.35184-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Integral Objects and Body Parts">
<gameid>65c53d04-7133-4f0b-be6a-7c5ebdaf5657</gameid>
<version>1.0</version>
<firstpublished>2021</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<isroom />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<object name="hands">
<inherit name="editor_object" />
<inherit name="body_part" />
</object>
</object>
<object name="device">
<inherit name="editor_object" />
<inherit name="surface" />
<feature_container />
<listchildren />
<addscript type="script">
msg ("You can't do that.")
</addscript>
<object name="green button">
<inherit name="editor_object" />
<inherit name="integral" />
<push>Nothing obvious happens.</push>
</object>
</object>
<object name="Mary">
<inherit name="editor_object" />
<inherit name="namedfemale" />
<inherit name="surface" />
<look>Mary has a big pimple.</look>
<feature_container />
<contentsprefix>who has</contentsprefix>
<listchildren />
<listchildrenprefix>She has</listchildrenprefix>
<addscript type="script">
msg ("Mary wouldn't like that.")
</addscript>
<object name="big pimple">
<inherit name="editor_object" />
<inherit name="body_part" />
<look>It is HUGE!!!</look>
</object>
<object name="earrings">
<inherit name="editor_object" />
<inherit name="plural" />
<inherit name="integral" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<object name="basket">
<inherit name="editor_object" />
<inherit name="container_open" />
<feature_container />
<open type="boolean">false</open>
<close type="boolean">false</close>
<listchildren />
<take />
</object>
<object name="eggs">
<inherit name="editor_object" />
<inherit name="plural" />
<take />
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<type name="integral">
<integral_type />
<not_all />
<take type="script">
msg ("You can't take " + this.article + " off of " + GetDefiniteName(this.parent) + ".")
</take>
</type>
<type name="body_part">
<inherit name="integral" />
<body_part_type />
<scenery />
<drop type="script">
msg ("You can't do that with body parts.")
</drop>
</type>
<function name="DoTake" parameters="object, ismultiple"><![CDATA[
prefix = ""
if (ismultiple) {
prefix = GetDisplayAlias(object) + ": "
}
if (object.parent = game.pov) {
if (not GetBoolean(object, "body_part_type")) {
msg (prefix + DynamicTemplate("AlreadyTaken", object))
}
else {
OutputTextNoBr (prefix)
do (object, "take")
}
}
else if (not ListContains(ScopeReachable(), object)) {
msg (BlockingMessage(object, prefix))
}
else if (not TestTakeGlobal(object, prefix)) {
// Do nothing, already handled
}
else if (not CheckLimits(object, prefix)) {
// Do nothing, already handled
}
else {
found = true
takemsg = object.takemsg
switch (TypeOf(object, "take")) {
case ("script") {
if (ismultiple) {
OutputTextNoBr (prefix)
}
do (object, "take")
takemsg = ""
}
case ("boolean") {
if (object.take = true) {
object.parent = game.pov
if (takemsg = null) {
takemsg = DynamicTemplate("TakeSuccessful", object)
}
}
else {
found = false
}
}
case ("string") {
object.parent = game.pov
takemsg = object.take
}
default {
found = false
}
}
if (not found and takemsg = null) {
takemsg = DynamicTemplate("TakeUnsuccessful", object)
}
if (LengthOf(takemsg) > 0) {
msg (prefix + takemsg)
}
if (HasScript(object, "ontake")) {
do (object, "ontake")
}
if (found and GetBoolean (object, "scenery") and object.parent = game.pov) {
object.scenery = false
}
}
]]></function>
</asl>