Lopaskurwa
Well-Known Member
- Joined
- Oct 6, 2017
- Messages
- 912
- Solutions
- 2
- Reaction score
- 50
Anyone got a switch system with this feature. 4 switches that have to be pressed at the same time by 4 players, can be a small delay or something but basically all 4 switches have to be clicked so X item is removed from the game and after 2 minutes switches go back to their original presset and the X item appears back
Post automatically merged:
Found this Xikini lever system, but cant get the part if timing, and all 4 levers clicked part to remove the objectAnyone got a switch system with this feature. 4 switches that have to be pressed at the same time by 4 players, can be a small delay or something but basically all 4 switches have to be clicked so X item is removed from the game and after 2 minutes switches go back to their original presset and the X item appears back
LUA:
local levers = {left = 20992, right = 20993}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object", "replace", position, {itemid_from, itemid_to}}
[4650] = {"object", "remove", Position(222, 366, 7), 1100, "south"},
[4651] = {"object", "remove", Position(222, 366, 7), 1100, "south"},
[4652] = {"object", "remove", Position(222, 366, 7), 1100, "south"},
[4653] = {"object", "remove", Position(222, 366, 7), 1100, "south"},
}
local relocateDirections = {
["north"] = {0, -1},
["east"] = {1, 0},
["south"] = {0, 1},
["west"] = {-1, 0},
}
local function transposeFields(fromPosition, toPosition, transpose)
local tile = Tile(fromPosition)
if tile then
local items = tile:getItems()
if items then
for i, item in ipairs(items) do
if transpose == true then
item:moveTo(toPosition)
else
item:remove()
end
end
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local item_id = item.itemid
local index = config[item.actionid]
local tile = Tile(index[3])
-- add
if index[2] == "add" and item_id == levers.left or index[2] == "remove" and item_id == levers.right then
if index[1] == "object" then
local relocatePosition = Position(index[3].x + relocateDirections[index[5]][1], index[3].y + relocateDirections[index[5]][2], index[3].z)
tile:relocateTo(relocatePosition)
transposeFields(index[3], relocatePosition, true)
Game.createItem(index[4], 1, index[3])
elseif index[1] == "floor" then
Game.createTile(index[3], true)
Game.createItem(index[4], 1, index[3])
end
-- remove
elseif index[2] == "remove" and item_id == levers.left or index[2] == "add" and item_id == levers.right then
if index[1] == "object" then
local object = tile:getItemById(index[4])
object:remove()
elseif index[1] == "floor" then
local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
tile:relocateTo(relocatePosition)
transposeFields(index[3], relocatePosition, false)
tile:getGround():remove()
end
-- replace
elseif index[2] == "replace" then
local transformTo = tile:getItemCountById(index[4][1]) > 0 and 2 or 1
local object = tile:getItemById(transformTo == 2 and index[4][1] or index[4][2])
object:transform(index[4][transformTo])
if index[1] == "floor" and index[5][transformTo] == true then
local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
tile:relocateTo(relocatePosition)
transposeFields(index[3], relocatePosition, false)
end
end
item:transform(item_id == levers.left and levers.right or levers.left)
return true
end
Last edited: