Using Menu or Question to Move?
Nalcarum
24 May 2016, 07:48Hi
So I'm really green with Quest and I have no background with coding whatsoever. I have tried to read the documentation but found out that I hardly understand a word about it. So I thought to ask for help.
So I'm trying to make a situation where player, after certain point, uses mirrors to move from room to room, and doors are unusable. So I would like to have a ability in the game to one way or another to choose where the player wants to go, one mirror can lead to any discovered mirror. I have tried to use a menu with list function but when testing it I get an error "Error running script: Error compiling expression 'MirrorList': Unknown object or variable 'MirrorList'". As I said, I don't know how to make a working list and I don't know what that error means. I tried to add the rooms that are accessible as parametres (using their names), but it doesn't seem to work.
So is there easier work-around for this, or could someone please explain how do I make a menu that shows the rooms player can jump into? If you try the later please explain it like you would explain it to donkey, very clearly and simply. I'm kinda feeling like a donkey because this doesn't feel like super complex thing to do.
Thanks before hand.
So I'm really green with Quest and I have no background with coding whatsoever. I have tried to read the documentation but found out that I hardly understand a word about it. So I thought to ask for help.
So I'm trying to make a situation where player, after certain point, uses mirrors to move from room to room, and doors are unusable. So I would like to have a ability in the game to one way or another to choose where the player wants to go, one mirror can lead to any discovered mirror. I have tried to use a menu with list function but when testing it I get an error "Error running script: Error compiling expression 'MirrorList': Unknown object or variable 'MirrorList'". As I said, I don't know how to make a working list and I don't know what that error means. I tried to add the rooms that are accessible as parametres (using their names), but it doesn't seem to work.
So is there easier work-around for this, or could someone please explain how do I make a menu that shows the rooms player can jump into? If you try the later please explain it like you would explain it to donkey, very clearly and simply. I'm kinda feeling like a donkey because this doesn't feel like super complex thing to do.
Thanks before hand.
HegemonKhan
24 May 2016, 10:28unfortunately, this is a bit advanced stuff (stuff that seems like it'd be easy to implement, is often not so). You may not want to try to jump into this, as it'll be hard for you to follow along on how this stuff is done.
------
conceptually:
think of List Attributes as like a PE coach's student roster, which he can use, to bark orders to those students. The students aren't physically on/in the roster, only their names but this allows you to issue actions/orders/commands to them.
So, you'll need to add all of the rooms' names that you'd like to be able to travel to, onto/into your Object List Attributes (which can't be done through the GUI~Editor, unfortuantely). depending on your design, this can entail a lot of work and be very complex to setup.
then you'll need scripting (Verbs/Commands/etc) of the 'show a menu' Script and usage of your Object List Attribute with it.
and that's just the gist of the basics of it.
do you want to have all of your 'mirror' warp/teleport Objects having universal choices, or do you want each one with a different set of rooms you can go to? and etc etc etc design questions about exactly what and how you want it set up.
^^^^^^
HK edit: sorry, didn't read your post closely enough, so you want to choose from visited mirrors in various rooms. once you select which mirror you want to go to, one way is to use the built-in 'parent' Attribute to move to the room containing the mirror, otherwise, another method would be to use the 'if/switch' scripting and the 'MoveObject' Script/Function.
--------
here's some links/guides of mine, but they're probably not going to be of help for you:
viewtopic.php?f=18&t=5138 (here's how to do movement without Exits: aka "warping/teleporting")
viewtopic.php?f=18&t=5137 (List and Dictionary Attributes)
also see this link, as it helps with using lists and show menu:
http://docs.textadventures.co.uk/quest/ ... ation.html (character creation, it shows how to use lists and show menu)
^^^^^^^^^^^
http://docs.textadventures.co.uk/quest/guides/ (guides, it's a bit hidden in the doc)
------
conceptually:
think of List Attributes as like a PE coach's student roster, which he can use, to bark orders to those students. The students aren't physically on/in the roster, only their names but this allows you to issue actions/orders/commands to them.
So, you'll need to add all of the rooms' names that you'd like to be able to travel to, onto/into your Object List Attributes (which can't be done through the GUI~Editor, unfortuantely). depending on your design, this can entail a lot of work and be very complex to setup.
then you'll need scripting (Verbs/Commands/etc) of the 'show a menu' Script and usage of your Object List Attribute with it.
and that's just the gist of the basics of it.
do you want to have all of your 'mirror' warp/teleport Objects having universal choices, or do you want each one with a different set of rooms you can go to? and etc etc etc design questions about exactly what and how you want it set up.
^^^^^^
HK edit: sorry, didn't read your post closely enough, so you want to choose from visited mirrors in various rooms. once you select which mirror you want to go to, one way is to use the built-in 'parent' Attribute to move to the room containing the mirror, otherwise, another method would be to use the 'if/switch' scripting and the 'MoveObject' Script/Function.
--------
here's some links/guides of mine, but they're probably not going to be of help for you:
viewtopic.php?f=18&t=5138 (here's how to do movement without Exits: aka "warping/teleporting")
viewtopic.php?f=18&t=5137 (List and Dictionary Attributes)
also see this link, as it helps with using lists and show menu:
http://docs.textadventures.co.uk/quest/ ... ation.html (character creation, it shows how to use lists and show menu)
^^^^^^^^^^^
http://docs.textadventures.co.uk/quest/guides/ (guides, it's a bit hidden in the doc)

XanMag
24 May 2016, 11:03Does mirror A always lead to the same place or is it random? Or can one mirror lead to any other of the players choosing?
What do you mean by 'after a certain point'? After a certain event, do all doors become useless and the only mode of travel are mirrors?
This isn't too hard but I'd need these questions answered first.
What do you mean by 'after a certain point'? After a certain event, do all doors become useless and the only mode of travel are mirrors?
This isn't too hard but I'd need these questions answered first.
HegemonKhan
24 May 2016, 11:06here's a simple brief quick sample game:
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="sample">
<gameid>b073bbfb-0e99-45d3-9786-bb395a6bc6b0</gameid>
<firstpublished>2016</firstpublished>
<author>HegemonKhan</author>
<version>1.0</version>
</game>
<object name="room">
<object name="player">
</object>
<object name="mirror">
<inherit name="mirror_type" />
</object>
</object>
<object name="room2">
<object name="mirror2">
<inherit name="mirror_type" />
</object>
</object>
<type name="mirror_type">
<attr name="warp" type="script">
show menu ("Where to?", this.mirror_list, true) {
if (player.parent = result) {
msg ("You're already at this location, silly.")
} else {
MoveObject (player, result)
}
}
</attr>
<attr name="mirror_list" type="objectlist">
<value>room</value>
<value>room2</value>
</attr>
<attr name="displayverbs" type="simplestringlist">warp</attr>
</type>
<verb>
<property>warp</property>
<pattern>warp</pattern>
<defaultexpression>You can't warp with that.</defaultexpression>
</verb>
</asl>
The Pixie
24 May 2016, 11:08In Quest, there are variables and attributes. They can both be used to store a value (say the location of something, or a name or a list or whatever), but variables only keep the value for the length of the script, then they just disappear.
I would guess you have a script that creates a new string list called MirrorList, and then adds the room names to it. When the script comes to the end, MirrorList disappears because that is what variables do; they are just temporary in Quest. The error is because another script is trying to use MirrorList but cannot find it.
The solution is to put "game." before each MirrorList, so it looks like this:
game.MirrorList
That will make MirrorList an attribute of the game object instead of a variable, so it will last all through the game. You will need to change it where the list is created, whetherever it is added to and whereever it is used. If you miss any you will probably get the same message.
I would guess you have a script that creates a new string list called MirrorList, and then adds the room names to it. When the script comes to the end, MirrorList disappears because that is what variables do; they are just temporary in Quest. The error is because another script is trying to use MirrorList but cannot find it.
The solution is to put "game." before each MirrorList, so it looks like this:
game.MirrorList
That will make MirrorList an attribute of the game object instead of a variable, so it will last all through the game. You will need to change it where the list is created, whetherever it is added to and whereever it is used. If you miss any you will probably get the same message.
Nalcarum
24 May 2016, 11:52XanMag wrote:Does mirror A always lead to the same place or is it random? Or can one mirror lead to any other of the players choosing?
What do you mean by 'after a certain point'? After a certain event, do all doors become useless and the only mode of travel are mirrors?
This isn't too hard but I'd need these questions answered first.
One mirror can lead to any mirror player has discovered, so the later.One mirror would be like a door to a multiple rooms. And after certain point I mean that after certain event I have set flag to the object "player", and all doors have if-statment that if player has the flag, he can't pass through them.
HegemonKhan wrote:
So, you'll need to add all of the rooms' names that you'd like to be able to travel to, onto/into your Object List Attributes (which can't be done through the GUI~Editor, unfortuantely).
That may be my problem. I have tried to create the list using the editor, and I take it from what you sad that it can't be done? So I need to create the list outside the editor and then somehow import it?
As I said, I'm as familiar with coding than a donkey would be. But the mirror-hopping is quite essential to my story, so if it is too advanced I probably must either abandon the story or find another way to create it. If so, any suggestions how I could do it?
The Pixie
24 May 2016, 12:51Try this:

Some explanation. The first line creates your list, MirrorList as an attribute of the player object (see previous post). The next two lines add the room names, obviously you will need to change them to your room names, and perhaps add more.
The large highlighted bit is the menu, using the options from the list we created. You might want to put this into a different script altogether, perhaps one in each mirror.
Inside is the script that runs when a choice is made. First check if a choice was made (if not, then result will be null). The list contains the names of the rooms, so we use GetObject to get the actual room, then move the player there.
Looks like this in code view (and you could paste this into your game).

Some explanation. The first line creates your list, MirrorList as an attribute of the player object (see previous post). The next two lines add the room names, obviously you will need to change them to your room names, and perhaps add more.
The large highlighted bit is the menu, using the options from the list we created. You might want to put this into a different script altogether, perhaps one in each mirror.
Inside is the script that runs when a choice is made. First check if a choice was made (if not, then result will be null). The list contains the names of the rooms, so we use GetObject to get the actual room, then move the player there.
Looks like this in code view (and you could paste this into your game).
player.MirrorList = NewStringList()
list add (player.MirrorList, "store")
list add (player.MirrorList, "lounge")
ShowMenu ("Where to?", player.MirrorList, true) {
if (not result = null) {
room = GetObject(result)
MoveObject (player, room)
}
}
Nalcarum
24 May 2016, 13:27Great, thanks, it's working. Will I copy that same script to all mirrors so they will work the same? When I put it to the game-tab, it showed it in the starting screen and disappeared. I managed to move it into "Use" function of one of the mirrors and it worked fine. ^^ Thank you so much!
Edit: Actually, got it working. I split the code up, put the "Create list" part at the start of the game and "Show Menu" and "Add to List" parts to each mirror.
Edit: Actually, got it working. I split the code up, put the "Create list" part at the start of the game and "Show Menu" and "Add to List" parts to each mirror.
The Pixie
24 May 2016, 14:23Cool!
HegemonKhan
24 May 2016, 18:28nicely done... you seem to be able to work with the code a bit, despite saying you don't understand it, hehe.
----
I shouldn't have lazily said it couldn't be done via the GUI~Editor, as it can as Pixie demonstrated, but there's no direct Object Attribute Type to select as a drop-down button choice, within the GUI~Editor's 'add attribute' to an Object. What Pixie did was to create a String List Attribute, and then in the scripting to use the 'GetObject', to convert the string choice into the Room Object.
You can create Object List Attributes, but you got to do it within the code.
------
since you seem to actually understand the coding a bit...
if you want, you can look into using 'Object Types / Types', as these are quest's Groups/Classes, which you can use to put all your universal mirror stuff into it only once, and then you just add the 'Object Type / Type / Group / Class' to the mirror Objects, via as 'Inherited Attributes'. The other way is to have the scripting to do it for you, which is the least amount of work that you have to do, but it can be confusing and/or possibly slow for quest, but if you got a huge game, you're not going to want to manually do stuff, too much work, lol.
GUI~Editor: Advanced (the left side's 'tree of stuff' ) -> Object Types / Types -> Add -> (set it up as you want)
http://docs.textadventures.co.uk/quest/ ... /type.html
http://docs.textadventures.co.uk/quest/ ... types.html
http://docs.textadventures.co.uk/quest/ ... types.html
here's an example of the concept of Object Type usage:
Not using Object Types... UGH! :
VS
using Object Types... much better! :
----
I shouldn't have lazily said it couldn't be done via the GUI~Editor, as it can as Pixie demonstrated, but there's no direct Object Attribute Type to select as a drop-down button choice, within the GUI~Editor's 'add attribute' to an Object. What Pixie did was to create a String List Attribute, and then in the scripting to use the 'GetObject', to convert the string choice into the Room Object.
You can create Object List Attributes, but you got to do it within the code.
------
since you seem to actually understand the coding a bit...
if you want, you can look into using 'Object Types / Types', as these are quest's Groups/Classes, which you can use to put all your universal mirror stuff into it only once, and then you just add the 'Object Type / Type / Group / Class' to the mirror Objects, via as 'Inherited Attributes'. The other way is to have the scripting to do it for you, which is the least amount of work that you have to do, but it can be confusing and/or possibly slow for quest, but if you got a huge game, you're not going to want to manually do stuff, too much work, lol.
GUI~Editor: Advanced (the left side's 'tree of stuff' ) -> Object Types / Types -> Add -> (set it up as you want)
http://docs.textadventures.co.uk/quest/ ... /type.html
http://docs.textadventures.co.uk/quest/ ... types.html
http://docs.textadventures.co.uk/quest/ ... types.html
here's an example of the concept of Object Type usage:
Not using Object Types... UGH! :
<object name="orc_1">
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="cash" type="int">50</attr>
<attr name="experience" type="int">25</attr>
<attr name="strength" type="int">10</attr>
<attr name="endurance" type="int">10</attr>
<attr name="dexterity" type="int">10</attr>
<attr name="agility" type="int">10</attr>
<attr name="right_hand" type="object">club</attr>
<attr name="drop_list" type="objectlist">
<value>club</value>
<value>life_potion</value>
<value>food</value>
</attr>
</object>
<object name="orc_2">
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="cash" type="int">50</attr>
<attr name="experience" type="int">25</attr>
<attr name="strength" type="int">10</attr>
<attr name="endurance" type="int">10</attr>
<attr name="dexterity" type="int">10</attr>
<attr name="agility" type="int">10</attr>
<attr name="right_hand" type="object">club</attr>
<attr name="drop_list" type="objectlist">
<value>club</value>
<value>life_potion</value>
<value>food</value>
</attr>
</object>
<object name="orc_3">
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="cash" type="int">50</attr>
<attr name="experience" type="int">25</attr>
<attr name="strength" type="int">10</attr>
<attr name="endurance" type="int">10</attr>
<attr name="dexterity" type="int">10</attr>
<attr name="agility" type="int">10</attr>
<attr name="right_hand" type="object">club</attr>
<attr name="drop_list" type="objectlist">
<value>club</value>
<value>life_potion</value>
<value>food</value>
</attr>
</object>
<object name="orc_4">
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="cash" type="int">50</attr>
<attr name="experience" type="int">25</attr>
<attr name="strength" type="int">10</attr>
<attr name="endurance" type="int">10</attr>
<attr name="dexterity" type="int">10</attr>
<attr name="agility" type="int">10</attr>
<attr name="right_hand" type="object">club</attr>
<attr name="drop_list" type="objectlist">
<value>club</value>
<value>life_potion</value>
<value>food</value>
</attr>
</object>
<object name="orc_5">
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="cash" type="int">50</attr>
<attr name="experience" type="int">25</attr>
<attr name="strength" type="int">10</attr>
<attr name="endurance" type="int">10</attr>
<attr name="dexterity" type="int">10</attr>
<attr name="agility" type="int">10</attr>
<attr name="right_hand" type="object">club</attr>
<attr name="drop_list" type="objectlist">
<value>club</value>
<value>life_potion</value>
<value>food</value>
</attr>
</object>
VS
using Object Types... much better! :
<object name=orc_1">
<inherit name="orc_object_type" />
</object>
<object name=orc_2">
<inherit name="orc_object_type" />
</object>
<object name=orc_3">
<inherit name="orc_object_type" />
</object>
<object name=orc_4">
<inherit name="orc_object_type" />
</object>
<object name=orc_5">
<inherit name="orc_object_type" />
</object>
<type name="orc_object_type">
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="cash" type="int">50</attr>
<attr name="experience" type="int">25</attr>
<attr name="strength" type="int">10</attr>
<attr name="endurance" type="int">10</attr>
<attr name="dexterity" type="int">10</attr>
<attr name="agility" type="int">10</attr>
<attr name="right_hand" type="object">club</attr>
<attr name="drop_list" type="objectlist">
<value>club</value>
<value>life_potion</value>
<value>food</value>
</attr>
</type>