Menu not working

m4u
26 Aug 2013, 21:41
Hi there,

I have a few menus for the player to choose:
1. aaa
2. bbb

But when I type the number doesn't work, only clicking.

And how can I implement that the player can also type the word?

Thanks,

M4u

jaynabonne
26 Aug 2013, 22:09
If you could post an example of your menu code, it would help. I haven't seen the numbers not work.

And the Quest menu code doesn't support typing the word. If you want to do that, you'll have to write your own menu code (or find someone who will do it for you!)

Rainbow Dash
26 Aug 2013, 22:15
Hi m4u, take a look at my post on status displays and its got some good examples of menus. Although, my menu has become a lot more complicated now. XD

m4u
26 Aug 2013, 23:14
Here is an example when try to break a bed:

</object>
<object name="desk">
<inherit name="editor_object" />
<inherit name="surface" />
<inroomdescription><![CDATA[<br/>****!]]></inroomdescription>
<hidechildren />
<listchildren />
<listchildrenprefix>Wait.. I see something...</listchildrenprefix>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Drop</value>
</inventoryverbs>
<break type="scriptdictionary">
<item key="hammer"><![CDATA[
Screen
msg ("<br/>********!!!")
IncScore ("You broke the desk", 2)
MoveObjectHere (clock)
]]></item>

Rainbow dash, I didn't find your post or it's not related but thanks.

M4u

jaynabonne
26 Aug 2013, 23:44
I don't see a menu here. I think I'm missing something. Can you show where the menu comes into it?

m4u
31 Aug 2013, 16:17
I dont know what else to send...thats all of the code that i see related to the menu, what part of the functions menu handle the numbers?

jaynabonne
31 Aug 2013, 17:23
Let's try it a different way: what does the player type to see this menu, and what are the options in it?

Usually I'd expect some sort of "show menu/ShowMenu" command.

m4u
31 Aug 2013, 17:33
The player types or click a verb. The verb is customized with "Required another object" in the object tab. The menu shows all of the objects on sight and inventory...

jaynabonne
31 Aug 2013, 18:33
Ok, I see. So it's the built-in Quest object "disambiguation" menu, not a menu of yours. I'll see if I can get one of those to come up. Are you using the web player or the desktop player?

HegemonKhan
31 Aug 2013, 20:01
ah, sorry for the confusion that I think we had and with the quest's game terms.

what you're refering to, in quest, it is known as an:

(object) list
~OR
(object) dictionary

these are just a "set~collection~group" of objects, which you can use to choose between or to attach an action~scripting onto it, such as through this coding stuff:

attaching scripting to the object(s):

