Dialogue help

Mareus
21 Jun 2014, 19:13
So.. I made a little dialogue that looks something like this:
 msg ("'Hello. Can you help me young man?'")
get input {
if (IsRegexMatch ("(yes|of course)", LCase (result))) {
msg ("I am thirsty." , the old man says. "Bring me some water and I shall reveal to you bla bla bla...'")
}
else {
}
}


The problem I am having is that I do not want the conversation to end if I write something that is not handled by the script. For example if I write something unexpected, like: "Who are you old man?", the conversation ends without any explanation and I have to restart the whole conversation from beginning. This is not a problem when you have just a few lines, but imagine having to go through a whole series of dialogue choices only to have it end suddenly without any explanation. Is there a way to add a line that says something like: "Try rephrasing." and then automatically repeating just the last question. I think this would be useful for more complicated dialogues.

Thanks in advance.

HegemonKhan
21 Jun 2014, 21:24
make the scripting that you want to repeat (aka 'loop~call upon~invoke'), as (within) a Function of it's own:

<object name="old_man">
<inherit name="editor_object" />
<attr name="socialize" type="script">
socialize_old_man_function // 'call function' Script
</attr>
<attr name="displayverbs" type="listextend">Socialize</attr>
</object>

<function name="socialize_old_man_function">
msg ("'Hello. Can you help me young man?'")
get input {
if (IsRegexMatch ("(yes|of course)", LCase (result))) {
msg ("I am thirsty." , the old man says. "Bring me some water and I shall reveal to you bla bla bla...'")
}
else {
msg ("Try rephrasing")
wait {
ClearScreen
socialize_old_man_function // 'call function' Script
}
}
}
</function>

Mareus
22 Jun 2014, 00:54
HegemonKhan wrote:make the scripting that you want to repeat (aka 'loop~call upon~invoke'), as (within) a Function of it's own:

<object name="old_man">
<inherit name="editor_object" />
<attr name="socialize" type="script">
socialize_old_man_function // 'call function' Script
</attr>
<attr name="displayverbs" type="listextend">Socialize</attr>
</object>

<function name="socialize_old_man_function">
msg ("'Hello. Can you help me young man?'")
get input {
if (IsRegexMatch ("(yes|of course)", LCase (result))) {
msg ("I am thirsty." , the old man says. "Bring me some water and I shall reveal to you bla bla bla...'")
}
else {
msg ("Try rephrasing")
wait {
ClearScreen
socialize_old_man_function // 'call function' Script
}
}
}
</function>


Thanks for answering, but the script you made does not work.
1. There seems to be a red line that says:
Failed to load script:
msg ("I am thirsty." , the old man says. "Bring me some water and I shall reveal to you bla bla bla...'")

2. So I fixed this by deleting the red line and adding again a new message with the relevant text, but even though I don't see any errors - the script still does not seem to work. I cant find "old_man" within the game. So, assumed that it was because "old_man" was located within my "old man" object, so I moved him manually to my room. Now, I can see him in the game, but when I click on him there is no socialize command and manually typing socialize with old man does nothing either.

3. Other than that, I noticed also that you created a new function called "socialize_old_man_function" and a sub-object called "old_man" within my "old man" object. This sub-object has a new verb "socialize". The thing is that I want to be using the default command "speak to" because I think that is the first thing any player will try. If that doesn't work, I don't think anyone will even try to "socialize". So is there a way to make this run through the default "speak to/talk to/talk with" command that comes built in by default in quest?

4. I remembered this a bit later, but it would also be useful to have a way to exit the conversation by typing "bye" command.

Some final notes: Basically I want to be able to get to special screen that is only for the dialogue with the NPCs - something similar to the old Legend games. I will even add NPC's picture once you type in the "speak to" command, and I don't want the conversation to end just because you might do a typo or try something that is not handled by the script. And if I want to exit the dialogue screen, I want to be able to type "bye" command and that way end the conversation.

Anyway, thanks for trying to help.

Mareus
22 Jun 2014, 18:27
Mareus wrote:

"HegemonKhan"

make the scripting that you want to repeat (aka 'loop~call upon~invoke'), as (within) a Function of it's own:

<object name="old_man">
<inherit name="editor_object" />
<attr name="socialize" type="script">
socialize_old_man_function // 'call function' Script
</attr>
<attr name="displayverbs" type="listextend">Socialize</attr>
</object>

