Question on Get Input and If Result
JenniferKline
27 Jun 2017, 23:15Heya all,
Trying to make conversation between NPCs. Right now, I'm trying to work with a system where it's a little like those open world RPGs, i.e Mass Effect where you get a couple of dialogue options or ways of approaching a scenario. I'm still not 100% sure how to put together this in a neat manner, so ideas are totally welcome. I have been considering making it a menu, I know roughly how they work now.
But at the moment my system is the player is greeted by an NPC and they type their response. Not word for words, of course, but the game will set out say, three or four consistent approaches. Hard, Kind, Mischevious or Sarcastic. While I can make those work, I don't know how to make it so a Get input
and if result =
can deal with multiple ways of the same thing.
Wow, worded that great.
Say it will get 'Sarcastic' but not 'sarcastic' or 'sarc' or 'Sarc' or even just 's' or 'S'. Ideally all of them would make suitable responses, as each word starts with a different letter. How can I make it accept multiple inputs for the same result?
Also, is there a neater or easier alternative to the menu for dialogue? So I could have four hyperlinks pop up, say for one dialogue being Hard, Kind, Mischevious or Sarcastic.
and for another Hard, Sexy, Mischevious or Silent
or Rude, Polite, Silent, Weird
.
Of course, it's not impossible for me to make a menu every time I want the player to have to speak to every individual NPC about every individual thing, probably not even that time consuming, but I am guessing there's others with more experience in multiple choice dialogue than me that could chip in.
Edit: Oh! Further question!
When I have menu options, do I have to use them in a menu? Is there a way to use
menulist = NewStringList()
list add (menulist, "male")
And have something along the lines of.
"Are you {menulist, "male"} or {menulist, "female"}"
So I don't have to have a printed menu with numbers each time, but still use the same system?
hegemonkhan
28 Jun 2017, 01:15I think if I'm understanding what you want, there's the 'inline' (hypertext: clickable links in the left big text box during game play):
the 'ShowMenu(xxx)' Function
(not to be confused with the popup window menu function: the 'show menu (xxx)' Function)
game.sex_list = split ("male;female", ";")
ShowMenu ("Are you a ", game.sex_list, false) {
player.sex = result
}
a simple way of handling multiple inputs (if there's not too many of them):
get input {
if (result = "Hard" or result = "Kind" or result = "Mischievious" or result = "Sarcastic") {
player.personality = TYPE_1_PERSONALITY
} else if (result = "Sympathetic" or result = "Angry" or result = "Flirtatious" or result = "Sad") {
player.personality = TYPE_2_PERSONALITY
}
}
however, when you got:
Hard/Kind/Mischevious/Sarcastic
and
Hard/Sexy/Mischevious/Silent
you can NOT do this as they got the same inputs (hard, mischievious), it's just NOT logically/parser-wise possible
only if each of them is a single string (a single item in a list) can it be done:
String/Item_1: Hard, Kind, Mischevious, and Sarcastic
String/Item_2: Hard, Sexy, Mischevious, and Silent
game.personality_type_list = split ("Hard, Kind, Mischevious, and Sarcastic; Hard, Sexy, Mischevious, and Silent", ";")
ShowMenu ("Are you ", game.personality_type_list, false) {
player.personality_type_string_attribute = result
}
// the list's 2 items (and their displayment) are:
// Hard, Kind, Mischevious, and Sarcastic
// Hard, Sexy, Mischevious, and Silent
// and your player attribute will be:
// player.personality_type_string_attribute = "Hard, Kind, Mischevious, and Sarcastic"
// or
// player.personality_type_string_attribute = "Hard, Sexy, Mischevious, and Silent"
hegemonkhan
28 Jun 2017, 01:26P.S.
forgot the question about handling different spellings for inputs:
game.sarcastic_list = split ("s;sarc;sarcastic", ";")
// HOWEVER, do note that you can NOT do this if you got another word with (some of) the same spelling, such as: sad, as they'll both have the 's' spelling option, and thus which did the person mean: 'sad' or 'sarcastic' ??? hence, it's logically impossible. You can't have any shortened spellings which are not unique, as you'll run into this logic parsing issue. 'sarcastic' and 'sad' are unique (distinguishable), but 'sa' (short for sarcastic) and 'sa' (short for sad) are not unique, nor is 's' (short for sarcastic) and 's' (short for sad) unique.
get input {
foreach (item, game.sarcastic_list) {
if (LCase (result) = item) {
player.personality = "sarcastic"
}
}
}
hegemonkhan
28 Jun 2017, 04:32this stuff as you can see, involves using List/Dictionary Attributes and iteration (foreach/for) through the List/Dictionary Attribute's items. The 'alt' (alternative names) text box in the GUI/Editor, is in fact a built-in Stringlist Attribute.
so, you may want to try to understand these more advanced List/Dictionary Attributes (90% of game making is possible through the basic Attributes: booleans/strings/integers/doubles/objects, and the 'if' Script usage. Lists/Dictionaries make up 5% to 9% of the remaining 10% of game making, so if you can, it's really helpful to learn to use Lists/Dictionaries and their iteration), if you don't already understand them, which I try to help with:
http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk
and here's a test game on a system that doesn't use Exits to move around (you got to first 'explore' to discover areas, that you can then select as a 'travel' destination), but do note that this was back when I was first learning this stuff, so the code has some mistakes and flaws in it:
http://textadventures.co.uk/forum/samples/topic/5138/explore-and-travel-code-sample-by-hk
ask if you got any questions on anything
The Pixie
28 Jun 2017, 07:58This is not trivial, and it would be worth considering going down the menu route (which is what Mass Effect does). However, this guide will tell you how to get Quest to recognise phrases in text the player types.
https://github.com/ThePix/quest/wiki/Ask-a-Question
hegemonkhan
28 Jun 2017, 13:51yay, I'm now finally understanding this stuff !!! ... I just need to learn it and memorize/get-used-to the regex commands/symbols. This is defiantely something I need to learn, to improve my quest/game-making abilities, as it's very useful stuff: string parsing controls/handling
(great guide Pixie, especially now that I'm finally able to understand this stuff !! laughs)
The Pixie
28 Jun 2017, 14:52Regexes are used in most languages and the format seems very similar across them all. Quest uses the .NET version, so is the same as Visual Basic and C# among others.
You can try them out here. Try putting ^put (?<object1>.*) (on|in) (?<object2>.*)$
and see what player input will get matched.
http://regexstorm.net/tester
hegemonkhan
29 Jun 2017, 03:56awesome, thanks Pixe!