I removed a lot of the stuff because I only use two belts so I thought it was something I did. I put back the unchanged version and I'm still getting this error. Let me know if you need to see the whole function. Any help would be greatly appreciated!
function OnTick(_Event)
if game.tick%30 == 0 then
local toRemove = {}
ToRemove = {}
for i, iLR_Entity in pairs(glob.LRT) do
if not iLR_Entity.valid then
table.insert(ToRemove, i)
end
end
for _, e in pairs(ToRemove) do
table.remove(glob.LRT, e)
end
for _, iLR_Entity in pairs(glob.LRT) do
local entityDirection = iLR_Entity.direction
local entitySettings = __EntitySettings[iLR_Entity.name][entityDirection]
local scanExpand = 0
scanArea = GetScanArea(entityDirection, iLR_Entity.position, 0, scanExpand)
local scan =
{
left = {result = game.findentitiesfiltered{name = "item-on-ground", area = scanArea.left}},
right = {result = game.findentitiesfiltered{name = "item-on-ground", area = scanArea.right}}
}
for sideName, side in pairs(scan) do
for _, item in pairs(side.result) do
local newDistance = 0
local direction = entityDirection
if entitySettings.spec == nil then
operSideName = entitySettings.operSide
elseif entitySettings.spec == "splitt" then
local randomPozitionID = math.random(0,1)
if randomPozitionID == 0 then
operSideName = "right"
else
operSideName = "left"
end
end
local newPosT = GetNewPosition(direction, iLR_Entity.position, newDistance)
local newPos = {x = newPosT[operSideName].x, y = newPosT[operSideName].y}
local possiblePos = game.findnoncollidingposition("item-on-ground", newPos, 0.01, 0.01)
if possiblePos then
game.createentity{name = "item-on-ground", position = possiblePos, stack = {name = item.stack.name, count = item.stack.count}}
item.destroy()
end
end
end
end
end
end