<function name="socialize_old_man_function">
msg ("'Hello. Can you help me young man?'")
get input {
if (IsRegexMatch ("(yes|of course)", LCase (result))) {
msg ("I am thirsty." , the old man says. "Bring me some water and I shall reveal to you bla bla bla...'")
}
else {
msg ("Try rephrasing")
wait {
ClearScreen
socialize_old_man_function // 'call function' Script
}
}
}
</function>


Thanks for answering, but the script you made does not work.
1. There seems to be a red line that says:
Failed to load script:
msg ("I am thirsty." , the old man says. "Bring me some water and I shall reveal to you bla bla bla...'")

2. So I fixed this by deleting the red line and adding again a new message with the relevant text, but even though I don't see any errors - the script still does not seem to work. I cant find "old_man" within the game. So, assumed that it was because "old_man" was located within my "old man" object, so I moved him manually to my room. Now, I can see him in the game, but when I click on him there is no socialize command and manually typing socialize with old man does nothing either.

3. Other than that, I noticed also that you created a new function called "socialize_old_man_function" and a sub-object called "old_man" within my "old man" object. This sub-object has a new verb "socialize". The thing is that I want to be using the default command "speak to" because I think that is the first thing any player will try. If that doesn't work, I don't think anyone will even try to "socialize". So is there a way to make this run through the default "speak to/talk to/talk with" command that comes built in by default in quest?

4. I remembered this a bit later, but it would also be useful to have a way to exit the conversation by typing "bye" command.

Some final notes: Basically I want to be able to get to special screen that is only for the dialogue with the NPCs - something similar to the old Legend games. I will even add NPC's picture once you type in the "speak to" command, and I don't want the conversation to end just because you might do a typo or try something that is not handled by the script. And if I want to exit the dialogue screen, I want to be able to type "bye" command and that way end the conversation.

Anyway, thanks for trying to help.



Come on guys, some help here please. I am really stuck on this.

jaynabonne
22 Jun 2014, 18:53
I think the "old man" that HK included was meant to be an example. You don't need it as such if you already have your own. And make your "speak to" script just call the function he gave you (call it whatever you like if "socialize" isn't it).

The line you fixed did indeed have a problem with mis-quoted quotes, but that was a minor issue.

If you really do want to have some sort of special screen/place for doing conversation, one way to do it (untested) would be to move the participants to a special room where you can control things a bit. Then the "bye" input would simply be a command that takes the player back to where he/she was. And you wouldn't need a loop as such - you'd just be in the conversation as long as you're in the "conversing room".

Mareus
22 Jun 2014, 23:24
jaynabonne wrote:I think the "old man" that HK included was meant to be an example. You don't need it as such if you already have your own. And make your "speak to" script just call the function he gave you (call it whatever you like if "socialize" isn't it).

The line you fixed did indeed have a problem with mis-quoted quotes, but that was a minor issue.

If you really do want to have some sort of special screen/place for doing conversation, one way to do it (untested) would be to move the participants to a special room where you can control things a bit. Then the "bye" input would simply be a command that takes the player back to where he/she was. And you wouldn't need a loop as such - you'd just be in the conversation as long as you're in the "conversing room".


Sorry. I just don't get it. I spent around 5 hours yesterday trying to figure out what all of this means, and I cant seem to get it to work. Even when I made a completely new game and named every object and command like in the mentioned script, it still does absolutely nothing. Can you please try explaining it in more detail, cause I cant make any sense of this?

Specifically the script seems to come in 2 parts and I don't know how to combine them.

PS. I even tried using dialogue with menus as found here:
http://quest5.net/wiki/Conversations

But these scripts seem to have exactly the same problem. Once you choose an option, the menu disappears and you have to restart the whole conversation. So i have no idea how to fix this problem.

I also tried downloading Media:ConvTutorial.aslx from the page to get a better insight into the coding behind it, but I cant seem to download it. I just get "save target" when I right click on the link, instead of "save to". A total bummer...

Mareus
23 Jun 2014, 15:59
Mareus wrote:

"jaynabonne"

I think the "old man" that HK included was meant to be an example. You don't need it as such if you already have your own. And make your "speak to" script just call the function he gave you (call it whatever you like if "socialize" isn't it).

The line you fixed did indeed have a problem with mis-quoted quotes, but that was a minor issue.

If you really do want to have some sort of special screen/place for doing conversation, one way to do it (untested) would be to move the participants to a special room where you can control things a bit. Then the "bye" input would simply be a command that takes the player back to where he/she was. And you wouldn't need a loop as such - you'd just be in the conversation as long as you're in the "conversing room".



