Conversation Help

Spindraft
28 Dec 2013, 16:52
This is public posting of a PM that I believe is beneficial to all

Conversation Help

Sent: Thu Dec 26, 2013 10:42 pm
From: HegemonKhan
To: Spindraft

ah, if you want help with dialogue~conversations:

there's many ways of crafting them...

the built-in "Ask" function is a bit rigid, (as best I understand it ~ I haven't really worked with it ~ and when I briefly did, I had trouble understanding it ~ though this was a long time ago ~ I've been getting much better at coding ~ from coming from no coding beginnings anyways, lol), as it is basically a "yes=true~no=false" Boolean system (I'm just lazily doing this from memory, so this may be way off, lol):

conceptually, an example:

msg ("Are you a male?")
(you type in: "yes" or "no" ~ or you select from the popup menu window ~ not sure how it runs, lol)
// the "ask" function automatically sets: result = (user's typed in input or selected choice from the popup menu window)
// "yes" = true
// "no" = false
if (result=true) {
-> msg ("indeed, you're a male.")
-> msg ("as a male, you have an extra amount of strength")
-> player.strength = player.strength + 1
} else if (result=false) {
-> msg ("No, you're not a male. You're a female instead.")
-> msg ("as a female, you have an extra amount of agility")
-> player.agility = player.agility + 1
}


as you can see, being limited to a "yes~no" choice is a bit limiting in what your "question" topic (and it's and your response) is.

--------

since it feels like you're new to quest and to coding (if I may be so foolish to guess upon lol), you'll need to understand the basics first, before I can really help, as this (my help) will likely be too confusing for you to follow without a general understanding of quest's basics, so I'd suggest (even if it is boring and~or simple for you):

1. going through the tutorial fully, until you understand most of it well ( http://quest5.net/wiki/Tutorial )

2. start off with understanding, and creating~crafting your own (even if it is only a basic one matching~copying the link's coding without having to look at it for reference): "character creation" ( http://quest5.net/wiki/Character_Creation )

3. with being able to do the "character creation", now you're ready to jump into trying to understand conversations and their crafting of them, and here's many links (resources) for you to study from and~or to use, as there's many ways to craft conversations (as there's many types of conversations):

01. http://quest5.net/wiki/Ask
02. http://quest5.net/wiki/Switch (very useful for conversations)
03. http://quest5.net/wiki/Custom_commands
04. http://quest5.net/wiki/If (tied for #1 most powerful script, lol)
05. http://quest5.net/wiki/Using_Lists
06. http://quest5.net/wiki/Using_Dictionaries (very useful for conversations, but it is more advanced as dictionaries are harder to grasp, than are lists or the "switch" function)
07. http://quest5.net/wiki/GetRandomInt
08. http://quest5.net/wiki/Show_menu (if you don't mind its popup menu window ~ it's a simple way to provide choices to choose from)
09. http://quest5.net/wiki/Showing_a_menu
10. http://quest5.net/wiki/Ask_a_question
11. http://quest5.net/wiki/Conversations
12. http://quest5.net/wiki/Dynamic_Menus_for_Conversations
13. http://quest5.net/wiki/A_Hint_System
14. http://quest5.net/wiki/Hs-addingquestion1
15. http://quest5.net/wiki/Hs-case
16. http://quest5.net/wiki/Hs-asktell
17. http://quest5.net/wiki/Hs-multiple
18. viewtopic.php?f=18&t=3909
19. viewtopic.php?f=18&t=3179
20. viewtopic.php?f=18&t=2643

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

and here's good ("required" lol ~ extremely useful) general resources (links) for you:

1. http://quest5.net/wiki/Main_Page
2. http://quest5.net/wiki/Tutorial
3. http://quest5.net/wiki/How_to
4. http://quest5.net/wiki/Category:All_Fun ... t_Commands (the "coding bible" of quest, lol: page 1, range: A-S)
5. http://quest5.net/w/index.php?title=Cat ... h#mw-pages (the "coding bible" of quest, lol: page 2, range: S-Z)
6. index.php
7. viewforum.php?f=18

enjoy :D

------

and feel free to ask me anything, I'll be glad to help

and we can just jump right into learning conversations too, but it'll be very hard for me, if you don't grasp the basics of quest yet, lol.

----------

also, it would be helpful (and useful) to make a thread in the forum called "conversation help thread" or something to that effect, as many people would appreciate such a thread, as this is a big aspect~element of most games, lol. That way, everyone can see and use our posts, and pms are a bit harder to deal with then posting on the forum, lol.

Spindraft
28 Dec 2013, 16:52
conversation help 2

Sent: Thu Dec 26, 2013 10:56 pm
From: HegemonKhan
To: Spindraft

here's some code to look at (or games to test out ~ though you'll have to convert it for your version of quest, as these are from older versions of quest):

Code: Select all<!--Saved by Quest 5.3.4762.29157-->
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
<hint_list type="list">null_hint</hint_list>
<autodisplayverbs type="boolean">false</autodisplayverbs>
<pov type="object">player</pov>
<start type="script">
character_creation
</start>
<hint_dict type="scriptdictionary">
<item key="doormat_hint">
msg ("Try to pull the doormat. Type in: pull doormat")
</item>
</hint_dict>
</game>
<object name="homeyard">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="editor_player" />
<drop type="boolean">false</drop>
<displayverbs>Look at</displayverbs>
<inventoryverbs>Look at; Use; Drop</inventoryverbs>
</object>
<object name="guide">
<inherit name="editor_object" />
<drop type="boolean">false</drop>
<displayverbs>Look at; Hint</displayverbs>
<inventoryverbs>Look at; Use; Drop</inventoryverbs>
<hint type="script">
show menu ("Hint about what?", game.hint_list, false) {
switch (result) {
case ("null_hint") {
msg ("No hints are available")
}
case ("doormat_hint") {
msg (ScriptDictionaryItem (game.hint_dict,"doormat_hint"))
}
}
}
</hint>
</object>
<exit name="to_frontyard" to="frontyard" />
</object>
<object name="frontyard">
<inherit name="editor_room" />
<object name="doormat">
<inherit name="editor_object" />
<drop type="boolean">false</drop>
<displayverbs>Look at</displayverbs>
<pull type="script">
MakeObjectVisible (frontdoorkey)
msg ("You found a key under the doormat")
</pull>
<look type="script">
list add (game.hint_list, "doormat_hint")
msg ("Your guide has a new hint for you now")
</look>
</object>
<object name="frontdoorkey">
<inherit name="editor_object" />
<alias>key</alias>
<drop />
<take />
<visible type="boolean">false</visible>
</object>
<exit name="to_homeyard" to="homeyard" />
</object>
<turnscript name="game_turns">
<enabled />
<script>
if (frontdoorkey.parent = player) {
msg ("You've won the game!")
finish
}
game.turns = game.turns + 1
</script>
</turnscript>
<verb>
<property>hint</property>
<pattern>hint</pattern>
<defaultexpression>"You can't hint " + object.article + "."</defaultexpression>
</verb>
<function name="character_creation">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female",";"), false) {
player.gender = result
show menu ("What is your race?", split ("american;european;african;asian",";"), false) {
player.race = result
show menu ("What is your eye color?", split ("blue;green;hazel;amber;brown",";"), false) {
player.eye_color = result
show menu ("What is your hair color?", split ("yellow;orange;red;brown;black;grey;white",";"), false) {
player.hair_color = result
show menu ("What is your skin color?", split ("white;light;tan;dark;red;brown;black",";"), false) {
player.skin_color = result
show menu ("What is your maturity?", split ("adult;teen;child",";"), false) {
player.maturity = result
msg ("What is your age?")
get input {
player.age = result
msg (" - " + player.age)
msg (player.alias + " is a " + player.age + " year old " + player.gender + " " + player.race + " " + player.maturity + " with " + player.eye_color + " eyes, " + player.hair_color + " hair, and " + player.skin_color +" skin.")
wait {
ClearScreen
}
}
}
}
}
}
}
}
}
</function>
</asl>


