TFS 1.2. So i wrote this code based on Xikini lever system with few adjustements, now im trying to write a lever press sequences for example have to be pressed accordingly for it to remove the object for example
Position(230, 365, 7), have to be pressed first
Position(220, 372, 7), this second
Position(240, 368, 7) this third
Position(233, 366, 7), this is last so its like a tricky puzzle
If they faill the sequence, the levers go back to their default preset which is left 20992 saying you failled, so they could repeat it again
Position(230, 365, 7), have to be pressed first
Position(220, 372, 7), this second
Position(240, 368, 7) this third
Position(233, 366, 7), this is last so its like a tricky puzzle
If they faill the sequence, the levers go back to their default preset which is left 20992 saying you failled, so they could repeat it again
LUA:
local levers = {left = 20992, right = 20993}
local leverActionIds = {4650, 4651, 4652, 4653}
local leverPositions = {
Position(220, 372, 7),
Position(230, 365, 7),
Position(233, 366, 7),
Position(240, 368, 7)
}
local targetPosition = Position(222, 366, 7)
local targetItemId = 1100
local resetTime = 1 * 60 * 1000 -- 1 minutes in milliseconds. Restore deleted object
local function areAllLeversClicked()
for _, position in ipairs(leverPositions) do
local tile = Tile(position)
if not tile then
return false
end
local lever = tile:getItemById(levers.right)
if not lever then
return false
end
end
return true
end
local function resetLeversAndObject()
for _, position in ipairs(leverPositions) do
local tile = Tile(position)
if tile then
local lever = tile:getItemById(levers.right)
if lever then
lever:transform(levers.left)
end
end
end
local tile = Tile(targetPosition)
if tile then
Game.createItem(targetItemId, 1, targetPosition)
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
item:transform(item.itemid == levers.left and levers.right or levers.left)
if areAllLeversClicked() then
local tile = Tile(targetPosition)
if tile then
local object = tile:getItemById(targetItemId)
if object then
object:remove()
player:sendTextMessage(MESSAGE_INFO_DESCR, "The object has been removed.")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Theres nothing to remove at the target position.")
end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "The target position does not exist.")
end
addEvent(resetLeversAndObject, resetTime)
end
return true
end