Sorry. I just don't get it. I spent around 5 hours yesterday trying to figure out what all of this means, and I cant seem to get it to work. Even when I made a completely new game and named every object and command like in the mentioned script, it still does absolutely nothing. Can you please try explaining it in more detail, cause I cant make any sense of this?

Specifically the script seems to come in 2 parts and I don't know how to combine them.

PS. I even tried using dialogue with menus as found here:
http://quest5.net/wiki/Conversations

But these scripts seem to have exactly the same problem. Once you choose an option, the menu disappears and you have to restart the whole conversation. So i have no idea how to fix this problem.

I also tried downloading Media:ConvTutorial.aslx from the page to get a better insight into the coding behind it, but I cant seem to download it. I just get "save target" when I right click on the link, instead of "save to". A total bummer...



Guys, I am really sorry if I am being a pain, but I really cant figure this out and it is driving me crazy. 12 hours now I have wasted on what I am sure some of you can handle in 3 minutes. All I need is one working example and then I can read the script and learn how to do it for more complicated dialogues. Here is a screenshot of what I am getting and for the love of god... *sigh* please someone HEEELLLLP!
HELP.jpg

Mareus
23 Jun 2014, 16:09
jaynabonne wrote:If you really do want to have some sort of special screen/place for doing conversation, one way to do it (untested) would be to move the participants to a special room where you can control things a bit. Then the "bye" input would simply be a command that takes the player back to where he/she was. And you wouldn't need a loop as such - you'd just be in the conversation as long as you're in the "conversing room".


And I also tried to move the whole conversation into one separate room. That seemed like the best suggestion so far, but the same problem occurs. Every typo that is not handled by the script interrupts the dialogue and I have to restart the dialogue from beginning, so looping seems to be the only way around it.

jaynabonne
23 Jun 2014, 20:36
I'll see if I can put something together. As far as your screen shot goes, I don't even understand where that is coming from. It would help more to be able to see what you have done with your actual source (i.e. post your game!).

jaynabonne
23 Jun 2014, 20:43
Here's a complete game (both attached and inline).

<!--Saved by Quest 5.5.5173.27901-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="dialogue">
<gameid>ce1669a0-d61a-46b0-8d67-ef160139974c</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="old man">
<inherit name="editor_object" />
<inherit name="male" />
<speak type="script">
speak_to_old_man
</speak>
</object>
</object>
<function name="speak_to_old_man">
msg ("'Hello. Can you help me, young man?'")
get input {
if (IsRegexMatch ("(yes|of course)", LCase (result))) {
msg ("\"I am thirsty.\" , the old man says. \"Bring me some water and I shall reveal to you bla bla bla...\"")
}
else {
msg ("Try rephrasing")
wait {
ClearScreen
speak_to_old_man
}
}
}
</function>
</asl>

Mareus
23 Jun 2014, 22:22
jaynabonne wrote:Here's a complete game (both attached and inline).

<!--Saved by Quest 5.5.5173.27901-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="dialogue">
<gameid>ce1669a0-d61a-46b0-8d67-ef160139974c</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="old man">
<inherit name="editor_object" />
<inherit name="male" />
<speak type="script">
speak_to_old_man
</speak>
</object>
</object>
<function name="speak_to_old_man">
msg ("'Hello. Can you help me, young man?'")
get input {
if (IsRegexMatch ("(yes|of course)", LCase (result))) {
msg ("\"I am thirsty.\" , the old man says. \"Bring me some water and I shall reveal to you bla bla bla...\"")
}
else {
msg ("Try rephrasing")
wait {
ClearScreen
speak_to_old_man
}
}
}
</function>
</asl>


Thank you so much for this. Now I understand what I was doing wrong. I am sorry for being a pain, but this was really preventing me from continuing with my game, so I was getting really frustrated. Thanks again, Jay. I wish I had your knowledge.

HegemonKhan
24 Jun 2014, 02:07
Sorry for not better explaining~helping you Mareus, and thanks for helping out Jay, as well. I've been too busy to try to give a better explanation, due to real life (I had a really busy last 2 weeks, sighs).

