this probably won't help you, as I'll be going over this stuff using code, but I hope it'll at least make some sense to you a bit with conception-understanding at least (I hope, HK crosses his fingers, lol)...
(hopefully you can figure out how to do this stuff via the GUI~Editor, as I'm just not that familar with it yet, and it takes so much longer to try to explain stuff using the GUI~Editor, sighs)
(unfortunately, what, how, when, why, where, and etc to use different code designs... takes years of experience... I'm struggling with this myself... I make really messy code~scripts, and then Jay, Pertex, Pixie, Chase, Sora, and etc... come along and do the same stuff in like only a 1/10 of the amount of code, is super neat ~ easy to understand, and etc... argh... lol! And I never even realized to do it that way that they do it... it's a lot like math... it's like me and you can only use addition, whereas experienced coders can use everything: from addition to calculus and beyond... they know what's the best math ability to use to solve something, whereas me and you are stuck with just using addition... we don't even know that multiplication, algebra, trig, calculus, and etc exists, let alone when, where, why, and how, to use which one of them for which situation-problem, lol. It's like I need to do a 100 step proof to solve a math problem, but they can solve the math problem in just a 10 step proof!)
-----------
01.
http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
02.
http://quest5.net/w/index.php?title=Cat ... t#mw-pages (page 2, range: S-Z)
03.
http://quest5.net/wiki/GetRandomInt04.
http://quest5.net/wiki/ListCount05.
http://quest5.net/wiki/Using_Lists06.
http://quest5.net/wiki/Using_Dictionaries (this is a bit more complicated than using lists)
07.
http://quest5.net/wiki/Split08.
http://quest5.net/wiki/Join (this isn't really used much by non-advanced coders, I don't even understand why~when you'd ever use this function, lol)
09.
http://quest5.net/wiki/Foreach10.
http://quest5.net/wiki/For11.
http://quest5.net/wiki/NewStringList12.
http://quest5.net/wiki/Category:Scopes13.
http://quest5.net/wiki/Stringlist14.
http://quest5.net/wiki/Objectlist15.
http://quest5.net/wiki/List_add16. etc... lol
---------------------
'for' and 'foreach' deals with Lists (stringlists and objectlists).
before I talk about 'for' and 'foreach', first we must get into what lists are:
(1) red, (2) blue, or (3) yellow
lists provide a selection of choices (a collection of strings, separated as individual selections to choose from), in the above example: red, blue, or yellow
String: redblueyellow
StringList: (1) red, (2) blue, or (3) yellow
String -> 'splits' into a -> StringList
StringList -> 'joins' into a -> String
the 'split' function creates a StringList (or ObjectList)
Object.StringList = split ("item_1;item_2;item_3;etc", "separator_character")
conceptually:
game.primary_colors_string_list = split ("string: redblueyellow", "separator_character: semicolon")
game.primary_colors_string_list = split ("red;blue;yellow", ";")
game.primary_colors_string_list = split ("string: redblueyellow", "separator_character: plus sign")
game.primary_colors_string_list = split ("red+blue+yellow", "+")
game.primary_colors_string_list = split ("string: redblueyellow", "separator_characters: HK")
game.primary_colors_string_list = split ("redHKblueHKyellow", "HK")
usually people use the semicolon as the separator character (using the 'split' in a 'show menu', as an example):
show menu ("What is your race?", split ("human;dwarf;elf", ";"), false) {
-> player.race_string = result
}
and, you can also make Lists this way too:
Object.StringList = NewStringList ()
list add (Object.StringList, "item_1")
list add (Object.StringList, "item_2")
list add (Object.StringList, "item_3")
// etc
so, that's what Lists are, but now for what is useful about those lists:
as I already shown, you can use them for a choice of selections to make
however, the other useful thing with lists is that you can use them to act upon specific items within the list (via 'for') or to act upon ALL~EVERY~EACH item within the list (via 'foreach'):
though for you to understand how this works, I got to explain something about lists:
while 'split ("red;blue;yellow", ";")' has three items (red-1, blue-2, yellow-3), their actual list ordering begins with ZERO:
list item order ('indexing'):
0: red
1: blue
2: yellow
so (using my above example)...
StringListItem (game.primary_colors_string_list, 1) -> outputs~returns: blue
StringListItem (game.primary_colors_string_list, 2) -> outputs~returns: yellow
StringListItem (game.primary_colors_string_list, 0) -> outputs~returns: red
StringListItem (game.primary_colors_string_list, 3) -> outputs~returns: ERROR~null, there is no 4th item (no item ordering of 3)
this allows for some cool stuff, such as random selection:
GetRandomInt (min, max)
game.primary_color_choosen_string = StringListItem (game.primary_colors_string_list, GetRandomInt (0,2))
game.primary_color_choosen_string = // (a random choice of either red; blue; or yellow)
and also this is extremely useful too with lists:
ListCount (game.primary_colors_string_list) -> outputs~returns: 3 (# of items in the list, NOT the list ordering, ya it gets some getting used to, very confusing for quite awhile)
game.primary_color_choosen_string = StringListItem (game.primary_colors_string_list, GetRandomInt (0,ListCount (game.primary_colors_string_list)) -> outputs~returns: // (a random choice of either red; blue; or yellow)
list remove (game.primary_colors_string_list, "yellow")
game.primary_color_choosen_string = StringListItem (game.primary_colors_string_list, GetRandomInt (0,ListCount (game.primary_colors_string_list) - 1) -> outputs~returns: // (a random choice of either red or blue)
* the 'ListCount (Object.List) - 1' is because of the difference between number of items in a list and the list's ordering:
ordering: color_string (number of items)
0: red (1st item)
1: blue (2nd item)
2: yellow (3rd item)
ListCount = 3
3 - 1
List item ordering: 2
StringListItem (Object.List, GetRandomInt (0, ListItem (Object.List) -1))
StringListItem (Object.List, GetRandomInt (0, 3 -1))
StringListItem (Object.List, GetRandomInt (0, 2))
// outputs~returns: (either: red, blue, or yellow)
if you don't do the 'ListCount (Object.List) - 1', you get problems~errors:
StringListItem (Object.List, GetRandomInt (0, ListItem (Object.List)))
StringListItem (Object.List, GetRandomInt (0, 3))
// outputs~returns: (either: red, blue, yellow, or... ???... no 4th item... ERROR~null...BIG PROBLEMS!)
-------
the importance of this, is that it finds the number of items in the list currently, without your intervention of 'coding' (typing) in the right number into the code line, which is not always possible for you to do, when you got code of changing list items taking place.
---------
alright, I've explained a bit more than what you asked for in the above, so let me now get to explaining what you wanted: 'for' and 'foreach', though I think the above helps with understanding this stuff too (if it doesn't confuse you even more, argh, lol):
so you got a string list:
game.primary_colors_string_list = split ("red;blue;yellow", ";")
if I want to do the same action(s) for ALL~EVERY~EACH item within the string list:
http://quest5.net/wiki/Foreachitem_x -> 1st as: red
item_x -> 2nd as: blue
item_x -> 3rd as: yellow
// etc
foreach (item_x, game.primary_colors_string_list)
-> msg ("Color: " + item_x)
}
// outputs~returns #1: Color: red
// outputs~returns #2: Color: blue
// outputs~returns #3: Color: yellow
let's use the example of an object list now:
game.fruit_string_list = split ("apple;orange;lemon", ";")
foreach (item_x, game.fruit_string_list)
-> MoveObject (item_x, player) // or (this does the exact same thing as 'MoveObject'): item_x.parent = player
}
// the "player" Player Object now holds these items: apple, orange, and lemon
or, we can do a Verb script too:
Verb: "eat"; the 'apple', 'orange', and 'lemon' Objects have all be given (add verb) the "eat" verb
foreach (item_x, game.fruit_string_list)
-> invoke (item_x.eat)
}
// you do the apple's eat verb
// you do the orange's eat verb
// you do the lemon's eat verb
or here's a good analogy example for you:
game.team_string_list = split ("team_member_1;team_member_2;team_member_3", ";")
foreach (team_member, game.team_string_list)
-> invoke (team_member.run_laps)
}
// ALL~EVERY~EACH team member runs laps
now, about 'for':
http://quest5.net/wiki/For(iterator variable, int from, int to) { script }
or
(iterator variable, int from, int to, int step) { script }
remember, list ordering starts at ZERO:
0: team member 1
1: team member 2
2: team member 3
for (team_member, 0,2)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 2 runs laps
// team member 3 runs laps
for (team_member, 0,1)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 2 runs laps
for (team_member, 1,2)
-> invoke (team_member.run_laps)
}
// team member 2 runs laps
// team member 3 runs laps
for (team_member, 0,0)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
for (team_member, 1,1)
-> invoke (team_member.run_laps)
}
// team member 2 runs laps
for (team_member, 2,2)
-> invoke (team_member.run_laps)
}
// team member 3 runs laps
for (team_member, 0,2,2)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 3 runs laps
for (team_member, 0,2,1)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 2 runs laps
// team member 3 runs laps
(let's add more team members to show more examples):
5 team members:
(remember, list ordering starts at ZERO)
0: team member 1
1: team member 2
2: team member 3
3: team member 4
4: team member 5
for (team_member, 0,4,2)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 3 runs laps
// team member 5 runs laps
for (team_member, 0,4,4)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 5 runs laps
for (team_member, 0,4,3)
-> invoke (team_member.run_laps)
}
// team member 1 runs laps
// team member 4 runs laps
--------
and don't forget you can use randomness: GetRandomInt (min, max), and also the current number of items too: ListCount (Object.List) - 1
-------
basically, lists enable you to group many (strings or objects: string lists or object lists), so that you can then do actions upon either: all~every~each of that group of strings~objects (via 'foreach'), or on a specific range (ie specific) of those string~objects within that group (via 'for').
also, lists enable you to easily adjust-change them (adding or removing items, ie: string or object), as well.
for example, let's say you got a random dialogue script block, such as when talking to an NPC (a non-playable-character, ie a 'townsfolk' vs a 'monster'), but you don't want the same dialogue choice being randomly selected over and over again, each time a dialogue msg script is selected, it is removed from the list, and the next time you talk to the NPC, it randomly selects from that now smaller list of choices, and again and again, until all the dialogue msgs are selected and seen by the person playing the game.
or, like in many games, you want to have 'events' from 'exploring', or from opening a chest that can be reopened for new items.
or for example, with a 'travel' or 'goto' or 'warp' feature~spell~whatever.
I can provide game code, for you to play out and study, of an 'explore' and 'travel' features, which is a real example of lists, (dictionaries too ~ which are a bit more complicated then lists ~ once you understand lists, let me know, and I'll try to help you with understanding dictionaries), 'for', 'foreach' and etc stuff ('GetRandomInt', 'ListCount', 'StringListItem', 'Object'ListItem'), so just let me know if interested in it.