Page 1 of 1

[Solved] [0.14.x] Help with adding unlimited power source

Posted: Thu Dec 08, 2016 3:53 am
by pinecoffin
Hi All,

I've been trying to figure this out myself (I like to try and do these things myself as I learn much better that way :lol: ) but just can't get this one, and it's driving me nuts.

What I have:

I have made a fixed sized sandbox test area. I usually just dump a heap of solar for power but noticed on the Production Challenge scenario there is a electric-energy-interface providing power.

What I want to do:


Have an electric-energy-interface in my map and set the properties as I like ie unlimited power without having to enable a mod.

Is there a reasonably simple way of adding to the control.lua to do this? Or a reasonably simple way to do this?

This is my first post so cheers for any help.

Edit:

So for anyone interested I finally figured it out.

Code: Select all

script.on_init(function()
  global.p_providers = {}
  for i=1,16,1 do
    local p_provider = game.get_entity_by_tag("Tag" .. i)
    p_provider.destructible = false
    p_provider.minable = false
    p_provider.rotatable = false
    p_provider.power_production = 5 * 10^9
    p_provider.power_usage = 0
    p_provider.electric_buffer_size = 5 * 10^9
    p_provider.energy = 2.55 * 10^9
    p_provider.electric_output_flow_limit = 50000000
    p_provider.electric_input_flow_limit = 50000000
    global.p_providers[i] = p_provider
  end
  global.p_substations = {}
  for i=17,24,17 do
    local p_substation = game.get_entity_by_tag("Tag" .. i)
    p_substation.destructible = false
    p_substation.minable = false
    p_substation.rotatable = false
    global.p_substations[i] = p_substation
  end
  p_pole = game.get_entity_by_tag("Tag0")
  p_pole.destructible = false
  p_pole.minable = false
  p_pole.rotatable = false
end)
Even better it's for multiple tagged items.

Now to figure out how to export a map to a map_settings.lua file...

Re: [0.14.x] Help with adding unlimited power source

Posted: Thu Dec 08, 2016 4:18 am
by Ranakastrasz

Code: Select all

 elseif entity.name == "electric-energy-interface" then
        local v = game.surfaces[1].create_entity({force = force, name = entity.name, position = {entity.position[1]+offset_x, entity.position[2]+offset_y}})
        v.destructible = false
        v.minable = false
        v.rotatable = false
        v.power_production = 5 * 10^9
        v.power_usage = 0
        v.electric_buffer_size = 5 * 10^9
        v.energy = 2.55 * 10^9
        v.electric_output_flow_limit = 50000000
        v.electric_input_flow_limit = 50000000
      elseif entity.name == "big-electric-pole" then

This appears to be the part you are talking about. Not really sure how to make that into a command.

Re: [0.14.x] Help with adding unlimited power source

Posted: Thu Dec 08, 2016 6:51 am
by pinecoffin
Thanks Ranakastrasz, I've been trying to figure out how to use that info. It looks exactly like what I need but I don't know how to use it.