Menu question

Tomsa
28 Feb 2009, 20:25
I have a question regarding menus. How would I go about creating a menu without the grey pop-up window?

Example:

1. An NPC asks me a question, to which I answer by either typing yes or no.

2. When "yes", you will be presented with a list of five choices, all printed in text and not in the menu window format.

3. When typing one of the listed choices, the appropriate response will follow.



P.S. If anyone here is dabbling with Inform 7, please PM me.

Thanatos
01 Mar 2009, 02:29
There is no need - it does this automatically when you upload it to the site. And if your worried about when people download it, I'm sure they won't mind :)

Redsun
01 Mar 2009, 03:19
Stay away from the pop up menues, they don't look that good create your own menues.

So that when the player types 1 for example the NPC responds accordingly.

so The menu could be in the room wrather then a pop up.

1. Who are you?
2. How do I get there?
3. My name is mooky and now your going to die!
4. Leave

This is just an example, this way you also have more control over
text color, text size, font style etc and it looks so much more
better.

now if the player types 1 and hit enter then the NPC responds to the "Who are you?" question.
You do this by writing a proc using if statements to check if stringholder equals 1, 2, 3 or 4.
Even though these are numbers you must use a string var.

Do you know how to write IF statements?

Tomsa
01 Mar 2009, 11:25
I am not sure I follow...could you clarify how you would set up this procedure and the string variables? Maybe then I would get a better understanding of this particular function.

- Speak to NPC

- NPC responds with following printed text:

1. Who are you?
2. How do I get there?
3. My name is mooky and now your going to die!
4. Leave

- You type one of the numbers.

- Response (procedure using if statements to check if stringholder equals 1, 2, 3 or 4).

How to?

Redsun
01 Mar 2009, 15:04
Sure

So what you want to do is first put in your questions in a proc not directly into the room.

I'll put a piece of my code in here to show how it can be done.


define procedure <charactorcreation>
if ( #pointholderstring# = 1 ) and ( %points% >= 1 ) then {
set <pointholder; 1>
dec <points; 1>
do <charactorcreation2> } else {
if ( #pointholderstring# = 2 ) and ( %points% >= 1 ) then {
set <pointholder; 2>
dec <points; 1>
do <charactorcreation2> } else {
if ( #pointholderstring# = 3 ) and ( %points% >= 1 ) then {
set <pointholder; 3>
dec <points; 1>
do <charactorcreation2> } else {
if ( #pointholderstring# = 4 ) and ( %points% >= 1 ) then {
set <pointholder; 4>
dec <points; 1>
do <charactorcreation2> } else {
if ( #pointholderstring# = 5 ) and ( %points% >= 1 ) then {
set <pointholder; 5>
dec <points; 1>
do <charactorcreation2> } else {
if ( %points% <= 0 ) then msg <|crYou do not have anymore points to use, you have %points%!.|n|nTo begin play simply hit the P key and hit the ENTER key.|n|n|n> else {
if not ( #pointholderstring# = 1 ) or not ( #pointholderstring# = 2 ) or not ( #pointholderstring# = 3 ) or not ( #pointholderstring# = 4 ) or not ( #pointholderstring# = 5 ) then {
msg <|crI do not understand that Letter or number. you have to hit the|n1 thru 5 keys only, no other letters or numbers, so please try again.|n|n|cb|n|n>
do <charactorcreationstart> } } } } } } }
end define

define procedure <charactorcreation2>
if ( %pointholder% = 1 ) then {
inc <playerintel; 1>
msg <|cgYou put 1 point in Intelligence!|nIntelligence up to %playerintel%!|n|cb|n|n|n>
do <charactorcreationstart> } else {
if ( %pointholder% = 2 ) then {
inc <playercharm; 1>
msg <|cgYou put 1 point in Charm!|nCharm up to %playercharm%!|n|cb|n|n|n>
do <charactorcreationstart> } else {
if ( %pointholder% = 3 ) then {
inc <playerview; 1>
msg <|cgYou put 1 point in View!|nView up to %playerview%!|n|cb|n|n|n>
do <charactorcreationstart> } else {
if ( %pointholder% = 4 ) then {
inc <playerdetect; 1>
msg <|cgYou put 1 point in Detect!|nDetect up to %playerdetect%!|n|cb|n|n|n>
do <charactorcreationstart> } else {
if ( %pointholder% = 5 ) then {
inc <playerpilot; 1>
msg <|cgYou put 1 point in Pilot!|nPilot up to %playerpilot%!|n|cb|n|n|n>
do <charactorcreationstart> } } } } }
end define


Now you don't need to do it this way, this is added stuff I used.
This is code from a game I've been working on.

This looks complex only because this code is part of the bigger picture.

