Crab.waitFor*() (Idea)

From 8x9craft
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
[75adf6bef0425196a6eba940] 2024-03-29 13:01:41: Fatal exception of type "Error"

Navigation menu