-local bombs
+local waterbombs
local replaceableTiles = {
["water"] = "grass-1",
["deepwater"] = "grass-1",
script.on_configuration_changed(function(data)
- if global.waterbombs ~= nil then
+ if waterbombs ~= nil then
script.on_event(defines.events.on_tick, tickBombs)
end
end)
script.on_load(function(event)
- if global.waterbombs ~= nil then
+ if waterbombs ~= nil then
script.on_event(defines.events.on_tick, tickBombs)
end
end)
script.on_event(defines.events.on_built_entity, function(event)
- if event.created_entity.name == "waterbomb" then
- global.waterbombs = {}
+ if event.entity.name == "waterbomb" then
+ waterbombs = {}
for _, surface in pairs(game.surfaces) do
for _, entity in pairs(surface.find_entities_filtered{name="waterbomb"}) do
- table.insert(global.waterbombs, entity)
+ table.insert(waterbombs, entity)
end
end
script.on_event(defines.events.on_tick, tickBombs)
function tickBombs(event)
if event.tick % 20 == 0 then
- for k,e in pairs(global.waterbombs) do
+ for k,e in pairs(waterbombs) do
if not e.valid then
- table.remove(global.waterbombs, k)
+ table.remove(waterbombs, k)
elseif e.energy > 49000000 then
local epos, x, y, distX, distY, surface
-- bomb explodes
e.destroy()
- table.remove(global.waterbombs, k)
+ table.remove(waterbombs, k)
-- water is created
createWater(x, y, explosionRadius, surface)
end
-- nothing more to be exploded. Stop ticking.
- if #global.waterbombs == 0 then
- global.waterbombs = nil
+ if #waterbombs == 0 then
+ waterbombs = nil
script.on_event(defines.events.on_tick, nil)
end
end
{
"name": "Waterbomb",
- "version": "1.1.3",
+ "version": "2.0.0",
"title": "Dihydrogen Monoxide Bomb (Waterbomb)",
"author": "someone1337",
"homepage": "https://git.somenet.org/factorio/Waterbomb.git",
"description": "Use explosions/bombs to create water. (Originally 'Landfill' by Rseding91)",
- "dependencies": ["base>=1.1.0"],
- "factorio_version": "1.1"
+ "factorio_version": "2.0",
+ "dependencies": ["base>=2.0.0"]
}
type = "recipe",
name = "waterbomb",
energy_required = 5,
- enabled = "false",
+ enabled = false,
category = "crafting-with-fluid",
ingredients =
{
- {"steel-plate", 32},
- {"electric-engine-unit", 4},
- {"processing-unit", 1},
+ {type="item", name="steel-plate", amount=32},
+ {type="item", name="electric-engine-unit", amount=4},
+ {type="item", name="processing-unit", amount=1},
{type="fluid", name="water", amount=32},
- {"explosives", 24},
+ {type="item", name="explosives", amount=24}
},
- result = "waterbomb"
+ results = {{type="item", name="waterbomb", amount=1}}
}
})