Tomsa
01 Mar 2009, 18:43
Well, since the example code did not have a "define game" block, I could not view it in the editor. I do not know ASL yet, because I am a beginner... Are there any more tutorials around that offers similar help to that of the QDK Tutorial?

Elexxorine
01 Mar 2009, 19:31
I threw together a quick exmaple for you. Just save the code as an asl then load it in QDK.
define game <NPC talk>
asl-version <400>
gametype singleplayer
start <room>
game version <1.0>
game author <Elexxorine>

end define

define room <room>
look <Talk to bob to see example npc talking.>

define object <bob>
alias <Bob>
speak do <bobtalk>
end define

end define

define procedure <bobtalk>
msg <Bob says: 'What do you want?'
msg <[1] Who are you?>
msg <[2] How do I get there?>
msg <[3] My name is mooky and now your going to die!>
msg <|i(Any other response to stop talking)|xi>
enter <bobtalkchoise>
if ( #bobtalkchoise# = 1) then do <bobtalk1>
if ( #bobtalkchoise# = 2) then do <bobtalk2>
if ( #bobtalkchoise# = 3) then do <bobtalk3>
if ( #bobtalkchoise# <> 1) and ( #bobtalkchoise# <> 2) and ( #bobtalkchoise# <> 3) then msg <Bob says: 'Nice talking to you.'>

end define

define procedure <bobtalk1>
msg <same stuff as before goes in here and for hte rest of the procedures>
end define

paul_one
01 Mar 2009, 19:44
Hmmm, gotta say I don't like the look of that code...

... Then again, my response is also a mess - but it's a mess that you can easily expand upon (well, easily if you know what's going on).

This is a menu 'system' which allows the user to have STRUCTURED menus (what's more, you can even make them up on the fly if you're good at it!).

The downside?
VERY confusing to use array indexes to map out menus, and also the strings themselves are confusing if you don't know what's going on.
Also, you can't kick off scripts which is bad - only way I can think of doing that would be to look in the string and /try/ to do it that way (I say try because Quest is very limited in this respect).

ANYWAY, load up the game, give it a try out, see what you think.

Menu's are like this:

convo[1000] (STARTING remark with up to 9 questions after that)
convo[1001] (answer to first question from the STARTING point, with up to 9 questions after that)
convo[1002] (answer to second question from the STARTING point, as first question)
convo[1003 or 1004 or 100N] (answer to reletive question from STARTING point)

NOW... Say your first question went into another menu with 9 questions...

convo[1011] (answer to first question, from the sub-menu for first question from starting point...)
convo[1021] (answer to SECOND question, same as directly above entry)

SO, it can be mapped like so:
[1000] -+ [1001] --+ [1011]
| + [1021]
| + [1031]
| + [1041]
|
+ [1002] --+ [1012]
| + [1022]
+ [1003]
+ [1004]


etc.
Hopefully these don't ever cross (I haven't had enough forethought to see if they do or not).
And as always, the code may totally crash your game if you have more then 9 questions in one section (or at any time really, as there's not a massive amount of error checking)..

I think the logic is sound and the code should be at least wobble-proof.

[EDIT]
DAMN, Elex got here before I posted mine!! :)
... Elex, please use select cases instead of those IF's... :P

paul_one
01 Mar 2009, 19:53
hahaha, just don't try taking Bob :D ...
... I seem to remember take <> meaning that the object WASN'T taken!!

... Oh well.

Tomsa
02 Mar 2009, 17:41
Great! This was the examples I was looking for. I will dabble with them later tonight, see if I can make it work. I will tell you what I am writing now. Recently I was reading a tutorial on how to use Inform 7, showing how to make rooms and objects.
http://www.brasslantern.org/writers/how ... orial.html

After completing this, I thought it would be fun to make the exact same example adventure for Quest Pro. In the I7 example, there is a robotic butler called "Robutler" in your room. I thought it would be a nice touch if the butler presented you with a few choices when spoken to.

Elexxorine: Your example wa easy to understand. At least I know what functions I should use know. Regardless if it is the player asking the NPC a bunch of questions or vice versa does not matter right now, since all I wanted to know was how to make nice little menus.

Paul_one: Yeah, your example sure looked messy in the eyes of a beginner, but it was a beautiful kind of mess with lots of possibilities. Once I have mastered Elexxorines example, I shall dabble with yours. :)

paul_one
02 Mar 2009, 17:57
Don't feel obligated.. I guess I tend to show off in my own little way (meaning I write good flexible code, even if it is obfuscated).

.. By the way, YAY, I used obfuscated in a sentence!!

Get back to us if you run into any troubles and we can help - it'll be interesting to see what you can come up with.

Elexxorine
02 Mar 2009, 19:46
Glad I could help. My example can be adapted for any menu system, such as shops. If you need any help with anything specific feel free to ask.