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

Place to share custom user maps, scenarios and campaigns.
Post Reply
pinecoffin
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 02, 2016 7:37 am
Contact:

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

Post by pinecoffin » Thu Dec 08, 2016 3:53 am

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...
Last edited by pinecoffin on Fri Dec 09, 2016 5:01 pm, edited 1 time in total.

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 1993
Joined: Thu Jun 12, 2014 3:05 am
Contact:

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

Post by Ranakastrasz » Thu Dec 08, 2016 4:18 am

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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

pinecoffin
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jul 02, 2016 7:37 am
Contact:

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

Post by pinecoffin » Thu Dec 08, 2016 6:51 am

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.

Post Reply

Return to “Maps and Scenarios”

Who is online

Users browsing this forum: No registered users