Different Descriptions for Entering Room from Different Direction #1545
Replies: 3 comments 18 replies
-
Hello. Any approach would end up being a lot of tedious work, really. If you actually want each room's description to change based upon the direction the player used to get to that room, that would mean writing something specific for each possibility for each room. Jay's method would be the best, mostly -- after a few minor changes. Jay's post
<command name="go" pattern="[go]" unresolved="[UnresolvedLocation]">
if (exit.visible) {
if (exit.locked) {
msg (exit.lockmessage)
}
else if (exit.runscript) {
if (HasScript(exit, "script")) {
do (exit, "script")
}
}
else if (exit.lookonly) {
msg ("[UnresolvedLocation]")
}
else {
game.pov.parent = exit.to
game.pov.lastExit = exit
}
}
else {
msg ("[UnresolvedLocation]")
}
</command>
<type name="northdirection">
<inherit name="compassdirection" />
<alias>north</alias>
<alt type="simplestringlist">n</alt>
<direction>northdir</direction>
</type>
<type name="northwestdirection">
<inherit name="compassdirection" />
<alias>northwest</alias>
<alt type="simplestringlist">nw</alt>
<direction>northwestdir</direction>
</type>
<type name="westdirection">
<inherit name="compassdirection" />
<alias>west</alias>
<alt type="simplestringlist">w</alt>
<direction>westdir</direction>
</type>
<type name="southwestdirection">
<inherit name="compassdirection" />
<alias>southwest</alias>
<alt type="simplestringlist">sw</alt>
<direction>southwestdir</direction>
</type>
<type name="southdirection">
<inherit name="compassdirection" />
<alias>south</alias>
<alt type="simplestringlist">s</alt>
<direction>southdir</direction>
</type>
<type name="southeastdirection">
<inherit name="compassdirection" />
<alias>southeast</alias>
<alt type="simplestringlist">se</alt>
<direction>southeastdir</direction>
</type>
<type name="eastdirection">
<inherit name="compassdirection" />
<alias>east</alias>
<alt type="simplestringlist">e</alt>
<direction>eastdir</direction>
</type>
<type name="northeastdirection">
<inherit name="compassdirection" />
<alias>northeast</alias>
<alt type="simplestringlist">ne</alt>
<direction>northeastdir</direction>
</type>
<type name="updirection">
<inherit name="updowndirection" />
<alias>up</alias>
<alt type="simplestringlist">u</alt>
<direction>updir</direction>
</type>
<type name="downdirection">
<inherit name="updowndirection" />
<alias>down</alias>
<alt type="simplestringlist">d</alt>
<direction>downdir</direction>
</type>
<type name="indirection">
<inherit name="inoutdirection" />
<alias>in</alias>
<alt type="simplestringlist"></alt>
<direction>indir</direction>
</type>
<type name="outdirection">
<inherit name="inoutdirection" />
<alias>out</alias>
<alt type="simplestringlist">o</alt>
<direction>outdir</direction>
</type>
END OF JAY'S POSTWell.. Let me back up... What is or isn't working for you? Here's what I ran into when I tried to create a game following those instructions while using the web editor just now:
So, we just need Jay's We will use ...and this is the point where we will still need to write a little extra code to handle things. NEW FUNCTION script: dirs = NewStringDictionary()
dictionary add (dirs, "north", "south")
dictionary add (dirs, "south", "north")
dictionary add (dirs, "east", "west")
dictionary add (dirs, "west", "east")
dictionary add (dirs, "northwest", "southeast")
dictionary add (dirs, "southeast", "northwest")
dictionary add (dirs, "northeast", "southwest")
dictionary add (dirs, "southwest", "northeast")
dictionary add (dirs, "in", "out")
dictionary add (dirs, "out", "in")
dictionary add (dirs, "up", "underneath")
dictionary add (dirs, "down", "above")
if (StringDictionaryItem(dirs, dir) <> null) {
return (StringDictionaryItem(dirs, dir))
}
return ("undefined") Finally, we can actually start the real work, which is adding a script1 for each room's description, using Example room description script: came_from = "undefined"
if (not HasAttribute(game.pov, "lastExit")) {
// The attribute will not exist when play begins. This avoids an error in that in case.
came_from = "@@GAME_START@@"
}
else {
came_from = OppoDir(game.pov.lastExit.alias)
}
if (came_from = "@@GAME_START@@") {
// Do nothing, the game just started
}
else if (came_from = "undefined") {
// The exit used was not listed in the OppoDir function
msg ("You seem to appear out of nowhere!")
}
else {
// In this example room, there are exits east and north
if (came_from = "west") {
// We entered WEST to get here
msg ("You came here from the room which is east of this location.")
}
else if (came_from = "south") {
// We entered SOUTH to get here
msg ("The butler asks that you wipe your feet before the next time you come inside from the fields which are north from this room!")
}
else {
msg ("You have entered from a direction which is listed in the OppoDir function, but was not handled in this room's script. Please submit a bug report.")
}
} OR...... if you're just wanting to tack on an extra line that prints when entering every room with a default string like "You just entered from...", then that wouldn't be very hard, but it would require:
if (exit.visible) {
if (exit.locked) {
msg (exit.lockmessage)
}
else if (exit.runscript) {
if (HasScript(exit, "script")) {
do (exit, "script")
}
}
else if (exit.lookonly) {
msg ("[UnresolvedLocation]")
}
else {
game.pov.parent = exit.to
game.pov.lastExit = exit
}
}
else {
msg ("[UnresolvedLocation]")
}
Script when entering a room on the came_from = "undefined"
if (not HasAttribute(game.pov, "lastExit")) {
// The attribute will not exist when play begins. This avoids an error in that in case.
came_from = "@@GAME_START@@"
}
else {
came_from = OppoDir(game.pov.lastExit.alias)
}
if (came_from = "@@GAME_START@@") {
// Do nothing, the game just started
}
else if (came_from = "undefined") {
// The exit used was not listed in the OppoDir function
msg ("You seem to appear out of nowhere!")
}
else {
msg ("You enter from " + came_from + ".")
} Footnotes
|
Beta Was this translation helpful? Give feedback.
-
@KVonGit What do you think about this idea? It's not easy to do it in the webeditor.
EDIT: OK, it's not possible to overwrite functions in the webeditor :-( |
Beta Was this translation helpful? Give feedback.
-
Here's a different (fun little) way things could be handled.
<!--Saved by Quest 5.9.9166.36226-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="lastparent">
<gameid>666abc76-c241-4d55-97d6-370f6433ff13</gameid>
<version>1.0</version>
<firstpublished>2025</firstpublished>
<start type="script"><![CDATA[
game.pov.changedparent => {
if (game.pov = this) {
if (IsDefined("oldvalue")) {
// The next line is new
game.pov.lastparent = oldvalue
OnEnterRoom (oldvalue)
}
else {
OnEnterRoom (null)
}
if (game.gridmap) {
MergePOVCoordinates
}
}
this.hasbeenmoved = true
}
]]></start>
<roomenter type="script"><![CDATA[
if (HasAttribute(game.pov, "lastparent")) {
msg ("<b>You came here from " + GetDisplayName(game.pov.lastparent) + ".</b>")
}
]]></roomenter>
</game>
<object name="living room">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<prefix>the</prefix>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="north" to="outside">
<inherit name="northdirection" />
<suffix>(outside)</suffix>
</exit>
<exit alias="south" to="kitchen">
<inherit name="southdirection" />
<suffix>(to the kitchen)</suffix>
</exit>
<exit alias="west" to="hallway">
<inherit name="westdirection" />
<suffix>(to the hallway)</suffix>
</exit>
</object>
<object name="hallway">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<prefix>the</prefix>
<exit alias="east" to="living room">
<inherit name="eastdirection" />
<suffix>(to the living room)</suffix>
</exit>
</object>
<object name="kitchen">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<prefix>the</prefix>
<exit alias="north" to="living room">
<inherit name="northdirection" />
<suffix>(to the lving room)</suffix>
</exit>
</object>
<object name="outside">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<descprefix>{=WriteVerb(game.pov, "be")}</descprefix>
<exit alias="south" to="living room">
<inherit name="southdirection" />
<suffix>(to the living room)</suffix>
</exit>
</object>
</asl> You are in the living room.
You can go north (outside), south (to the kitchen) or west (to the hallway).
> go north
You are outside.
You can go south (to the living room).
You came here from the living room.
> go south
You are in the living room.
You can go north (outside), south (to the kitchen) or west (to the hallway).
You came here from outside.
> go south
You are in the kitchen.
You can go north (to the lving room).
You came here from the living room.
> go north
You are in the living room.
You can go north (outside), south (to the kitchen) or west (to the hallway).
You came here from the kitchen.
> go west
You are in the hallway.
You can go east (to the living room).
You came here from the living room.
> go east
You are in the living room.
You can go north (outside), south (to the kitchen) or west (to the hallway).
You came here from the hallway.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am making a game in Quest (web version) and I would like to be able to display different room descriptions (or the equivalent scripted messages) based on the direction the player is entering the room from.
I have tried using the code from this old forum post with little success (I was able to get Quest 5.8 running on macOS through CrossOver, so that also might be complicating things). I have also tried wrapping my head around the other method mentioned in that forum post, but it both seems a little over my head and a lot of tedious work given how many rooms I would like this to work for.
Would there be a way to do something like this? Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions