Need help creating new verb - Put Down

Suwonian
14 Nov 2012, 11:27
I would like to select an item from my inventory, click "Put Down", and then see a menu appear with a list of containers in the room to choose from. How can I add all the containers in the room to a list using the user interface (i.e. without code view)?

Pertex
14 Nov 2012, 15:56
This is a simple solution to fill a list with container:
container.jpg


I think you will have to expand this function. You should check if the containers are openable or locked or other things

Suwonian
14 Nov 2012, 18:01
This looks very promising; I wish I understood more about it. I believe it is adding objects to the list but I can't get the list to appear as the options in my menu. Whenever I.....
Add new script
Show a Menu
and choose the list I populated, I get an error message which reads Error running script: Unknown menu options type

Within the for each loop, I used a print expressions object to see what was being added to the list
Object: table1
I also used a print expressions mylist to see what was added to the list.
List: Object: table1

Why don't the objects appear when I use Show a Menu?

Pertex
14 Nov 2012, 19:10
Could you post a screenshot of your script or your gamefile?

jaynabonne
15 Nov 2012, 00:42
"show menu" takes either a string list or a string map. You can't pass it an object list (it's unclear what it would show)

You can create a string list instead of an object list as your first step, and then add the object.name to it instead of the object.

Suwonian
15 Nov 2012, 07:52
Thank you Pertex and Jaynabonne. I can now populate a menu with a list of open containers that are present in the room.



The problem I'm having now is moving the object to the container. I tried move object but it seems to require an object as a destination. How would I use the string (stored as "result" by the Show Menu) to indicate the object ?

I've also tried to use the string to change the parent attribute of the object I want to move (see photo below). This removed the object from my inventory but it didn't show up "on" the table. I'm not sure where it went. (side question: Is it position to use a print expression (or other method for debugging) to print an object's current location?)


Pertex
15 Nov 2012, 10:56
use GetObject to get your object by name : http://quest5.net/wiki/GetObject
name.jpg

Suwonian
15 Nov 2012, 11:39
Thank you Pertex. My object now moves to the menu chosen container :)


Suwonian
15 Nov 2012, 14:34
A made a lot of progress today. I used the script, that I set up as a verb for a single object, to create a command. Now, I can easily add the command to any object that I want the player to be able to selectively put down; all I need to do is add the verb, that starts the command pattern, to an object's inventory verbs list which appears under the object's "Object" tab in the GUI.

Sound confusing? Hopefully, the photos below will help. Notice that I used the word "place" to start my command pattern and I added the verb "Place" to the inventory verb list for an object named "Knife".





Now, in game, when I click on "knife" in my inventory, the options "Look at", "Drop", and "Place" appear in the inventory pane. When I click on "Place", a menu pops-up listing the containers (that are in the room and open) and then when I click on one of the places listed in the menu (such as "workbench", the knife moves from my inventory to the the selected place ("workbench").

Why this works: The way I understand it.
Clicking on an object from the inventory pane ("knife") and then a verb from the inventory pane ("Place") is equivalent to typing into the input box the verb and object name ( >place knife ) and hitting enter.

The reasons I did this.
In my opinion, when a user needs to type a command, a lot can go wrong (spelling, alternative words, wrong syntax). By creating menus that are specific to their objects, I can avoid most of these pitfalls and I can help the player understand the range of options that are intended for the objects.

Pertex
15 Nov 2012, 14:50
You should add an if to check if there are container in this room , something like this:

container.jpg

Suwonian
15 Nov 2012, 16:59
Thanks for the advice Pertex. I totally agree; I need to make stronger code. I need to have more stringent tests so it can deal with different situations (such as a room with no containers).

I thought more about it for this code and I feel that there should always be a place to place something so I've added a floor container (surface) to my room (and I'll need to add a floor container to any additional rooms I create).

Suwonian
15 Nov 2012, 17:16
I've changed the code again. I wasn't happy that the menu was displaying the object's name so I changed it so that the menu now displays the object's alias. I've also changed it so that the object list comes from the ScopeReachable() instead of ScopeReachableNotHeld() so that I can place objects in a container that is in my inventory. I've attached the aslx file for those that are interesting in playing around with it.





jaynabonne
16 Nov 2012, 01:42
Attached is a slight modification to what you have. It uses a string dictionary instead of a string list for the menu. The advantage of this is that you can pair up what the user sees (each entry's "value") with what you want to actually use (each entry's "key"). In this case, you can pair up te alias (what the user sees) with the object's name. Sadly, you can't pair it with the object directly... :) The chosen entry's key is returned. So the user picks the alias, and you get the name back.

You can take it or leave it, but it might feel simpler and more straightforward, and it's another Quest tool to add to your bag of tricks.

Suwonian
16 Nov 2012, 04:58
Jaynabonne,

Thank you for the advice. I think the dictionary is by far the better option if I understand it right. With the method I was using, there would be a problem if there were two objects in the room with the same alias.