Difference between revisions of "Crab.onBlock()"

From 8x9craft
Jump to: navigation, search
(See also)
(Examples)
Line 14: Line 14:
 
     crab.say('A block of type ' + block.fullName + ' has changed somewhere around me');
 
     crab.say('A block of type ' + block.fullName + ' has changed somewhere around me');
 
});
 
});
crab.handleEvents();
+
while(true){
 +
    crab.sleep(1)
 +
}
 
</source>
 
</source>
  

Revision as of 02:10, 14 August 2017

function onBlock(callback: Function): void

Set a function as an event listener that is run each time a block has been changed around the crab. That includes blocks in front, behind, to the left, to the right, above and below the crab.

Parameters:

callback: Function - function with signature (block: BlockInfo, pos: Vector3i) => void that gets called after occurrence of the event.

Examples

// Respond to a change in a block nearby.
crab.onBlock(function(block) {
    crab.say('A block of type ' + block.fullName + ' has changed somewhere around me');
});
while(true){
    crab.sleep(1)
}

See also

Navigation menu

Internal error

Jump to: navigation, search
[11bec4501bc981fa06c6d57d] 2024-03-28 12:45:58: Fatal exception of type "Error"

Navigation menu