developer_center:developer_editor:script:block_event
Table of Contents
Block Class
How to Write Event
ScriptSupportEvent:registerEvent([[EventName]],callbackFunctionName)
Example
function Placed (e) local blockid = e.blockid local x,y,z = e.x,e.y,e.z end ScriptSupportEvent:registerEvent([[Block.Add]],Placed)
Event List
EventName | Parameters | Description |
---|---|---|
Block.Add | blockid, x, y, z | Triggered when a block with the specified block type is added at the given coordinates (x, y, z). |
Block.DestroyBy | eventobjid, blockid, x, y, z | Event that occurs when local blocks of the specified type are destroyed. It provides information about the event player (eventobjid), the block type (blockid), and the coordinates (x, y, z) of the destroyed block. |
Block.Dig.Begin | eventobjid, blockid, x, y, z | Triggered when any block is mined. It provides information about the event player (eventobjid), the block type being mined (blockid), and the coordinates (x, y, z) of the block being mined. |
Block.Dig.Cancel | eventobjid, blockid, x, y, z | Event that occurs when the mining action on a block is canceled. It provides information about the event player (eventobjid), the block type being mined (blockid), and the coordinates (x, y, z) of the block being mined. |
Block.Dig.End | eventobjid, blockid, x, y, z | Triggered when a block is successfully mined. It provides information about the event player (eventobjid), the block type being mined (blockid), and the coordinates (x, y, z) of the mined block. |
Block.Remove | blockid, x, y, z | Event that occurs when a block with the specified block type is removed at the given coordinates (x, y, z). |
Block.Trigger | eventobjid, blockid, x, y, z | Event that occurs when a block with the specified block type is triggered and becomes active or powered. It provides information about the event player (eventobjid), the block type (blockid), and the coordinates (x, y, z) of the triggered block. |
Api List
Class:apiName(Parameters) | Return | Description |
---|---|---|
Block:isSolidBlock(x, y, z: number) | ErrorCode.OK, isSolid: boolean | Check if it is a solid block |
Block:isLiquidBlock(x, y, z: number) | ErrorCode.OK, isLiquid: boolean | Check if it is a liquid block |
Block:isAirBlock(x, y, z: number) | ErrorCode.OK, isAir: boolean | Check if it is an air block |
Block:getBlockID(x, y, z: number) | ErrorCode.OK, id: number | Get the block ID at the specified location |
Block:setBlockAll(x, y, z: number, blockid: number, data: number) | ErrorCode.OK | Set block data and update + notify |
Block:getBlockData(x, y, z: number) | ErrorCode.OK, data: number | Get block data |
Block:destroyBlock(x, y, z: number, dropitem: boolean) | ErrorCode.OK | Destroy the block with an option to drop items (default false, not drop) |
Block:placeBlock(blockid: number, x, y, z: number, face: number, color: number) | ErrorCode.OK | Place the block |
Block:replaceBlock(blockid: number, x, y, z: number, face: number, color: number) | ErrorCode.OK | Replace the block |
Block:setBlockAllForUpdate(x, y, z: number, blockid: number) | ErrorCode.OK | Set block data to notify surrounding blocks |
Block:setBlockAllForNotify(x, y, z: number, blockid: number) | ErrorCode.OK | Set block data to update the current position block |
Block:setBlockSettingAttState(blockid: number, attrtype: BLOCKATTR_ENABLE, switch: boolean) | ErrorCode.OK | Set the block's attribute status |
Block:getBlockSettingAttState(blockid: number, attrtype: BLOCKATTR_ENABLE) | ErrorCode.OK, switch: boolean | Get the block's attribute status |
Block:getBlockSwitchStatus(pos: table{x, y, z}) | ErrorCode.OK, isactive: boolean | Get the switch state of the functional block |
Block:setBlockSwitchStatus(pos: table{x, y, z}, isactive: boolean) | ErrorCode.OK | Set the switch state of the functional block |
Block:getBlockDataByDir(blockid: number, dir: number) | ErrorCode.OK, data: number | Get the block data value based on the direction |
Block:getBlockPowerStatus(pos: table{x, y, z}) | ErrorCode.OK, isactive: boolean | Get the power-on state of the block |
Block:randomBlockID() | ErrorCode.OK, blockid: number | Get a random block ID |
Block:GetBlockDefName(blockid: number) | ErrorCode.OK, name: string | Get the name of the block |
Block:GetBlockDefDesc(blockid: number) | ErrorCode.OK, desc: string | Get the description of the block |
Block:GetBlockFacade(blockid: number) | ErrorCode.OK, faced: number | Get the appearance of the block |
Block:PlayAct(x, y, z: number, animid: number, playmode: number) | ErrorCode.OK | Play the animation for the miniature cube |
Block:ReplaceBluePrint(x, y, z: number, blueprint: string, angle: number, mirror: boolean, placeMode: boolean) | ErrorCode.OK | Place the blueprint at the specified location |
developer_center/developer_editor/script/block_event.txt · Last modified: 2023/07/18 03:18 by hhuxx1