Scripting
Script Structure
onEquipItem(player, item, slot)
function onEquipItem(player, item, slot) -- Only allow myself to equip the item if player:getName() == "Delusion" then return true end return false end
onDeEquipItem(player, item, slot)
function onDeEquipItem(player, item, slot) -- Disallow de-equip for some arbitrary condition met with a player's storage value if player:getStorageValue(123123) == 1 then return false end return true end
onStepIn(creature, item, position, fromPosition)
function onStepIn(creature, item, position, fromPosition) -- Push the creature back if they are not a player if not creature:isPlayer() then creature:teleportTo(fromPosition, true) end end
onStepOut(creature, item, position, fromPosition)
function onStepOut(creature, item, position, fromPosition) -- Send a simple magic effect trailing the creature fromPosition:sendMagicEffect(CONST_ME_MAGIC_RED) end
onAddItem(moveitem, tileitem, pos)
local accepted_items = {2148, 2160} function onAddItem(moveitem, tileitem, pos) -- Only allow gold & crystal coins to be thrown if table.contains(accepted_items, moveitem:getId()) then return true end return false end
onRemoveItem(moveitem, tileitem, pos)
function onRemoveItem(moveitem, tileitem, pos) local tile = Tile(pos) -- Allow item to be removed if there are no creatures on top of the tile if tile and tile:getCreatureCount() == 0 then return true end return false end
Last updated