Code: Select all<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="StringDicTest">
<gameid>490059fa-4154-4263-afa3-33dab1095527</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="npc">
<inherit name="editor_object" />
<conversation type="stringdictionary">1 = A;2 = B;3 = C</conversation>
<speak type="script">
msg (StringDictionaryItem (this.conversation , ToString (GetRandomInt (1,3))))
</speak>
</object>
</object>
</asl>


Code: Select all<!--Saved by Quest 5.2.4515.34846-->
<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<start type="script">
question1
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<answer1>HK</answer1>
</object>
</object>
<function name="question1">
msg ("To proceed, you must answer the question correctly")
msg ("What is my name? Answer: HK")
get input {
msg (result)
if (player.answer1 = result) {
msg ("You got the answer right, you may proceed")
}
else {
msg ("Wrong answer, try again")
question1
}
}
</function>
</asl>


Code: Select all<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>eef801a1-4e6b-4b0a-bdbf-8f3ecfa8389c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns=</statusattributes>
<start type="script">
msg ("Important Note:")
msg ("Type in: help")
</start>
</game>
<object name="homeland">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="grassland">
<inherit name="editor_room" />
</object>
<object name="plains">
<inherit name="editor_room" />
</object>
<object name="desert">
<inherit name="editor_room" />
</object>
<object name="tundra">
<inherit name="editor_room" />
</object>
<object name="swampland">
<inherit name="editor_room" />
</object>
<object name="mountains">
<inherit name="editor_room" />
</object>
<object name="forest">
<inherit name="editor_room" />
</object>
<object name="wasteland">
<inherit name="editor_room" />
</object>
<object name="coastland">
<inherit name="editor_room" />
</object>
<object name="hills">
<inherit name="editor_room" />
</object>
<command name="help_command">
<pattern>help</pattern>
<script>
help_function
</script>
</command>
<command name="explore_command">
<pattern>explore</pattern>
<script>
explore_function
</script>
</command>
<command name="travel_command">
<pattern>travel</pattern>
<script>
travel_function
</script>
</command>
<object name="data_object">
<inherit name="editor_object" />
<travel_string_list type="simplestringlist">homeland</travel_string_list>
<homeland_events_string_list type="simplestringlist">grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery</homeland_events_string_list>
<homeland_events_script_dictionary type="scriptdictionary">
<item key="grassland_discovery">
list add (data_object.travel_string_list, "grassland")
msg ("You've discovered the grassland! Now, you can travel to the grassland and explore it!")
</item>
<item key="plains_discovery">
list add (data_object.travel_string_list, "plains")
msg ("You've discovered the plains! Now, you can travel to the plains and explore it!")
</item>
<item key="desert_discovery">
list add (data_object.travel_string_list, "desert")
msg ("You've discovered the desert! Now, you can travel to the desert and explore it!")
</item>
<item key="tundra_discovery">
list add (data_object.travel_string_list, "tundra")
msg ("You've discovered the tundra! Now, you can travel to the tundra and explore it!")
</item>
<item key="swampland_discovery">
list add (data_object.travel_string_list, "swampland")
msg ("You've discovered the swampland! Now, you can travel to the swampland and explore it!")
</item>
<item key="forest_discovery">
list add (data_object.travel_string_list, "forest")
msg ("You've discovered the forest! Now, you can travel to the forest and explore it!")
</item>
<item key="mountains_discovery">
list add (data_object.travel_string_list, "mountains")
msg ("You've discovered the mountains! Now, you can travel to the mountains and explore it!")
</item>
<item key="hills_discovery">
list add (data_object.travel_string_list, "hills")
msg ("You've discovered the hills! Now, you can travel to the hills and explore it!")
</item>
<item key="wasteland_discovery">
list add (data_object.travel_string_list, "wasteland")
msg ("You've discovered the wasteland! Now, you can travel to the wasteland and explore it!")
</item>
<item key="coastland_discovery">
list add (data_object.travel_string_list, "coastland")
msg ("You've discovered the coastland! Now, you can travel to the coastland and explore it!")
</item>
</homeland_events_script_dictionary>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
game.turns = game.turns + 1
</script>
</turnscript>
<function name="help_function">
msg ("Type 'explore' to explore your area.")
msg ("Type 'travel' to travel to different areas.")
</function>
<function name="explore_function"><![CDATA[
switch (game.pov.parent) {
case (homeland) {
result_1 = ListCount (data_object.homeland_events_string_list) - 1
if (result_1 >= 0) {
result_2 = StringListItem (data_object.homeland_events_string_list,GetRandomInt(0,result_1))
invoke (ScriptDictionaryItem (data_object.homeland_events_script_dictionary,result_2))
on ready {
foreach (item_x, split ("grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery",";")) {
if (result_2 = item_x) {
list remove (data_object.homeland_events_string_list, result_2)
}
}
}
} else {
msg ("There seemingly is nothing left to explore in this area.")
}
}
}
]]></function>
<function name="travel_function">
show menu ("Where do you wish to travel?",data_object.travel_string_list,false) {
if (not game.pov.parent = GetObject (result)) {
game.pov.parent = GetObject (result)
} else {
msg ("You are already at this area.")
ask ("Try again?") {
if (result=true) {
travel_function
} else {
msg ("You realize that you need to discover a new area to travel to first, before you can travel to that place.")
}
}
}
}
</function>
</asl>
HegemonKhan Posts: 569Joined: Thu Dec 06, 2012 2:11 am

