Crab.waitFor*() (Idea)

From 8x9craft
Revision as of 03:10, 23 February 2017 by Maciek (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Enable synchronous waiting for events. This would allow to write programs without minding the state:

Examples

while (true) {
    crab.waitForChat('open');
    crab.setRedstoneOutput('back');
    crab.sleep(10);
    crab.clearRedstoneOutput('back');
    // and the door open
}
crab.say('Waiting for the signal');
crab.waitForChat('go!');
// start race
crab.say('Where should I go?');
var direction = crab.waitForChat();
if (direction == 'left') crab.stepLeft();
else if (direction == 'right') crab.stepRight();
else crab.say("I didn't understand that");

See also

Navigation menu

Internal error

Jump to: navigation, search
[7f141d1bebae8648d4c27994] 2024-03-28 13:38:59: Fatal exception of type "Error"

Navigation menu