I'm trying to completely remove the power requirements for the lab. If I just comment out the power stuff it seems to throw up errors... If I reduce power to 0watts it still needs 'power' according to the game... Is there any way of having a completely un-powered buildings?
Please take the time to respond. I am trying to do a major overhaul mod and this has been a huge roadblock for me... I'm at a total loss .
Creating a Building That Requires No Power?
-
- Inserter
- Posts: 23
- Joined: Thu Jan 22, 2015 8:22 pm
- Contact:
Re: Creating a Building That Requires No Power?
The way Factorio is designed in C++ most entities require power, but if you can make it require 0 power (can't remember off the top of my head if that works) then you could use control.lua to give that building 1 energy when it's created. That would satisfy it's power need (since it doesn't ever use that power). It's a hack sure, but I've used uglier ones
The alternative, if you can't set it not use energy, would be either filling it's energy constantly or creating an invisible entity that could do so (solar panel + accumulator?) right on top of it (along with a pole with a very small range).
Code: Select all
game.onevent(defines.events.onbuiltentity, function(event)
event.createdentity.energy = 1
end)
game.onevent(defines.events.onrobotbuiltentity, function(event)
event.createdentity.energy = 1 -- I'm assuming this is createdentity as well, could test with game.player.print(serpent.block(event))
end)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
-
- Inserter
- Posts: 23
- Joined: Thu Jan 22, 2015 8:22 pm
- Contact:
Re: Creating a Building That Requires No Power?
Would I just paste that code into control? How would I link it up to my entity? Sorry I am a code noob.
The entity is called alchemical-lab
The entity is called alchemical-lab
Re: Creating a Building That Requires No Power?
The previous code would add 1 energy to all created entities, to make it only target your entity you'd add an if statement checking the name like so:
And yes, this would be pasted into the control.lua
And yes, this would be pasted into the control.lua
Code: Select all
require "defines" -- makes defines table with events available
game.onevent(defines.events.onbuiltentity, function(event)
if event.createdentity.name == "alchemical-lab" then
event.createdentity.energy = 1
end
end)
game.onevent(defines.events.onrobotbuiltentity, function(event)
-- I'm assuming this is createdentity as well, could test with game.player.print(serpent.block(event))
if event.createdentity.name == "alchemical-lab" then
event.createdentity.energy = 1
end
end)
Everyone starts that way, including meTheLastRonin wrote:Sorry I am a code noob.
-
- Inserter
- Posts: 23
- Joined: Thu Jan 22, 2015 8:22 pm
- Contact:
Re: Creating a Building That Requires No Power?
That didn't work but I had another idea... I can turn the well into a burner and then simply insert a new object that has ridiculous energy output while the well has only '0.1' energy need. So how would I change the code so that instead of giving energy it inserts 1 supercoal when built?FreeER wrote:The previous code would add 1 energy to all created entities, to make it only target your entity you'd add an if statement checking the name like so:
And yes, this would be pasted into the control.luaCode: Select all
require "defines" -- makes defines table with events available game.onevent(defines.events.onbuiltentity, function(event) if event.createdentity.name == "alchemical-lab" then event.createdentity.energy = 1 end end) game.onevent(defines.events.onrobotbuiltentity, function(event) -- I'm assuming this is createdentity as well, could test with game.player.print(serpent.block(event)) if event.createdentity.name == "alchemical-lab" then event.createdentity.energy = 1 end end)
Everyone starts that way, including meTheLastRonin wrote:Sorry I am a code noob.
Re: Creating a Building That Requires No Power?
instead of "event.createdentity.energy = 1" you'd use "event.createdentity.insert{name='super-coal', count=1}", if that didn't automatically go into the fuel slot (usually does, but thought I'd mention it) you'd use "event.createdentity.getinventory(defines.inventory.fuel).insert{name='super-coal', count=1}"TheLastRonin wrote:So how would I change the code so that instead of giving energy it inserts 1 supercoal when built?