Script Paths
Encrtia
19 Oct 2015, 06:22Ok, I'm unsure if this is doable or how to approach - so am asking if someone more knowledgeable may again inteverne to assist.
It's a little hard to explain actually.
Essentially, I'm writing series of passages that are seperated by "Wait for Player to press button" commands. Eventually, the player is given a choice. Hi5 someone, or don't. After they make the choice, a passage is presented "You high five him" or "You don't high five him", & then the outcome of both choices converge back into one script. Did that make sense? Is that possible? Or do I have to duplicate the script for Both the IF & ELSE IF routes each time?
It's a little hard to explain actually.
Essentially, I'm writing series of passages that are seperated by "Wait for Player to press button" commands. Eventually, the player is given a choice. Hi5 someone, or don't. After they make the choice, a passage is presented "You high five him" or "You don't high five him", & then the outcome of both choices converge back into one script. Did that make sense? Is that possible? Or do I have to duplicate the script for Both the IF & ELSE IF routes each time?
The Pixie
19 Oct 2015, 06:58Like this?
msg ("text 1")
wait {
msg ("text 2")
ask ("Hi 5?") {
if (result) {
msg ("You hi 5ed")
}
else {
msg ("You didn't")
}
msg ("Either way...")
}
}
HegemonKhan
19 Oct 2015, 07:48if you understand 'outlines', like for using for writing a school essay or whatever, you understand the basics of scripting order~sequence!
============================
in simpliest form (this was the very first programming languages, like basic), scripting order~sequence, goes from top to bottom:
line 1: script 1
------V
line 2: script 2
------V
line 3: script 3
------V
line 4: script 4
==========================
but it gets more complicated, with nesting:
line 1: script 1
line 2: -> script 2
line 3: -> script 3
line 4: script 4
script 1 ~ line 1
|.......\
|.......script 2 ~ line 2
|.........\
|..........script 3 ~ line 3
|
script 4 ~ line 4
this isn't too bad though:
path: script 1 -> script 2 -> script 3 -> script 4
however, you can run into some exception-problems with scripts that wait for a user input or popup a menu window, as script 4 can activate before everything is finished up within script 2 and script 3.
================================
the simpliest (most error-free) nesting is obviously, a straight diagonal from the upper-left to the lower right:
script 1
.......\
.......script 2
...........\
...........script 3
..............\
..............script 4
path: script 1 -> script 2 -> script 3 -> script 4
================================================
so, what does you 'if~else' (using for this example) script would look like?, see below:
................................script 1
............................../..........\
...........script 2: if (true)............else
............ { script 3A }..............{ script 3B}
...........................\............/
..............................script 4
so the paths are:
script 1 -> script 2 -> script 3A -> script 4
script 1 -> script 2 -> script 3B -> script 4
========================================================
so, what does you 'if~else if~else' (using for this example) script would look like?, see below:
............................................script 1............
.........................../..................|..................\
...........script 2: if (A).............if else (B).............else
............ { script 3A }.............{ script 3B }...........{ script 3C }
...........................\..................|................/
..........................................script 4............
so the paths are:
script 1 -> script 2 (if A) -> script 3A -> script 4
script 1 -> script 2 (else if B) -> script 3B -> script 4
script 1 -> script 2 (else) -> script 3C -> script 4
===========================================
I hope you now see~understand what happens as we add more or less 'else ifs'... as trying to draw this stuff is a pain, lol.
I also hope you can understand all the other infinite path patterns~structures that can be done... lol
for an example, we can path~branch as deep as we want (think of an upside down tree):
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
..........|..|..|..|..|
or
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
...........\/\/\/\/
............\/\/\/
.............\/\/
..............\/
or
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
...........\/\/\/|.|
............\/\/..|.|
.............\/....|.|
and etc...
============================================
however, besides nesting scripts, you've got various loops (for, foreach, while, do-while, etc), functions (calling upon functions), functions calling on other functions, functions calling on themselves (loops the function: recursion), 'if' scripts~structures, and etc...
============================================
also, you might want to google various code flow charts, for some examples:
(this helps you train your brain in programming~code 'if' path-decision logic thought-processing~mentality, which is needed for game making regardless of whether you use code or the GUI~Editor)
https://en.wikipedia.org/wiki/Flowchart
http://www4.ncsu.edu/~spbalik/java/IfElseExample.html
https://chortle.ccsu.edu/QBasic/chapter18/bc18_3.html
https://facweb.northseattle.edu/msteffa ... apter3.htm
http://programmers.stackexchange.com/qu ... ps-process
https://blog.udemy.com/flowchart-examples/
============================
in simpliest form (this was the very first programming languages, like basic), scripting order~sequence, goes from top to bottom:
line 1: script 1
------V
line 2: script 2
------V
line 3: script 3
------V
line 4: script 4
==========================
but it gets more complicated, with nesting:
line 1: script 1
line 2: -> script 2
line 3: -> script 3
line 4: script 4
script 1 ~ line 1
|.......\
|.......script 2 ~ line 2
|.........\
|..........script 3 ~ line 3
|
script 4 ~ line 4
this isn't too bad though:
path: script 1 -> script 2 -> script 3 -> script 4
however, you can run into some exception-problems with scripts that wait for a user input or popup a menu window, as script 4 can activate before everything is finished up within script 2 and script 3.
================================
the simpliest (most error-free) nesting is obviously, a straight diagonal from the upper-left to the lower right:
script 1
.......\
.......script 2
...........\
...........script 3
..............\
..............script 4
path: script 1 -> script 2 -> script 3 -> script 4
================================================
so, what does you 'if~else' (using for this example) script would look like?, see below:
................................script 1
............................../..........\
...........script 2: if (true)............else
............ { script 3A }..............{ script 3B}
...........................\............/
..............................script 4
so the paths are:
script 1 -> script 2 -> script 3A -> script 4
script 1 -> script 2 -> script 3B -> script 4
========================================================
so, what does you 'if~else if~else' (using for this example) script would look like?, see below:
............................................script 1............
.........................../..................|..................\
...........script 2: if (A).............if else (B).............else
............ { script 3A }.............{ script 3B }...........{ script 3C }
...........................\..................|................/
..........................................script 4............
so the paths are:
script 1 -> script 2 (if A) -> script 3A -> script 4
script 1 -> script 2 (else if B) -> script 3B -> script 4
script 1 -> script 2 (else) -> script 3C -> script 4
===========================================
I hope you now see~understand what happens as we add more or less 'else ifs'... as trying to draw this stuff is a pain, lol.
I also hope you can understand all the other infinite path patterns~structures that can be done... lol
for an example, we can path~branch as deep as we want (think of an upside down tree):
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
..........|..|..|..|..|
or
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
...........\/\/\/\/
............\/\/\/
.............\/\/
..............\/
or
............../\
............./\/\
............/\/\/\
.........../\/\/\/\
...........\/\/\/|.|
............\/\/..|.|
.............\/....|.|
and etc...
============================================
however, besides nesting scripts, you've got various loops (for, foreach, while, do-while, etc), functions (calling upon functions), functions calling on other functions, functions calling on themselves (loops the function: recursion), 'if' scripts~structures, and etc...
============================================
also, you might want to google various code flow charts, for some examples:
(this helps you train your brain in programming~code 'if' path-decision logic thought-processing~mentality, which is needed for game making regardless of whether you use code or the GUI~Editor)
https://en.wikipedia.org/wiki/Flowchart
http://www4.ncsu.edu/~spbalik/java/IfElseExample.html
https://chortle.ccsu.edu/QBasic/chapter18/bc18_3.html
https://facweb.northseattle.edu/msteffa ... apter3.htm
http://programmers.stackexchange.com/qu ... ps-process
https://blog.udemy.com/flowchart-examples/
Encrtia
20 Oct 2015, 02:08Exactly The Pixie. So Simple, how could I miss it. Thanks.
Great visual references HegemonKhan! A pain drawing it worked out very well
I hadn't thought too deeply about pathways/patterns, but my lack of organization certainly beckons me to do so! Thanks as well for the examples, it's definitely something I need to look into.
It's like the solution came first, then the deep explanation after so there's no way one could Not understand what's going on. Thanks again guys!
Great visual references HegemonKhan! A pain drawing it worked out very well

It's like the solution came first, then the deep explanation after so there's no way one could Not understand what's going on. Thanks again guys!