"foreach" ( http://quest5.net/wiki/Foreach )
"for" ( http://quest5.net/wiki/For )

getting the object that you want from it (the objectlist or objectdictionary):

http://quest5.net/wiki/ObjectListItem
http://quest5.net/wiki/ObjectDictionaryItem

how to make and use "lists" and "dictionaries":

http://quest5.net/wiki/Using_Lists
http://quest5.net/wiki/Using_Dictionaries

-----------------------

if you instead actually want to create a quest "menu" (a popup box with choices to select from during game play), it's:

"show menu" ( http://quest5.net/wiki/Show_menu )

http://quest5.net/wiki/Showing_a_menu
http://quest5.net/wiki/Character_Creation (this utilizes a menu, just another thing to look at, if you want to create~use a menu)

for a concept example of a quest "menu":

What is your race?

// (the popup box)
1. human
2. dwarf
3. elf
4. gnome
5. hobbit~halfling

// you pick (click on) one of them

------------------------

if you want a "menu" but without the popup box, instead being able to type in the number, you can do this:

(jayna can probably code this effect much better than I, but this is only what I can do with code, lol)

foreach (object_x, name_of_your_objectlist) {
-> msg ("1. " + object_x)
-> // (jayna can probably add~create code to increase the number for it, as I'm still working on trying to learn~understand it, lol)
-> // (so that it produces this effect:)
-> // msg ("2. " + object_x)
-> // msg ("3. " + object_x)
-> // etc etc etc
}

msg ("what is your choice?")
get input {
-> // you type in the number of the choices that you want
-> your_choice_x = result
-> // whatever script you want with the below code line:
-> // ObjectListItem (name_of_your_objectlist, your_choice_x)
-> // ~OR~
-> // ObjectDictionaryItem (name_of_your_objectdictionary, your_choice_x)
-> // ~OR~
-> // Do (ScriptDictionaryItem (name_of_your_scriptdictionary, your_choice_x))
-> // ~OR~
-> // Invoke (ScriptDictionaryItem (name_of_your_scriptdictionary, your_choice_x))

m4u
01 Sept 2013, 21:49
Im using the desktop version...Thank you HegemonKhan, that's very useful!

m4u
02 Sept 2013, 20:10
Hi guys, can you check what is wrong with this code?

<mix type="script">
menu = NewStringList()
if (ListContains(ScopeVisible(), a)) {
list add (menu, "a")
}
else if (ListContains(ScopeVisible(), b)) {
list add (menu, "b")
}
else if (ListContains(ScopeVisible(), c)) {
list add (menu, "c")
}
ShowMenu ("What mix it with?", menu, true) {
if (result="b") {
msg ("Oh yea!")
}
else {
msg ("Crap!")
}
}
</mix>

jaynabonne
02 Sept 2013, 20:18
You might want to make your if/else's just be if's. As it is, only one object will be added to the menu, even if there are more than one available.

        if (ListContains(ScopeVisible(), a)) {
list add (menu, "a")
}
if (ListContains(ScopeVisible(), b)) {
list add (menu, "b")
}
if (ListContains(ScopeVisible(), c)) {
list add (menu, "c")
}


I'm also assuming there are objects named "a", "b", and "c". :)

I'm curious to see if the hyperlinks show up for this sample menu.

m4u
02 Sept 2013, 20:33
Yeah, thanks, it worked! But only by typing the number or clicking the word, i'm looking for writing the word...

m4u
02 Sept 2013, 21:14
By the way, any idea about how to fix the numbers? I still have the problem...

jaynabonne
02 Sept 2013, 21:24
I think I had said before - if you want to allow the player to type the word, then you need to write your own menu code. You'd have to print out the choices (perhaps in an output section so you can hide them afterwards) and then use "get input" to read a line of input.

HegemonKhan
02 Sept 2013, 22:08
as Jayna said,

it's either:

"show menu" -> popup box -> you click on the choice in the popup box

~OR~

"get input" -> you have to create~display~(msg) your own "menu list" (no popup box) -> you type in your choice

~OR~

maybe there's a way to code in a way to combine "show menu" and "get input" together, but this is probably beyond my ability, dealing with creating your own custom "core" coding and likely using some advanced coding too.

-----------------------

[HK edit: fixed up my code of small errors~mistakes, lol]

here's a quick sample example of how to do it with the "get input" way:

(you'll have to adjust it though for what you want to do, but it's got the aspects you need)
(for one example, I'm using a STRING list, and not an object list like you are)
(another example, I only have a simple "msg" script, "yes male" or "yes female", you'd want some other action~script done)
(you can add as many items as you want into your list, and it'll apply the correct list number for them, but you got to also add in the scripting for what to actually do with those new items too, lol)
(if you have a long list of items, then you'd want to use "ListItem" or "ObjectListItem" for enacting your script upon that item, and while it would be easier~quicker to just have the person type in the number, I think I could code it so you can also type out the "name" of the item too, for it to work with the "ListItem" or "ObjectListItem", hopefully, I can do so, lol)

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<gender_string_list type="simplestringlist">male;female</gender_string_list>
<start type="script">
test_function
</start>
</game>
<function name="test_function">
x=0
foreach (string_x, game.gender_string_list) {
x=x+1
msg (x + ". " + string_x)
}
msg ("What is your choice?")
get input {
choice_x = result
if (choice_x = "1" or choice_x = "male") {
msg ("yes male")
} else if (choice_x = "2" or choice_x = "female") {
msg ("yes female")
} else {
msg ("you got to type in the correct thing! And~or, you got to have scripts for what to do with those new or extra added items too!")
}
on ready {
show menu ("Do you want to do it again?", split ("yes;no",";"), false) {
if (result="yes") {
test_function
} else if (result="no") {
msg ("you've choosen to stop")
}
}
}
}
</function>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


Try typing in each of these 4 things each time:

1
2
male
female

it should produce:

yes male (for typing in "1" or "male")
yes female (for typing in "2" or "female")

m4u
02 Sept 2013, 23:04
Ok ok i got it, I know now how to do it, thank you very much, but my other question of this post is how to fix the typing of the numbers that should be working by default in quest. As I said before it happens with object requiring another object...

jaynabonne
02 Sept 2013, 23:15
Part of the problem is that I don't know the exact situation. Can you put together a sample program that exhibits the problem? I did a test just now where I added four objects to a room and enabled "use" on one of them, requiring another object. The code is here:

<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="disambigtest">
<gameid>39d4f0d0-254e-48f9-a7d7-0d932f351446</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="chair">
<inherit name="editor_object" />
</object>
<object name="table">
<inherit name="editor_object" />
</object>
<object name="pencil">
<inherit name="editor_object" />
<use />
</object>
<object name="paper">
<inherit name="editor_object" />
</object>
</object>
</asl>


Run the game and type "use pencil". For me, it brings up a menu and I can type "1". It complains that you can't use it that way, because I didn't set up the use verb on that object, but the menu works.

If it doesn't work for you, can you please tell me:
1) What you type that doesn't work
2) What it says and does when it doesn't work.

HegemonKhan
02 Sept 2013, 23:20
I'm not exactly certain of what you mean by~with typing in the numbers, but I'm guess that by using the "use object with~on object" script in the GUI~Editor, it's applying this script: "ListItem"

ListItem (and it's specific types: StringListItem or ObjectListItem): gives an internal number to the objects in the string list or object list:

<object name="player">
-> <inventory type="simpleobjectlist">hat;shirt;pants;gloves;shoes;socks</inventory>
</object>

(lists start internally with ZERO, not one)

internal numbering: (0) hat, (1) shirt, (2) pants, (3) gloves, (4) shoes, (5) socks

so, the core code probably has coding to enable you to type in the number, and it matches (does the script) it up with the same internally numbered item in the list.

THIS IS JUST MY GUESS, jayna can probably answer you with an actual correct answer~explanation, lol.

---------------------

(if you don't mind doing so) could you post your game code or add your game file as an attachment, or some game file or code, which shows how you can type in the numbers, so we can examine it, to understand and respond with an explanation for~to it?

------------------

my coding in my previous post, does something similiar to this, have fun trying it out, hehe.

---------------

HK Edit:

ah, this is something with the "use" core verb (and it is in the GUI~Editor's script choice as: ~"use object on~with object").

I'll let jayna handle this, as I'm not familiar with the core coding stuff yet (I can look at it, but most of it is quite a bit beyond me ability).

I never knew you could type in a number for the "use" core coding (instead of clicking on the popup box' choices)... if you have the Verb set up for it... if I am understanding Jayna's post, lol.

m4u
03 Sept 2013, 19:03
Hi guys, I found the problem is in the MetaLib library, so I asking the Pixie...

jaynabonne
03 Sept 2013, 19:47
Yes, I can see that. There is an override in that library for HandleCommand, which has changed to include menu support. I'm sure he'll get you fixed.