amoxicilina
Member
- Joined
- Jun 25, 2010
- Messages
- 72
- Reaction score
- 11
Hi guys, I'm having a problem with this code, I'm learning.
Problem it does not remove the shelf to release the passage, but when clicking on the lever it changes it to the way it was used but after 1 minute it returns it to its previous itemid, someone could help me I would be very grateful <3.
following faulty code.
Problem it does not remove the shelf to release the passage, but when clicking on the lever it changes it to the way it was used but after 1 minute it returns it to its previous itemid, someone could help me I would be very grateful <3.
following faulty code.
Lua:local Lever_secret = Action() local config = { [30010] = {position = Position(32420, 32352, 9), lever1 = 1345, lever2 = 1346, wellId = 1718, time = 60, revert = true}, [30011] = {position = Position(32298, 32500, 11), lever1 = 1345, lever2 = 1346, wellId = 1718, time = 60, revert = true}, } local function revertWall(wallPosition, leverPosition) local leverItem = Tile(leverPosition):getItemById(config.lever2) if leverItem then leverItem:transform(config.lever1) end Game.createItem(config.wellId, 1, wallPosition) end local function removeWall(position) local tile = position:getTile() if not tile then return end local thing = tile:getItemById(config.wellId) if thing then thing:remove() player:sendCancelMessage('Você tem 1 minuto antes que a passagem se feche.') position:sendMagicEffect(CONST_ME_MAGIC_RED) end end function Lever_secret.onUse(player, item, fromPosition, target, toPosition, isHotkey) local wall = config[item.uid] if item.itemid ~= wall.lever1 then player:sendCancelMessage('A alavanca já foi usada.\nCorra talvez tenha tempo pra encontrar a passagem aberta.') return true end local wall = config[item.uid] removeWall(wall.position) if wall.revert then addEvent(revertWall, wall.time * 1000, wall.position, toPosition) end item:transform(wall.lever2) return true end Lever_secret:uid(30011, 30010) Lever_secret:register()