I'm using the Ore Expansion 1.0.1 mod as a base since I'm pretty new to Lua but so far I haven't managed to do so successfully as I'm getting "specified surface doesn't have a chart".
Could someone with some Lua experience give me a hand? I've tried the wiki and googling around but no luck so far.
Troublesome line is the last one.
Code: Select all
require "defines"
if not orexpmult then orexpmult = {} end
game.on_event(defines.events.on_chunk_generated, function(event)
local distX = math.abs(event.area.left_top.x)
local distY = math.abs(event.area.left_top.y)
local mult = 1 + (math.floor(math.sqrt((distX * distX) + (distY * distY))) / 1024)
orexpmult = mult
--game.player.print(distX)
--game.player.print(distY)
--game.player.print(orexpmult)
if mult > 1 then
for _,ore in pairs(event.surface.find_entities_filtered({area = {{event.area.left_top.x, event.area.left_top.y}, {event.area.right_bottom.x, event.area.right_bottom.y}}, type="resource"})) do
ore.amount = math.floor(ore.amount * mult)
end
end
game.forces.player.chart(event.surface,{lefttop = {x = event.area.left_top.x, y = event.area.left_top.y}, rightbottom = {x = event.area.right_bottom.x, y = event.area.right_bottom.y}})
end)