MorganaSacani
Active Member
- Joined
- Sep 20, 2022
- Messages
- 87
- Solutions
- 1
- Reaction score
- 32
I need help shortening the script.
I know that there is a possibility to do it by loop, but I don't know how.
I need this algorithm to scan three bodies at three specific positions.
If all three bodies are in the correct position, the script will work.
I know that there is a possibility to do it by loop, but I don't know how.
I need this algorithm to scan three bodies at three specific positions.
If all three bodies are in the correct position, the script will work.
Lua:
local config = {
goToPosition = { x = 100, y = 100, z = 7 },
corpseId = 2821,
corpse1 = { x = 100, y = 100, z = 7 },
corpse2 = { x = 100, y = 100, z = 7 },
corpse3 = { x = 100, y = 100, z = 7 },
}
local check, c1, c2, c3 = 0, 0, 0, 0
function onStepIn(creature, item, position, fromPosition)
local player = Player(creature)
if not player:isPlayer() then return false end
local corpse1Item = Tile(config.corpse1):getItemById(config.corpseId)
if corpse1Item then c1 = 1 end
local corpse2Item = Tile(config.corpse2):getItemById(config.corpseId)
if corpse2Item then c2 = 1 end
local corpse3Item = Tile(config.corpse3):getItemById(config.corpseId)
if corpse3Item then c3 = 1 end
check = c1 + c2 + c3
if check == 3 then
player:teleportTo(config.goToPosition)
corpse1Item:remove()
corpse2Item:remove()
corpse3Item:remove()
end
check = 0
return true
end