Working with Menus

Avamarine
Hello! Another Quest newbie here. I've been poking around, doing my fair share of research on the program and trying to figure everything out. I've actually been doing fairly decently on my own, however I have run into one particular problem... Menus.

I have it so that the game starts out, you can set your name. But when it comes to setting your gender I wanted to use a Menu where you can choose male or female (to prevent people from typing in things like chicken). I looked at the given tutorials for menus and stringlists and such but for some reason it's just not making sense. This isn't the only scenario wherein I will be wanting to use something like this, so if someone could help explain how to create a working menu for choosing something (for instance I plan on adding a store later), I would be immensely grateful.

Also, and I realize that this might be much to ask, but... Tutorials are great, but I learn best by studying other works. For instance when I taught myself Python and C, I learned more by studying available codes from completed, open-source programs. Would anyone be willing to share one of their completed works with me? I have no intentions of copying or anything devious, it's just how my brain works. I fully understand if not however.

I've been having fun with this program though! Looking forward to getting a good idea on how everything works.

HegemonKhan
yah! this is a first, someone who actually is asking me (who wants) code to be given, haha (you're perfect for me and I for you, lol) :D

first, have you already seen this link (guide~help) ?? :

http://docs.textadventures.co.uk/quest/ ... ation.html
(it's a step by step guide)

http://docs.textadventures.co.uk/quest/ ... _menu.html

if you want to see my own struggle (I used, am using, quest to learn to code for my very first time, hehe) with learning quest and coding back 2-3 years when I first found out about quest and joined this site, hehe:

(at some number of posts into the thread, I am having trouble with 'show menu' ~ 'character creation', myself, asking for help)

viewtopic.php?t=3348

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

in the GUI~Editor :

run as script -> add a~new script -> output -> 'show a menu' Script -> (see below)

Menu text (your question or whatever message): blah
Menu List: use an existing list (Object_name.List_name, or this code-command: split ("option1; option2; option3; etc", ";")
allow player to cancel: self explanatory (able to go back on your choice: yes:true or no:false)
// automatically (hidden from you), the quest engine sets this: result = your_selected_choice
-> then, -> add a~new script -> (do whatever script, but see below)

for character creation menus, you'll want to choose this script:

-> then, -> add a~new script -> variables -> 'set a variable or attribute' Script -> (see below)

// conceptually (algebraic substitution): Object_name.Attribute_name = result = your_selected_choice -> Object_name.Attribute_name = your_selected_choice

Object_name.Attribute_name = result

examples:

player.gender_string = result
// ( I use 'gender_string' of my Attribute_name, because, this is my own personal labeling system, hehe, and because 'gender' and 'article' are already used for grammer: 'he~she~it' and 'him~her~them', and I don't want to over-write this default feature, which would happen if I used 'gender' for the Attribute_name)

player.race = result
player.class = result

in code, it looks like this:

// no existing list:
show menu ("What is your gender?, split ("male;female", ";"), false) {
// I would select 'male'
player.gender_string = result
msg ("You are a " + player.gender_string + ".")
// outputs: You are a male.
}

// an existing list (example is of creating~setting the list immediately before the 'show menu' script block runs, lol):
game.gender_stringlist = split ("male;female", ";")
show menu ("What is your gender?", game.gender_stringlist, false) {
// I would select 'male'
player.gender_string = result
msg ("You are a " + player.gender_string + ".")
// outputs: You are a male.
}


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

Coding:

Attributes:

Object_name.Attribute_name = Value_or_Expression

Examples:

String Attributes:

(the Value must have quotes, or for an Expression, the textual parts must have quotes)

player.gender_string = "female"
orc.gender = "male"
HK.gender_string = "male"
HK.hair_color = "dark brown"
HK.hair_color_string = "dark brown"
player.y = "x"
player.y_string = "1"

Static Expression:
HK.greeting = "Hi, my name is HK, what is your name?"

Dynamic Expression (I'll help you with these later, they're confusing unless you know the trick, hehe):

// player.alias = "HK"
// player.gender_string = "male"
// player.race = "human"
// player.class = "warrior"
player.appearance_description_string = player.alias + " is a " + player.gender_string + " " + player.race + " " + player.class + "."
// outputs: HK is a male human warrior.

// player.alias = "ilyena"
// player.gender_string = "female"
// player.race = "elf"
// player.class = "sorceress"
player.appearance_description_string = player.alias + " is a " + player.gender_string + " " + player.race + " " + player.class + "."
// outputs: ilyena is a female elf sorceress.

Integer (int) Attributes:

player.strength = 100
player.y = 5

Double (Float~Floating Point~Decimals):

player.strength = 19.482

Boolean Attributes:

orc.dead = false
orc.dead = true
player.flying = false
player.flying = true

Object Attributes:

(NO quotes on the Value)

player.right_hand = sword
player.left_hand = shield

List (Stringlist and Objectlist) Attributes:

HK.favorite_color_stringlist = split ("black;red", ";")
HK.toys_objectlist = split ("ball;computer_game;action_figures", ";")

etc Attribute Types (Dictionaries, and etc)

----------

i'm tired... see my other posts... I go into more detail on 'Attributes' ( ' set a variable or attribute ' Script) and the 'if' Script, the 2 SUPER Scripts for doing 90% of everything that you want to do in your game.

HegemonKhan
oops... here's a full game code for you:

(most posted code is extremely basic, so it surely falls under public domain, and those who're pro coders, wouldn't post their amazing code anyways)

*anyone and everyone may use this code, and no credit is needed to be given at all, this is fully free for public usage*

(you may need to generate a new 'gameid' String Attribute algorithm-generated unique string, ask if you need help)

(showing both methods for using a List in the 'show menu' Script blocks)

create a new game, go into code view (of the entire game code) or just open up your game file with notepad, wordpad, or notepad++ ( http://notepad-plus-plus.org/ ), highlight and delete the entire code, then click on 'select all' here below, copy it, and then paste it into your game file, save, and then play it (hopefully, I got no errors and it works~plays, lol).

quest uses 'XML' (eXtensisble Markup Language) as its programming language (and can use JS too): if you use notepad++, at the top bar, under languages, choose 'XML'.

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="xxx">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<attr name="race_stringlist" type="simplestringlist">human;dwarf;elf;gnome</attr>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
show menu ("What is your gender?", split ("male;female", ";"), false) {
player.gender_string = result
show menu ("What is your race?", game.race_stringlist, false) {
player.race = result
show menu ("What is your class?", split ("warrior;thief;cleric;mage", ";"), false) {
player.class = result
wait {
msg (player.alias + " is a " + player.gender_string + " " + player.race + " " player.class + ".")
}
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>

The Pixie
That first link HK gives is probably all you need.

By the way, there are two command to show a menu. Use "show menu" to bring up a dialogue box or "ShowMenu" to have the menu embedded in the game text (it disappears once the choice is made).

Avamarine
@HK Aaah, thank you so much. I'm looking over the code now and seriously, you have no idea how much it's helping. Really, I can look at tutorials and such but without actually -seeing- a working game and getting to mess with the code, it doesn't do too much for me and takes me forever to figure out. I really appreciate what you've offered here =)

@Pixie Yeah, I did see that first link and looked at it but like I said tutorials only go so far for me for some reason, it's just how my brain works. But I will have this open and take another look at it, after poking around HK's code and it should help make more sense.

HegemonKhan
most new people here, are non-coders, so for them, the tutorial and guides (the 'how to' section in the wiki) are great as they show how to do the stuff in~with the GUI~Editor.

whereas, you get code help within the forum (as it's faster to post~write: copy n paste), than trying to make a step by step post going through~using the GUI~Editor.

The 'library+code samples' forum, is more code-oriented, I think, but it does have some GUI~Editor help too.

you can also search for my posts, as I'm always giving code help, which you can study from, hehe.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums