msg ("this is a question that requires a yes or no answer.")
Get input {
If (result = "yes") {
// run yes script
} else if (result = "no") {
// run no script
} else {
// something else happens
}
}
msg ("this is a question that requires a yes or no answer.")
Get input {
If (result = "yes") {
// run yes script
} else if (result = "no") {
// run no script
} else {
// something else happens
}
}
ask ("this is a question that requires a yes or no answer.") {
// you select 'yes' or 'no' from the popup window
// quest's 'ask' Function does this automatically (hidden from you): yes -> true
// quest's 'ask' Function does this automatically (hidden from you): no -> false
if (result = true) {
// script1
} else if (result = false) {
// script2
}
}
ask ("this is a question that requires a yes or no answer.") {
if (result) {
// script1
} else {
// script2
}
}
<function name="custom_ask_function">
msg ("Do you want to live?")
msg ("(Type in the number of your choice)")
DisplayList (global_data_object.yes_or_no_stringlist, true)
get input {
if (result = "1") {
msg ("Doh! Fine, live, then, grr")
wait {
ClearScreen
}
} else if (result = "2") {
msg ("Yessss! Muwuhaha! Die!")
wait {
ClearScreen
}
} else {
ClearScreen
custom_ask_function
}
}
</function>
<object name="global_data_object">
<inherit name="editor_object" />
<attr name="yes_or_no_stringlist" type="simplestringlist">yes;no</attr>
</object>
ask ("this is a question that requires a yes or no answer.") {
if (result) {
// script1
} else {
// script2
}
}
HegemonKhan wrote:and I just learned from your posts that there's a 'hyperlink' (upper case) one, laughs. I just knew of the 'popup window' (lower case) one, lol.
looks like both me and silver created our own Functions, as we don't like the 'ask' Function's popup window, not knowing that there's the other 'ASK' Function, which uses hyperlinks, instead of a popup window. DOH! (well not wasted effort, our custom 'ask' functions are useful still too, hehe).
HegemonKhan wrote:You'll at some point get around to learning to code (hopefully), as it seems you already are moving towards it (switching between code view mode and the GUI~Editor mode, to see how the code converts into how it is done~looks in the GUI~Editor), hehe.
Silver was totally against coding... now he~she loves it, probably not going back much to the GUI~Editor anymore, just like me (as I too came into quest not knowing anything at all about coding, and but used quest to learn to code, to get where I'm at today: still a noob at coding, but I've come a long way, and Silver is making good code progress now too. If you want to learn to code, quest is really awesome for it). Code is indeed very scary at first, but as you slowly start to learn it, it's really not that difficult (it's really just a lot of algebra: algebraic substitutions, but coming up with creative~advanced code designs, that's hard, lol. But just the coding itself, isn't really as bad as it certainly does seem for people new to code). The GUI~Editor is great, but once you can code, you don't have much more need for it anymore.
-------
try leaving the bracket choice as [EXPRESSION], and then in the text box, type in: result, see below
if -> [EXPRESSION] -> result
and see what happens
(it's the exact same thing)
how is it in the GUI~Editor (too lazy to fire up quest to find out myself, lol) ???, something like this:
if -> [VARIABLE~whatever the label choice here] -> [RESULT]
or
if -> [RESULT]
???
msg("The Goblin backs away slightly and its eyes pierce you. You feel you could {command:fight:attack} him now or you could {command:something:else} away from him.")
msg("you have entered a room. Would you like to {command:ghghghg} the door}")
msg("you have entered a room. would you like to {command:ghghghg:open} the door")
You can:
{command:combat fight:Attack}
{command:combat magic:Use magic}
{command:combat item:Use item}
{command:combat escape:Escape}
<command name="Dungeons_DoScriptCmd">
<pattern>DoScript #text1# #text2#;DoScript #text1#</pattern>
<script>
<![CDATA[
// We just executed a command. Clear the screen.
Dungeons_NewScreen()
// text = object:attribute parameters
// text2 = parameter string (param1,param2,...)
source = Split(text1, ".")
object = StringListItem(source, 0)
attribute = StringListItem(source, 1)
if (not IsDefined("text2")) {
text2 = ""
}
args = Split(text2, ",")
params = NewDictionary()
argnum = 1
foreach (arg, args) {
dictionary add(params, "arg"+argnum, arg)
argnum = argnum + 1
}
//msg("object = " + object + ", attribute = " + attribute + ", params = " + params)
do (GetObject(object), attribute, params)
]]>
</script>
switch (text) {
case ("attack") {
// do attack stuff
}
case ("flee") {
// run away
}
// etc.
}
jaynabonne wrote:You can either create a separate command for each or pass parameters to a single command or some combination of the two. The "command_name" part is actually a full command. It can be something like "fight" or "Combat_Attack" (both single commands) or something more complex like "Combat attack", where the command has pattern "Combat #text#" and you then have to check the text param to see what subcommand you're executing. Like:You can:
{command:combat fight:Attack}
{command:combat magic:Use magic}
{command:combat item:Use item}
{command:combat escape:Escape}
This shows:
You can:
Attack
Use magic
Use item
Escape
and if you click "Attack" it sends the command "combat fight". The "combat" command can then compare text to "fight" to handle that particular area. One way or another you need to have unique commands for each case.
You can also do something like this:<command name="Dungeons_DoScriptCmd">
<pattern>DoScript #text1# #text2#;DoScript #text1#</pattern>
<script>
<![CDATA[
// text = object:attribute parameters
// text2 = parameter string (param1,param2,...)
source = Split(text1, ".")
object = StringListItem(source, 0)
attribute = StringListItem(source, 1)
if (not IsDefined("text2")) {
text2 = ""
}
args = Split(text2, ",")
params = NewDictionary()
argnum = 1
foreach (arg, args) {
dictionary add(params, "arg"+argnum, arg)
argnum = argnum + 1
}
//msg("object = " + object + ", attribute = " + attribute + ", params = " + params)
do (GetObject(object), attribute, params)
]]>
</script>
This command takes command text like "DoScript player.attack", where it will then invoke the script "attack" on the player object, or even something like "DoScript shop.buy axe", where you have an object named "shop" with a script named "buy". It will be called with a parameter named "arg1" set to "axe". Basically, the command line can be as complicated as you wish to parse.
A command with the latter script would be like: {command:DoScript combat.attack:Attack}, which would invoke the "attack" script on the "combat" object.
msg ("You encountered an orc, do you " + {command:fight_command:combat attack orc} + ", " + {command:fight_command:combat magic orc} + ", " + {command:fight_command:combat item orc} + ", " + {command:fight_command:combat magic player + ", " + {command:fight_command:combat item player + ", or " + {command:fight_command:combat escape player} + "?")
<command name="fight_command">
<pattern>combat #text# #object#</pattern>
<script>
switch (text) {
case ("attack") {
msg ("You attack the " + object.alias + ".")
}
case ("magic") {
if (object.name = "orc") {
msg ("You cast a fireball at the " + object.name + ".")
} else if (object.name = "player") {
msg ("You cast a healing spell upon yourself")
}
}
// etc etc etc
}
</script>
</command>
HegemonKhan wrote:You'll at some point get around to learning to code (hopefully), as it seems you already are moving towards it (switching between code view mode and the GUI~Editor mode, to see how the code converts into how it is done~looks in the GUI~Editor), hehe.
Silver was totally against coding... now he~she loves it, probably not going back much to the GUI~Editor anymore, just like me (as I too came into quest not knowing anything at all about coding, and but used quest to learn to code, to get where I'm at today: still a noob at coding, but I've come a long way, and Silver is making good code progress now too. If you want to learn to code, quest is really awesome for it). Code is indeed very scary at first, but as you slowly start to learn it, it's really not that difficult (it's really just a lot of algebra: algebraic substitutions, but coming up with creative~advanced code designs, that's hard, lol. But just the coding itself, isn't really as bad as it certainly does seem for people new to code). The GUI~Editor is great, but once you can code, you don't have much more need for it anymore.
HegemonKhan wrote:
try leaving the bracket choice as [EXPRESSION], and then in the text box, type in: result, see below
if -> [EXPRESSION] -> result
and see what happens
(it's the exact same thing)
how is it in the GUI~Editor (too lazy to fire up quest to find out myself, lol) ???, something like this:
if -> [VARIABLE~whatever the label choice here] -> [RESULT]
or
if -> [RESULT]
???