I"m having trouble figuring this out. or if it is even possible to do.
if (GetBoolean(game, "trigger")) {
SetFlagOn ("tr2")
SetFlagOff ("tr1")
}
else if (not GetBoolean(game, "trigger")) {
SetFlagOn ("trigger")
SetFlagOn ("tr1")
SetFlagOff ("tr2")
}
This is all in function I can call up whenever the trigger is needed
Trigger: meant to turn it on
tr1: first time activation
tr2: already activated(should only trigger once per page whenever a condition Is met)
//
What I want to do is add a counter so that if 'trigger' is active three times for example, to set turn on a flag(let call it tr3). The counter the easy part but i'm not sure how to stop the counter if the player loops back into the same page.(cause the event already triggered and shouldn't repeat over and over.) I know tr2 is the key i'm just unsure of what logic to use. My closest guess was an if statement(not part of the function. I suspect each page the event triggers in wou need it own uniquie flag for the logic to work..I think)
if (GetBoolean(game, "tr2")) {
if (not GetBoolean(game, "ID")) {
IncreaseCounter ("triggercount")
SetFlagOn ("ID")
}
}
// Id being page unique flag for page
You could use "firsttime" to set/increase the counter, then just use one flag (you were calling it ID) when the counter gets to a particular value. Then if the player doubles back to a page it won't increase the counter anymore since it's their second+ visit.
So on the first page:
firsttime {
SetCounter ("TheCounter", 1)
}
otherwise {
if (GetInt(game, "TheCounter") = 3) {
SetFlagOn ("TheFlag")
}
}
On subsequent pages that increase the counter use ChangeCounter (instead of Set), and also nest the ability to set the flag on within "firsttime" (as well as "otherwise") if they've been going to the pages out of order:
firsttime {
ChangeCounter ("TheCounter", 1)
if (GetInt(game, "TheCounter") = 3) {
SetFlagOn ("TheFlag")
}
otherwise {
if (GetInt(game, "thecounter") = 3) {
SetFlagOn ("TheFlag")
}
}
Acutally it only works have right..for some reason when i put the commands into function and then try to have a IF statement it does trigger the function
IF flag1 then function
but the function doesnt run then
I kind of gave up trying ot make it work cause flavor text didn't work right.
I mean is that if have a condition to meet before a FUNCTION triggers but when I try it just didn't trigger the function
Like: IF flag on then FUNCTION
But when i meet the condition..it doesn't trigger the function
an example:
using Functions:
<game name="example_game">
<attr name="start" type="script">
integer_variable = GetRandomInt (1, 2)
if (integer_variable = 1) {
hi_function
} else if (integer_variable = 2) {
bye_function
}
</attr>
</game>
<function name="hi_function">
msg ("hi")
</function>
<function name="bye_function">
msg ("bye")
</function>
using an object's Script Attribute:
<game name="example_game">
<attr name="start" type="script">
integer_variable = GetRandomInt (1, 2)
if (integer_variable = 1) {
do (game, "hi_script_attribute") // or: invoke (game.hi_script_attribute)
} else if (integer_variable = 2) {
do (game, "bye_script_attribute") // or: invoke (game.bye_script_attribute)
}
</attr>
<attr name="hi_script_attribute" type="script">
msg ("hi")
</attr>
<attr name="bye_script_attribute" type="script">
msg ("bye")
</attr>
</game>
or, you can do this too:
<game name="example_game">
<attr name="start" type="script">
integer_variable = GetRandomInt (1, 2)
dynamic_hi_bye_function (integer_variable)
</attr>
</game>
<function name="dynamic_hi_bye_function" parameters="integer_parameter">
if (integer_parameter = 1) {
msg ("hi")
} else if (integer_parameter = 2) {
msg ("bye")
}
</function>
and here's this (using delegates: this allows Script Attributes to be able to have Parameters/Arguments and a return type, just like as if it was a Function) as well:
<delegate name="dynamic_hi_bye_delegate" parameters="integer_parameter" />
<game name="example_game">
<attr name="start" type="script">
integer_variable = GetRandomInt (1, 2)
rundelegate (game, "dynamic_hi_bye_script_attribute", integer_variable)
</attr>
<attr name="dynamic_hi_bye_script_attribute" type="dynamic_hi_bye_delegate">
if (integer_parameter = 1) {
msg ("hi")
} else if (integer_parameter = 2) {
msg ("bye")
}
</attr>
</game>