Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- /c remote.call("cargo-ship","placeDeepOil",event)
- local interface = {}
- -- creat deep sea oil
- function interface.placeDeepOil(e)
- deep_tiles = game.surfaces[1].count_tiles_filtered{area=e.area, name = "deepwater"}
- math.randomseed(e.tick)
- if deep_tiles == 1024 then
- freq = 0.03
- if settings.global["oil_frequency"].value == choices.oil_freq.none then
- freq = 0
- elseif settings.global["oil_frequency"].value == choices.oil_freq.v_low then
- freq = 0.0075
- elseif settings.global["oil_frequency"].value == choices.oil_freq.low then
- freq = 0.015
- elseif settings.global["oil_frequency"].value == choices.oil_freq.high then
- freq = 0.06
- elseif settings.global["oil_frequency"].value == choices.oil_freq.v_high then
- freq = 0.12
- end
- freq = freq * 1.25
- mult = 1
- if settings.global["oil_richness"].value == choices.oil_rich.v_poor then
- mult = 0.3
- elseif settings.global["oil_richness"].value == choices.oil_rich.poor then
- mult = 0.7
- elseif settings.global["oil_richness"].value == choices.oil_rich.good then
- mult = 1.8
- elseif settings.global["oil_richness"].value == choices.oil_rich.v_good then
- mult = 3
- end
- r = math.random()
- if r < freq then
- -- create oil in inner part of tile to avoid deep oil too close to land
- local x = math.random(-10,10)
- local y = math.random(-10,10)
- local pos = {e.area.left_top.x+16+x, e.area.left_top.y+16+y}
- local a = (1+freq/(r+(freq/50)))*750000*mult
- game.surfaces[1].create_entity{name="deep_oil", amount=a, position=pos}
- end
- end
- end
- function init()
- if global.or_power_generator == nil then
- global.or_power_generator = {}
- end
- end
- script.on_init(function()
- init()
- end)
- script.on_configuration_changed(function(data)
- init()
- end)
- function on_creation(event)
- local name = event.created_entity.name
- if name == "or_power" then
- table.insert(global.or_power_generator, event.created_entity)
- end
- end
- script.on_event(defines.events.on_built_entity, on_creation)
- script.on_event(defines.events.on_robot_built_entity, on_creation)
- function powerOilRig(e)
- if e.tick % 60 == 0 then
- for _, generator in pairs(global.or_power_generator) do
- generator.fluidbox[1] = {name="steam", amount = 100, temperature=165}
- end
- end
- end
- remote.add_interface("cargo-ship", interface)
- script.on_event("enter_ship", OnEnterShip)
- script.on_event(defines.events.on_entity_died, OnDeleted)
- script.on_event(defines.events.on_player_mined_entity, OnDeleted)
- script.on_event(defines.events.on_robot_mined_entity, OnDeleted)
- script.on_event(defines.events.on_chunk_generated, interface.placeDeepOil)
- script.on_event(defines.events.on_built_entity, spawnInvisibles)
- script.on_event(defines.events.on_tick, powerOilRig)
- -- long reach
- script.on_event(defines.events.on_runtime_mod_setting_changed, applyChanges)
- script.on_event(defines.events.on_player_cursor_stack_changed, increaseReach)
- script.on_event(defines.events.on_player_died, deadReach)
Advertisement
Add Comment
Please, Sign In to add comment