I know your frustration, it took me a long time to get where I am now (search this forum for: HK's noob help me thread), as I was even worse off than you, I was confused by just all the terms themselves, lol.

Also, it's further frustrating that it takes you (me, I mean) like 8 hours to code something in, and then the good coders here, do the same thing, better: more efficientently (less code lines, less characters), more cleanly~neat~easy to understand, and faster, than your (mine, I mean) code, in like only an hour... Sighs, I'll get there... but right now it's still very slow learning and in writing~crafting code for me, hehe.

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

let me try to explain quest's coding structure, so you can be able to use code given to you

there's two types of stuff in quest's coding:
1. the 'things', which are known as ELEMENTS, and have the 'tags', as shown below:

Beginning tag of the entire game code: <asl>
Ending tag of the entire game code: </asl>
All code must be in-between them, obviously

you can do either horizontal or vertical writing~typing of code, though vertical is easier for code noobs, like me and you. As, horizontal requires you to know coding extremely well, beimg an expert at coding.

horizontal:

<asl>your_entire_mass_of_game_coding</asl>


vertical:

<asl>
your_entire_mass_of_game_coding
</asl>


and the other ELEMENTS:

(All of the ELEMENTS also hold attributes too)

Attributes (holds data): <attr></attr>
Functions (holds scripts): <function></function>
Turnscripts (holds scripts): <turnscript></turnscript>
Timers (holds scripts): <timer></timer>
Objects (holds other objects and attributes): <object></object>
Exits (connects room obejcts): <exit></exit>
Commands (holds scripts): <command></command>
Verbs (holds scripts): <verb></verb>
Object Types (holds attributes): <type></type>
The Game Object (settings and other stuff for your game): <game></game>
Templates (holds message scripts): <template></template>
etc etc etc

now, hopefully you notice the indenting of the 'your_entire_mass_of_game_code' within the vertical structure of the 'asl' tag example above. This is extremely important, to get the indenting correct, as it is the structure of your coding, thus dealing with 'child~parent' relationships and the order that your scripts are executed. This indenting is known as 'nesting'. You must have the correct nesting, both when writing~typing in your code directly, or when working with the GUI~Editor 's features too, such as in adding objects or scripts.

'parent~child' relationships (heirarchy of: containment ~ container structure ~ Folders ~ Directories ~ Objects ~ Scripts ~ etc):

Root (main parent)
Direct Parent (DP)
Indirect Parent (IP)
Direct Child (DC)
Indirect Child (IC)

great grandfather (Root; DP of grandfather; IP of father, you, son, grandson, and great grandson)
grandfather (DC of great grandfather; DP of father; IP of you, son, grandson, and great grandson)
father (IC of great grandfather; DC of grand father; DP of you; IP of son, grandson, and great grandson)
you (you get the idea now)
son (you get the idea now)
grandson (you get the idea now)
great grandson (you get the idea now)

HK
pants with pockets
wallet
$ 1 bill
$ 5 bill

C://
programs
quest

Human Life Taxonomy (biology):
Life Taxonomy: Organic (carbon-based)
Domain Taxonomy: Eukarya (multi-cellular)
Kingdom Taxonomy: Animalia (animals, not: plants, fungus, bacteria, virus, protists)
Phylum Taxonomy: Chordata (symmetry, having a backbone~spine)
Class Taxonomy: Mammalia (having mammary glands; having breasts; milk prodution~secretion)
Order Taxonomy: Primate (Monkeys:tails and Apes:no_tails)
Family Taxonomy: Hominidae (Apes: Humans, Gorillas, Chimps, Orangutans, and Bonobos)
Tribe Taxonomy: Hominini (ape-human)
Genus Taxonomy: Homo (human)
Species Taxonomy: Homo sapien sapien (modern human)


so, now you should understand this:

<asl>
<game>
<attr></attr>
<attr>
</attr>
</game>
<verb>
<attr></attr>
<attr>
</attr>
</verb>
<command>
<attr></attr>
<attr>
</attr>
</command>
<turnscript>
<attr></attr>
<attr>
</attr>
</turnscript>
<object>
<attr></attr>
<attr>
</attr>
<object>
<attr></attr>
<attr>
</attr>
</object>
</object>
</asl>


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

now, you'll notice that the ELEMENT tags often have additional stuff in it themselves:

<asl version="550">
</asl>
<game name="blah">
</game>
<attr name="strength" type="int"></attr>
<function name="blah2" parameters="text_x" type="string">
</function>
etc etc etc

these extra things within the tags themselves, are actually attributes too, but they're pre-set attributes, so you can't just use any attribute within the tags themselves. These attributes within the tags themselves are applied and~or are apart of the ELEMENT itself, as a part of its identity, WHEREAS the attributes held within the ELEMENT block, are just attributes held by the ELEMENT, for your own use. Some of these are required, such as the: name="blah0" and the: version="###", but some of the others, are optional.

----------

Script Nesting:

think of it's order of execution as the exact same as if you were reading an outline:

I. Planets
A. Mercury
B. Venus
C. Earth
1. Continents
a. Asia
(1) Countries
(a) China
2. Oceans
D. Mars
E. Jupitur
F. Saturn
G. Uranus
H. Neptune
I. Pluto
II. Galaxies
A. Spiral Galaxies
1. Milky Way Galaxy


so, scripting works the same way (if using the GUI~Editor, you *MUST* make sure you click on the correct 'add a script' buttons, to get the correct~proper nesting of your scripts), except that it can read (execute) multiple things at once, unlike us humans, so that can make the 'on ready' useful, though only use it when it's needed (usually with~for separating the popups menus with 'show menu' or the typed-in input requests of 'get input', as quest, obviously, can't run two of them at the same time, laughs):

