dado1996 wrote:HegemonKhan That is very helpful and I appreciate it. Now I want to know if in the switch case, there is no problem if I use more than one word in the split.
the 'split' Function/Script is a quick way to create a list:
http://docs.textadventures.co.uk/quest/ ... split.htmlthis is it's syntax/format:
(you can have as many word/phrase items as you want, I'm just using 3 below)
split ("word/phrase item 1 SEPARATOR word/phrase item 2 SEPARATOR word/phrase item 3", "SEPARATOR")
the usual convention is:
SEPARATOR: semicolon character/symbol // but you can use generally whatever character/symbol you want, if you prefer
so, for example:
// the concept of split:
// 'redblueyellow' String is "split" up into 3 sub/new-Strings: 'red', 'blue', and 'yellow'
and when using 'split' with 'show menu', you get:
single word items: split ("red; blue; yellow", ";")
// output popup menu choices:
// red
// blue
// yellow
~ OR ~
// the concept of split:
// 'You love the color red You love the color blue You love the color yellow' String is "split" up into 3 sub/new-Strings: 'You love the color red', 'You love the color blue', and 'You love the color yellow'
phrase items: split ("You love the color red; You love the color blue; You love the color yellow", ";")
// output popup menu choices:
// You love the color red
// You love the color blue
// you love the color yellow
though if you use phrases, then your if/switch-case Scripting has to match those phrases (just as they have to match when you use single words):
(the "arrows" aren't proper code syntax, I just use them to do/show the intenting/"nesting", when I don't want to use the post's code boxes)
switch (resut)
-> case ("You love the color red") {
->-> // scripts
-> }
-> case ("You love the color blue") {
->-> // scripts
-> }
-> case ("You love the color yellow") {
->-> // scripts
-> }
}
OR
if (result = "You love the color red") {
-> // scripts
} else if (result = "You love the color blue") {
-> // scripts
} else if (result = "You love the color yellow") {
-> // scripts
}
--------------
when an Attribute's Value is encased within double quotes, quest understands that Value to be a String Value, which means that the Attribute must be a String Attribute too (String Attributes hold String Values).
GUI~Editor's Adding (creating) an Attribute (non-scripting method):
(Object Name: player)
Attribute Name: favorite_fruit
Attribute Type: string
Attribute Value: apple // the GUI-Editor handles it, so you don't need to put in the double quotes yourself
Scripting method:
player.favorite_fruit = "apple" // this is just refering to specific TEXT (text/string: "apple"), not an actual-existing 'apple' Object.
VS
when an Attribute's Value is NOT encased within double quotes, quest understands that Value to be an Object Value, which means that the Attribute must be an Object Attribute too (Object Attributes hold Object Values).
<object name="apple">
-> contents/attributes
</object>
GUI~Editor's Adding (creating) an Attribute (non-scripting method):
(Object Name: player)
Attribute Name: favorite_fruit
Attribute Type: object // this means the Attribute is an Object Attribute; an Attribute that holds an Object Value (the name/ID of the Object, not the actual-physical Object itself. Think of this as like a P.E. roster. The roster-paper holds the name of the students, not the students, lol. However, the PE coach can use the roster to bark orders to those students, which is what makes Object Attributes useful. Object Attributes only hold a single Object Value, Object List Attributes can hold any qunatity of Object Values)
Attribute Value: apple // the GUI-Editor handles it, so you don't need to worry about whether it needs double quotes or not (it doesn't, it's not a string)
Scripting method:
player.favorite_fruit = apple // this is refering to the actual (and existing) Object: <object name="apple">contents/attributes</object>
-----------
a more meaningful example of Object Attributes is this example:
<object name="unarmed">
-> <attr name="damage" type="int">1</attr>
</object>
<object name="katana">
-> <attr name="damage" type="int">50</attr>
</object>
<object name="claymore">
-> <attr name="damage" type="int">75</attr>
</object>
<object name="battle_axe">
-> <attr name="damage" type="int">100</attr>
</object>
<object name="player">
-> <attr name="right_hand" type="object">unarmed</attr>
-> <attr name="damage" type="int">player.right_hand.damage + player.right_hand.damage * player.strength / 100</attr>
</object>
in scripting:
unarmed.damage = 1
katana.damage = 50
claymore.damage = 75
battle_axe.damage = 100
player.strength = 67
player.right_hand = unarmed // you're initially "equipped" with unarmed (conceptually not equipped with a weapon)
player.damage = player.right_hand.damage + player.right_hand.damage * player.strength / 100
// player.damage = 1 + ( 1 * (67/100) )
player.right_hand = katana // you "equipped" the katana
player.damage = player.right_hand.damage + player.right_hand.damage * player.strength / 100
// player.damage = 50 + ( 50 * (67/100) )
player.right_hand = claymore // you "equipped" the claymore
player.damage = player.right_hand.damage + player.right_hand.damage * player.strength / 100
// player.damage = 75 + ( 75 * (67/100) )
player.right_hand = battle_axe // you "equipped" the battle_axe
player.damage = player.right_hand.damage + player.right_hand.damage * player.strength / 100
// player.damage = 100 + ( 100 * (67/100) )
notice how the player posseses none of the 4 weapon Objects in his/her inventory (none of the 4 weapons are on/inside of the 'player' Player Object) nor held inside of the 'right_hand' Object Attribute of the player's, yet we're able to use them for determining the 'player' Player Object's 'damage' Integer (int) Attribute, through the Object Attribute.
just has the PE coach can use the roster to bark orders to the students, yet the roster itself doesn't hold the students on it, lol.