Spindraft
28 Dec 2013, 16:53
conversation help 3

Sent: Fri Dec 27, 2013 12:54 am
From: HegemonKhan
To: Spindraft



spindraft wrote:I get the gist of this, the problem is I have trouble trying to convert it out of the whole yes/no, male/female type of question. This is how I was trying to rewrite it, as you can see I want to present a series of responses, so- the player asks the NPC if there is an exit. Base on this question there would be a number of choices presented to the player such as "Is that all you are looking for?" I may be able to help you, are your intentions sound?" and so on.


you can expand (make more complex) upon this code, by adding in your basic "if" scripts and etc...

also, for scripting acting upon any selected Objects or Exits, you'd first need to use: "GetObject" or "GetExitByName" or "GetExitByLink"

here's some coding for you, between these two codings, you got all the aspects involved with conversation code crafting:

(though this may be very difficult for you to understand if you're new to quest and~or especially to coding and its coding logic, feel free to ask if you got any questions or can't understand anytthing, and I'll do my best to help and~or explain it to you)

Code: Select all<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d67ec73f-f879-4911-9d88-c02ea527c534</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="wise_owl_npc">
<inherit name="editor_object" />
<alias>Wise Owl</alias>
<displayverbs type="stringlist">
<value>Inquire</value>
</displayverbs>
<inquire type="script">
show menu ("What do you wish to inquire about?", global_data_object.inquire_topics_string_list, false) {
invoke (ScriptDictionaryItem (global_data_object.inquire_topics_script_dictionary, result))
}
</inquire>
</object>
</object>
<object name="global_data_object">
<inherit name="editor_object" />
<inquire_topics_string_list type="stringlist">
<value>princess</value>
<value>sword</value>
<value>dragon</value>
</inquire_topics_string_list>
<dragon_topics_string_list type="stringlist">
<value>weakness</value>
<value>location</value>
</dragon_topics_string_list>
<inquire_topics_script_dictionary type="scriptdictionary">
<item key="princess">
msg ("The princess has been captured by the dragon. Rescue her, and the King will wed thee to her, as his heir to his throne and kingdom! You'll become the new king of this land!")
</item>
<item key="sword">
msg ("Ah the legendary dragon slayer sword, magically forged... and guarded by a powerful sorcerer...")
</item>
<item key="dragon">
show menu ("What about the dragon do you wish to know?", global_data_object.dragon_topics_string_list, false) {
invoke (ScriptDictionaryItem (global_data_object.inquire_topics_script_dictionary, result))
}
</item>
<item key="weakness">
msg ("Only the legendary dragon slayer sword can pierce its adamantium scales and thus kill it")
</item>
<item key="location">
msg ("within the volcano in the lava scorched wasteland far to the eastern edge of this world")
</item>
</inquire_topics_script_dictionary>
</object>
<verb name="inquire">
<property>inquire</property>
<pattern>Inquire</pattern>
</verb>
</asl>


and

Code: Select all<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>eef801a1-4e6b-4b0a-bdbf-8f3ecfa8389c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns=</statusattributes>
<start type="script">
msg ("Important Note:")
msg ("Type in: help")
</start>
</game>
<ob

Spindraft
28 Dec 2013, 16:54
Re: conversation help 4

Sent: Fri Dec 27, 2013 9:13 pm
From: HegemonKhan
To: Spindraft

"Switch" (a "Multiple Ifs" function) is convenient (has a nice clear organizational structure~design), but it is less functionally useful~powerful than the "If" function itself.

for example (this is hard for me to explain however in words or to come up with good examples):

with "If" I can do this:

if (result=true) {
}

if (result = 1 or result = 5 or result = 10) {
}

and etc "if (EXPRESSIONS) { script }"

whereas, with "Switch", I can not do so.

-----

switch (game.pov.radiation_level) {
-> case ("25") {
->-> msg ("you're just mildly sun-burned, it's not that big of a deal.")
-> }
-> case ("75") {
->-> msg ("your skin has been mutated into mud, sliding right off your body on its own, or when you itch~rub yourself, taking your skin right off your body")
-> }
}


is the same as (conceptually):

if (HasInt (game.pov.radiation_level) = true) { // I tried to make this as code viable as possible, lol
-> if (game.pov.radiation_level=25) {
->-> msg ("you're just mildly sun-burned, it's not that big of a deal.")
-> } else if (game.pov.radiation_level=75) {
->-> msg ("your skin has been mutated into mud, sliding right off your body on its own, or when you itch~rub yourself, taking your skin right off your body")
-> }
}-

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

basically, if you can use a "switch" and if its better to use depending on what you want done, than use "switch", otherwise, just use lots of "Ifs (and Else Ifs and Elses)".

for example of where "switch" won't work, and even if it could, it's still better to use lots of "Ifs":

two parts of my combat coding (thanks to Pertex' combat code and his help with me making one of my own):

Code: Select allCode that is "Checking" if I can engage in fighting the monster or not:

if (enemy=null) {
msg ("There seemingly is no " + text + " here.")
} else if (not check_reachable_function (enemy) = true) {
msg ("There seemingly is no " + enemy.alias + " here.")
} else if (not DoesInherit (enemy,"character_object_type")) {
msg (enemy.alias + "is seemingly not something that you can battle.")
} else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is seemingly not something that you can battle.")
} else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
} else {
battle_sequence_function (self,enemy)
}