<asl version="540">
// ~ <ref name="English.aslx" />
// ~ <ref name="Core.aslx" />
<game name="testing game stuff">
// attribute code lines
<start type="script">
character_creation_function
</start>
</game>
<object name="room">
<inherit name="editor_object" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<function name="character_creation_function">
msg ("what is your name?")
get input {
player.alias = result
msg ("What is your age?")
get input {
player.age_integer = result
if (player.age_integer >= 0 and player.age_integer < 4) {
player.age_string = "baby"
} else if (player.age_integer >= 4 and player.age_integer < 13) {
player.age_string = "child"
} else if (player.age_integer >= 13 and player.age_integer < 20) {
player.age_string = "teen"
} else if (player.age_integer >= 20) {
player.age_string = "adult"
}
show menu ("What is your gender?", split ("male;female", ";"), false) {
player.gender_string = result
show menu ("What is your race?", split ("human;dwarf;elf;gnome;halfing;giant", ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;ranger;thief;cleric;mage", ";"), false) {
player.class = result
}
}
}
}
}
on ready {
ClearScreen
msg (player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.gender_string + " " + player.race + " " + player.class + ".")
if (player.class = "warrior") {
player.strength = 45
player.agility = 15
player.intelligence = 0
player.spirituality = 0
} else if (player.class = "ranger") {
player.strength = 30
player.agility = 30
player.intelligence = 0
player.spirituality = 0
} else if (player.class = "thief") {
player.strength = 15
player.agility = 45
player.intelligence = 0
player.spirituality = 0
} else if (player.class = "cleric") {
player.strength = 0
player.agility = 0
player.intelligence = 0
player.spirituality = 45
} else if (player.class = "mage") {
player.strength = 0
player.agility = 0
player.intelligence = 45
player.spirituality = 0
}
if (player.gender_string = "male") {
player.strength = player.strength + 5
player.intelligence = player.intelligence + 5
} else if (player.gender_string = "female") {
player.agility = player.agility + 5
player.spirituality = player.spirituality + 5
}
wait {
ClearScreen
msg ("Alias: " + player.alias)
msg ("Age: " + player.age_integer + " (" + player.age_string + ")")
// etc code lines
wait {
ClearScreen
}
}
}
</function>
</asl>

HegemonKhan
24 Jun 2014, 02:34
you can label things however you want (as you can see, I like typing out what something is, and love using the underscores too), but you must match up those same labels used exactly, for them to work in quest (quest's finds and acts upon stuff by what you label it as, so you can't make any typos).

if your labeling of the Object's Name is: old man
then you can't use my labeling of: old_man
quest will see these as two different objects

capitolization matters too:
player.strength = 100
player.Strength = 100
these are two different Attributes for quest

(I've no idea how or why, you got the '____space____' stuff when you copy and pasted... lol)

you'll soon learn that you need to develop a labeling convention (that works for you) for yourself, to help you stay organized and to work faster too.

-----------

<attr name="displayverbs" type="listextend">name_of_your_verb</attr>

is to add a custom made Verb (aka, a script attribute in code writing) as a displayed button and hyperlink, like the other default built-in Verbs, that you can click on during game play.

so, you don't need this line if you're over-writing a default built-in Verb, such as 'speak to', so that's why Jay, removed this code line for you. But, if you wanted to and made your own custom Verb via writing it in as code, then you'd need this code line.