local config = {
walls = {
[1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
[2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
},
levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wallItem = tile:getItemById(wall.id)
if not wallItem then
Game.createItem(wall.id, 1, wall.position)
end
end
end
local tile = Tile(leverPosition)
if tile then
local item = tile:getItemById(config.levers.pulled)
if item then...
- local config = {
- walls = {
- [1] = {position = Position(x, y, z), chance = 100, id = 1033},
- [2] = {position = Position(x, y, z), chance = 20, id = 1033},
- },
- positions = {
- Position(x, y, z),
- Position(x, y, z),
- },
- },
- levers = {notPulled = 1000, pulled = 1001}
- }
Show me your current code, paste it here.
local config = {
walls = {
[1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
[2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
},
positions = {
Position(1289, 998, 7),
Position(1289, 999, 7),
},
levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wall = tile:getItemById(wall.id)
if not wall then
Game.createItem(wall.id, 1, wall.position)
end
end
end
local tile = Tile(leverPosition)
if tile then
local item = tile:getItemById(config.levers.pulled)
if item then
item:transform(config.levers.notPulled)
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getId() == config.levers.notPulled then
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wall = tile:getItemById(wall.id)
if wall and math.random(1, 100) <= wall.chance then
wall:remove()
end
end
end
item:transform(config.levers.pulled)
addEvent(revertThings, 2 * 60 * 1000, item:getPosition())
end
return true
end
local config = {
walls = {
[1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
[2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
},
levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wall = tile:getItemById(wall.id)
if not wall then
Game.createItem(wall.id, 1, wall.position)
end
end
end
local tile = Tile(leverPosition)
if tile then
local item = tile:getItemById(config.levers.pulled)
if item then
item:transform(config.levers.notPulled)
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getId() == config.levers.notPulled then
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wallItem = tile:getItemById(wall.id)
if wallItem and math.random(1, 100) <= wall.chance then
wallItem:remove()
end
end
end
item:transform(config.levers.pulled)
addEvent(revertThings, 2 * 60 * 1000, item:getPosition())
end
return true
end
get code from my last post, this code is not from my last post, because it has previous issue.
local config = {
walls = {
[1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
[2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
},
levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wallItem = tile:getItemById(wall.id)
if not wallItem then
Game.createItem(wall.id, 1, wall.position)
end
end
end
local tile = Tile(leverPosition)
if tile then
local item = tile:getItemById(config.levers.pulled)
if item then
item:transform(config.levers.notPulled)
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getId() == config.levers.notPulled then
for _, wall in ipairs(config.walls) do
local tile = Tile(wall.position)
if tile then
local wallItem = tile:getItemById(wall.id)
if wallItem and math.random(1, 100) <= wall.chance then
wallItem:remove()
end
end
end
item:transform(config.levers.pulled)
addEvent(revertThings, 2 * 60 * 1000, item:getPosition())
end
return true
end