and

Code: Select allThe Player's "Attack" battle choice coding (checking if the player will deal damage or not, and if yes, then the damage mechanic equations~formulas):

  case ("Attack") {
self_attack_failed = false
if (RandomChance (GetInt (enemy,"agility") - GetInt (self,"speed")) = true) {
msg (enemy.alias + "evaded your attack!")
self_attack_failed = true
self.defending = false
} else if (RandomChance (GetInt (enemy,"dexterity") - GetInt (self,"agility")) = true) {
msg (enemy.alias + "parried your attack!")

Spindraft
28 Dec 2013, 16:54
conversation help 5

Sent: Fri Dec 27, 2013 2:19 am
From: HegemonKhan
To: Spindraft

built-in "randomization" function:

(there's also the "dice" functions if you prefer this "D&D" method of getting a "random" value)

(and there's: "RandomChance" function ~ RandomChance (Value) ~ for example of how it works: if the Value=75, then you got a 75% chance of it being "true", ie of it triggering your following script:

if (RandomChance (75)=true) {
// you got a 75% or 3/4 chance of your "card" being a six
-> msg ("the card is a six")
}

if (RandomChance (75)=false) {
// you got a 25% or 1/4 chance of your "card" being a six
-> msg ("the card is a six")
}

if (RandomChance (25)=true) {
// you got a 25% or 1/4 chance of your "card" being a six
-> msg ("the card is a six")
}

if (RandomChance (25)=false) {
// you got a 75% or 3/4 chance of your "card" being a six
-> msg ("the card is a six")
}


... )

result = GetRandomInt (1,5) // quest game engine will "randomly" select amongst: 1, 2, 3, 4, or 5
-> switch (result) {
->-> case ("1") {
->->-> // whatever script you want, for example: msg ("about the dragon")
->-> }
->-> case ("2") {
->->-> // whatever script you want, for example: msg ("about the princess")
->-> }
->-> case ("3") {
->->-> // whatever script you want, for example: msg ("about the treasure")
->-> }
->-> case ("4") {
->->-> // whatever script you want, for example: msg ("about the dragon slayer sword")
->-> }
->-> case ("5") {
->->-> // whatever script you want, for example: msg ("about the etc...")
->-> }
-> }
}

HegemonKhan
28 Dec 2013, 23:13
the tags for the "code box" (which is useful in these posts as it allows for horizontal and vertical scrolling, maintains your indenting~spacing ~ such as for your game coding, has an easy to use "select all" hyperlink button for highlighting and thus copy and pasting, and the box stays small) is:

this is the code box


[code.](your text)[/code.]

[code.]this is the code box[/code.]

but without the "." 's in the code brackets

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

and here's the tags for a "quote box" too:

HK wrote:this is a quote box


[quote.="Name_of_Author"](the quote)[/quote.]

[quote.="HK"]this is a quote box[/quote.]

again, without the "." 's in the quote brackets

enjoy :D

Spindraft
29 Dec 2013, 01:06
Sorry Hegemon, right about the time I moved these posts over by full copy my father-in-law calls with major comp issues in Alabama; spent all day back and forth about that. Figured I would straighten this out when I got the time. You like.

Spindraft
29 Dec 2013, 01:11
You know coding better than I, as the Command calls within the text is still beyond me, but...

you can also "call upon" functions and scripts (though it's easier to use functions, so I'm just going to show you how to do it with functions) too:

for example:

Code: Select all<game name="blah">
// blah scripts ~ code lines
<start type="script">
character_creation_function
</start>
</game>

<function name="character_creation_function">
alias_character_creation_function
on ready {
age_character_creation_function
on ready {
gender_character_creation_function
on ready {
// etc functions
}
}
}
</function>

<function name="alias_character_creation_function">
msg ("What is your name?")
get input {
game.pov.alias=result
}
</function>

<function name="age_integer_character_creation_function">
msg ("What is your age?")
get input {
if (IsInt (result) = true) {
game.pov.age_integer = ToInt (result)
on ready {
age_string_character_creation_function
}
} else if (IsInt (result) = false) {
msg ("Please type in a number for your age.")
age_integer_character_creation_function
}
}
</function>

<function name="age_string_character_creation_function"><![CDATA[
if (game.pov.age_integer < 0) {
game.pov.age_integer = 0
}
if (game.pov.age_integer >= 0 and game.pov.age_integer < 4) {
game.pov.age_string = "baby"
} else if (game.pov.age_integer >= 4 and game.pov.age_integer < 13) {
game.pov.age_string = "child"
} else if (game.pov.age_integer >= 13 and game.pov.age_integer < 20) {
game.pov.age_string = "teen"
} else if (game.pov.age_integer >= 20) {
game.pov.age_string = "adult"
}
]]></function>

<function name="gender_character_creation_function">
show menu ("What is your gender?", split ("male;female",";"), false) {
game.pov.gender_string = result
}
</function>

// etc *.character_creation_functions functions

<command name="character_attributes_command">
<pattern>show char</pattern>
<script>
character_attributes_function
</script>
</command>

<function name="character_attributes_function">
msg (game.pov.alias)
msg (game.pov.age_integer)
msg (game.pov.age_string)
msg (game.pov.gender_string)
msg (game.pov.race_string)
msg (game.pov.class_string)
msg (game.pov.level_integer)
msg (game.pov.experience_integer)
msg (game.pov.cash_integer)
msg (game.pov.hit_points_integer)
msg (game.pov.mana_points_integer)
msg (game.pov.strength_integer)
msg (game.pov.endurance_integer)
// etc attributes
</function>

HegemonKhan
29 Dec 2013, 01:30
ya, it looks good now, but it wasn't for me, for others to be able to read more clearly, and just to let you know how to do it, for posting in the future, but it definately is more nice~organized~clean now ;)

--------

charge your father-in-law for the IT support ;)
(just joking)

Spindraft
29 Dec 2013, 22:43
HegemonKhan wrote:
charge your father-in-law for the IT support ;)
(just joking)



