text
stringlengths
0
299
-- Events
-- BlockPlace
Parameters
player: Player | nil
Player placing the block (if placed by a player).
position: Vector3
Position in the world the block is being placed at.
blockType: ItemType
The type of the block being placed
cancelled: bool [modifiable]
If set to true, the block place will be denied.
-- Here is a script using this event:
-- Fortify all blocks placed by players to Stone Brick
Events.BlockPlace(function(event)
-- Only fortify player blocks
if (not event.player) then
return
end
-- Only replace wool blocks
if not string.includes(event.blockType, "wool") then
return
end
BlockService.placeBlock(ItemType.STONE_BRICK, event.position)
SoundService.playSound(Sound.FORTIFY_BLOCK, event.position)
event.cancelled = true
end)
-- BlockBreak
Parameters
player: Player | nil
Player who broke the block.
position: Vector3
Position in the world the block was broken at.
blockType: ItemType
The type of the block being placed
-- Here is an example of a script using this event:
Events.BlockBreak(function(event)
if (not event.player) then
return
end
-- Only consider ceramic block breaks
if (event.blockType == ItemType.BLASTPROOF_CERAMIC) then
InventoryService.giveItem(event.player, ItemType.FIREBALL, 1, true)
end
end)
-- BedAlarmTriggered
Parameters
intruder: Player
The intruder player that triggered the bed alarm.
team: Team
The team whose bed alarm went off.
-- Here is an example of a script that uses this event:
-- Send out a broadcast to the game server when a bed alarm is triggered
Events.BedAlarmTriggered(function(event)
local alert = event.intruder.displayName .. " invaded " .. event.team.name .. "'s base!"
MessageService.broadcast(alert)
end)
-- ConsumeItem
Parameters
player: Player
The player that consumed the item.
itemType: ItemType
The item that was consumed by the player.
cancelled: bool [modifiable]
If set to true the item consume will be cancelled.
-- Here is a script that uses this event:
-- Make a player jump twice as high every time they eat a pie item
Events.ConsumeItem(function(event)
if (event.item == ItemType.PIE) then
event.player:registerJumpHeightMultiplier("pie_jumps", 2)
end
end)
-- Enchant
Parameters
player: Player
The player who researched the enchant.
enchant: EnchantType
Type of enchant researched by the player.
cancelled: bool [modifiable]