Waitq: Difference between revisions
Jump to navigation
Jump to search
imported>Bale No edit summary |
imported>Eliteofdelete No edit summary |
||
Line 18: | Line 18: | ||
function_description=This function will initiate a countdown from {{pspan|secs}} seconds to 0, during which time nothing else will be acted on. It essentially pauses a script. This is the "quiet" version, which will not print a countdown on the gCLI during the delay.</p><p>Minimum wait is 1 second, even if {{pspan|secs}} is 0.| | function_description=This function will initiate a countdown from {{pspan|secs}} seconds to 0, during which time nothing else will be acted on. It essentially pauses a script. This is the "quiet" version, which will not print a countdown on the gCLI during the delay.</p><p>Minimum wait is 1 second, even if {{pspan|secs}} is 0.| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=The example adventures 5 times in the castle top floor. Waits a few seconds between adventures to give time time to read messages. Wait silent is used for easier readability.| | |||
code= | |||
<syntaxhighlight> | |||
int[item] items; | |||
int meat; | |||
buffer fight; | |||
for x from 1 to 5 { | |||
fight = visit_url(to_url($location[The Castle in the Clouds in the Sky (Top Floor)])); | |||
repeat { | |||
if (contains_text(fight, "choice.php")) { //Check to see if in a choice adventure | |||
cli_execute("choice-goal"); //Clear the choice adventure | |||
fight = visit_url(to_url($location[The Castle in the Clouds in the Sky (Top Floor)])); | |||
} | |||
} until (!contains_text(fight, "choice.php")); | |||
fight = run_combat(); | |||
if (have_effect($effect[beaten up]) == 0) { | |||
items = extract_items(fight); | |||
meat = extract_meat(fight); | |||
print("You acquired "+meat+" meat, and the following items:", "green"); | |||
foreach it, number in items | |||
print(""+number+", "+it, "blue"); | |||
waitq(4); | |||
} | |||
else abort("You lost the fight :("); | |||
} | |||
</syntaxhighlight>| | |||
}}| | |||
see_also={{SeeAlso|wait}}| | see_also={{SeeAlso|wait}}| | ||
cli_equiv=The CLI command "waitq" functions the same and can be used to pause basic .txt scripts.| | cli_equiv=The CLI command "waitq" functions the same and can be used to pause basic .txt scripts.| |
Latest revision as of 23:05, 21 January 2015
Function Syntax
- secs is the number of seconds you want to delay further action.
This function will initiate a countdown from secs seconds to 0, during which time nothing else will be acted on. It essentially pauses a script. This is the "quiet" version, which will not print a countdown on the gCLI during the delay.
Minimum wait is 1 second, even if secs is 0.
Code Samples
The example adventures 5 times in the castle top floor. Waits a few seconds between adventures to give time time to read messages. Wait silent is used for easier readability.
int[item] items;
int meat;
buffer fight;
for x from 1 to 5 {
fight = visit_url(to_url($location[The Castle in the Clouds in the Sky (Top Floor)]));
repeat {
if (contains_text(fight, "choice.php")) { //Check to see if in a choice adventure
cli_execute("choice-goal"); //Clear the choice adventure
fight = visit_url(to_url($location[The Castle in the Clouds in the Sky (Top Floor)]));
}
} until (!contains_text(fight, "choice.php"));
fight = run_combat();
if (have_effect($effect[beaten up]) == 0) {
items = extract_items(fight);
meat = extract_meat(fight);
print("You acquired "+meat+" meat, and the following items:", "green");
foreach it, number in items
print(""+number+", "+it, "blue");
waitq(4);
}
else abort("You lost the fight :(");
}
CLI Equivalent
The CLI command "waitq" functions the same and can be used to pause basic .txt scripts.