LOL, He just got WIN 8 and is determined to mess with everything.

Awesome. Ran an entire conversation within a command. Multi-path conversation using 72 separate lines of text creating a full bodied conversation that branches, returns and branches again. This allowed for various paths to be taken in route to a common point and all of it can be contained in the editor under one title in the tree.


if (IsSwitchedOn(A)) {
msg ("</br><1> \"Some text\"")
}
if (IsSwitchedOn(B)) {
msg (" </br><2> \"Some text\"")
}
if (IsSwitchedOn(C)) {
msg ("</br><3> \"Some text\"")
}
get input {
switch (result) {
case (1) {
msg ("</br>\"text\"</br><br/><6> \"text.\"</br>")
SwitchOff (A)
}
case (2) {
msg ("</br>\"text.\"</br><br/><4> \"text\"</br><br/><5> \"text\"")
SwitchOff (B)
}
case (3) {
msg ("</br>\"text.\"</br><br/><4> \"text\"</br><br/><5> \"text\"")
SwitchOff (C) }
}
get input {
switch (result) {
case (4) {
msg ("</br>\"text"</br><br/><8> \"text\"</br>")
}
case (5) {
msg ("</br>\Itext\"</br><br/><8> \"text\"</br>")
}
case (6) {
msg ("</br>\"text</br><br/>\"text\"</br><br/><10> text")
}
}
get input {
switch (result) {
case (8) {
msg ("</br>\"text?\"</br><br/> \"text\"</br><br/><15> text")
}
case (10) {
msg ("</br><11> \"text\"</br><br/><12> \"text\"</br><br/><13> \"text\"</br><br/><14> \"text\"</br>")
}
}
get input {
switch (result) {
case (11) {
msg ("</br>\"text\" </br><br/><20> \"text"")
}
case (12) {
msg ("</br>\"text.\"</br><br/><29> \"text\"")
}
case (13) {
msg ("</br>\"text\"</br><br/><33> \"text\"</br><br/><34> \"text\"")
}
case (14) {
msg ("</text\"</br><br/><35> \"text\"</br><br/><36> \"text\"")
}
case (15) {
msg ("</br><16> \"text\"</br><br/><17> \"text\"</br><br/><18> \"text\"</br><br/><19> \"text\"</br>")
}
}


This is just to show the format that you would use. It gets kind of painful to track an interactive conversation through 72 lines but if you write down your story as you go it makes it much easier to follow. This is just the very beginning of what a large conversation would look like. Not sure if there is an easy way to write conversations because after all the sentences have to be recorded but this sure makes it nice in the editor tree, one title can hold a conversation as long as you want it to be.

One note though, I was running out of UI space and was having to write in the code view but this should be fairly easy for anyone because all you have to do is follow the pattern that has already been established to that point.

Spindraft
01 Jan 2014, 19:18
The conversation tracks very well as long as you enter the correct inputs. One problem though. If the current options include choosing 1, 2 or 3 and you input anything else (a wrong input) it stops the entire command, you cannot input anything else. How do I deal with this so that if a player inputs the wrong number they can simply re-enter the correct number and continue on with the conversation? I need to do a loop I suppose until the correct input is entered.

I exit the end of the conversation via a function but I noticed I had to hit enter a couple of times to get the script to move on afterwards. It entered the function and moved an object to inventory correctly but then clicking on an object command inn the inventory required the dual click to continue. ??

HegemonKhan
01 Jan 2014, 20:58
if you have a problem with functions~scripts (Scripting), it's probably that you didn't nest~indent (or didn't choose the correct "Add a script" button) some stuff correctly, and or didn't use the other scripts ("wait", "on ready", and etc) at all when you needed to or didn't use them correctly, all of these scripts, which deal with the "ordering" of your conversation functions and scripts. It takes awhile to learn and understand how "ordering" of scripting works, and it's not something that can be easily explained either, you just gradually get a "feel" for it as you get more experience with coding.

For one example, if your scripting (scripts, functions) isn't continuous (ordered properly~correctly), you may get the room description script "You are in the dungeon", show up in the middle of your other scripting...

If you don't halt ("on ready" or "wait") the scripting or nest~indent~layer it correctly, you'll have a problem, such as if you're using "show menu", as it will try to run multiple pop up "show menu" windows at the same time, which it can't do obviously.

if you don't do the scripting properly, you can have an endless looping...

etc etc etc etc "funny~curious things happening"... lol

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

ya, you need to make a "checking" script and a loop~"call upon" (which means you need it to be a function to "call upon"~loop, or you can use a script too, but it's more effort to code-set-it-up):

a_function:
if (result > 3) {
-> a_function
} else if (result = "1") {
-> // do this script
} else if (result = "2") {
// yada yada yada

in the programming world, this is known as:

"Error and Exception Handling"

this is like half of the entire coding of software...

ya, it's nice if people would type in what they're suppose to... but if they don't... you need to code-deal-with-it, lol.

and for software, this is a much more serious concern: SECURITY, as it enables people to hack into a person's computer, through software input coding, as there's no "coding check" to stop a person from typing in his own malicious code input... this is why there's so many "patches" or "upgrades" to software, and why it's so important to patch~upgrade vigilantly~diligently.

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

here's some of my own "Error and Exception Handling" Codings:

<function name="age_integer_function">
msg ("What is your age?")
get input {
if (IsInt (result) = true) {
game.pov.age_integer = ToInt (result)
} else if (IsInt (result) = false) {
age_integer_function
}
}
</function>

if (game.pov.age_integer < 0) {
game.pov.age_integer = 0
}

<function name="day_of_birth_integer_function"><![CDATA[
msg ("What is your day of birth?")
get input {
if (IsInt (result) = false) {
day_of_birth_integer_function
} else if (IsInt (result) = true) {
// result may need to be converted into an integer
if (game.pov.month_string = "january" or game.pov.month_string = "march" or game.pov.month_string = "may" or game.pov.month_string = "july" or game.pov.month_string = "august" or game.pov.month_string = "october" or game.pov.month_string = "december") {
if (result > 0 and result < 32) {
game.pov.day_integer = ToInt (result)
} else if (result < 1 or result > 31) {
day_of_birth_integer_function
}
} else if (game.pov.month_string = "april" or game.pov.month_string = "june" or game.pov.month_string = "september" or game.pov.month_string = "november") {
if (result > 0 and result < 31) {
game.pov.day_integer = ToInt (result)
} else if (result < 1 or result > 30) {
day_of_birth_integer_function
}
} else if (game.pov.month_string = "february") {
if (global_data_object.year_integer = global.data_object.old_leap_year_integer) {
if (result > 0 and result < 30) {
game.pov.day_integer = ToInt (result)
} else if (result < 1 or result > 29) {
day_of_birth_integer_function
}
} else if (global_data_object.year_integer <> global.data_object.old_leap_year_integer) {
if (result > 0 and result < 29) {
game.pov.day_integer = ToInt (result)
} else if (result < 1 or result > 28) {
day_of_birth_integer_function
}
}
}
}
}
]]></function>

<function name="year_of_birth_integer_function"><![CDATA[
msg ("What is your year of birth?")
msg ("Please type in 4 numbers")
get input {
if (IsInt (result) = false) {
year_of_birth_integer_function
} else if (IsInt (result) = true) {
// result may need to be converted into an integer
if (LengthOf (result) <> 4) {
year_of_birth_integer_function
} else if (LengthOf (result) = 4) {
if (result < 1900) {
year_of_birth_integer_function
} else if {result >= 1900) {
game.pov.year_integer = ToInt (result)
}
}
}
}
]]></function>


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

P.S.

well... if you used "show menu" for everything... then you don't need any "error and exception handling"... lol

but any time that you use the user's typed input ("get input") ... you need "checking" and "looping" code, in case the user doesn't type in what or how he's specified to do.

Spindraft
02 Jan 2014, 12:43
Thanks Hegemon, I will write a check function for the conversation issues. I have not learned how to use "show menu" yet because I do not understand how the UI wants to take the info. I am still trying to get links to work as the input method but the command will not accept this so stuck with user input for now. Got a couple of books and it looks to me like XML and HTML are closely related - in fact I am wondering if "xlinks:type" will not work the same way "a href" works since I am guessing that an XML Doctype is being used as a script header somewhere ahead of the actual document we are scripting inside the editor. Just thinking aloud.

HegemonKhan
02 Jan 2014, 17:08
all "show menu" does, is to take your "list of choices ("stringlist")" Attribute, and puts them as forced choices via a~the pop up menu window of it, and then it sets the variable: result = your selection (from the pop up menu window of it).

It's similar to the "get input" function, except it uses a "stringlist" (as it is a list and selection of pre-set and forced choices), and with, and due to, its pop up menu window, whereas with "get input" the user types in his input~response.

in Code (and I'm sure you can connect its form in the GUI~Editor to that in its code-form):

there's two ways to syntax in a stringlist within the "show menu":

temporary~local~variable~non-saved: split ("choice_1;choice_2;choice_3" , ";")
permanent~global~attribute~saved: Object.StringList

about "split" (if I understand this conceptually, lol):

split ("value_1, ie our string and the separating symbols~characters" , "value_2, ie our chosen symbol~character as our separator")

split ("abc;def;ghi" , ";")
or: split ("abc+def+ghi" , "+")
or: split ("abc@def@ghi" , "@")
or: split ("abc777def777ghi" , "777")
or: split ("abcXdefXghi" , "X")

string = abcdefghi
split = what's our separator symbol~character for the quest game engine to recognize as such? the semicolon: ";"
split = how do you want to split up abcdefghi ??? here's how: abc ; def ; ghi (or: a ; b ; c ; d ; e ; f ; g ; h ; i ~ or: ab ; cd ; ef ; gh ; i ~ or etc etc etc)
stringlist = (1) abc (2) def (3) ghi

show menu ("your message ~ question", list of choices, cancel'able? true~false) {
-> // script
}

-------

show menu ("What is your gender?", split ("male;female" , ";"), false) {
-> // let's say you selected "male" from the show menu's pop up menu window
-> // quest automatically sets the variable: result = "male"
-> player.gender_string = result
}

---------

show menu ("What is your gender?", global_data_object.gender_string_list, false) {
-> // let's say you selected "male" from the show menu's pop up menu window
-> // quest automatically sets the variable: result = "male"
-> player.gender_string = result
}

<object name="global_data_list">
-> <inherit name="editor_object" />
-> <gender_string_list type="simplestringlist">male;female</gender_string_list>
</object>

HegemonKhan
02 Jan 2014, 17:39
If you're asking how to use "show menu" with~for your conversation function... it's really not too hard...


// Does this look similar to when you use "get input", eh? hehe
show menu ("What topic do you want to ask about?", global_data_object.topic_string_list, false) {
-> // let's say you selected "princess" from the "show menu's" pop up menu window
-> // quest automatically sets the variable: result = your selection from the "show menu's" pop up menu window
-> // result = "princess"
-> global_data_object.topic_string = result
-> switch (global_data_object.topic_string) {
->-> case ("dragon") {
->->-> msg ("about the dragon")
->-> }
->-> case ("princess") {
->->-> msg ("about the princess")
->-> }
->-> case ("sword") {
->->-> msg ("about the sword")
->-> }
-> }
}

<object name="global_data_object">
-> <inherit name="editor_object" />
-> <topic_string_list type="simplestringlist">dragon;princess;sword</topic_string_list>
-> <topic_string type="string">unknown</topic_string>
</object>

// quest~game output (due to selecting "princess"): about the princess