Page 1 of 1
Creating a Building That Requires No Power?
Posted: Sun Jan 25, 2015 2:44 am
by TheLastRonin
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
.
Re: Creating a Building That Requires No Power?
Posted: Sun Jan 25, 2015 3:43 pm
by FreeER
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
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)
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).
Re: Creating a Building That Requires No Power?
Posted: Sun Jan 25, 2015 4:07 pm
by TheLastRonin
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
Re: Creating a Building That Requires No Power?
Posted: Sun Jan 25, 2015 4:28 pm
by FreeER
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
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)
TheLastRonin wrote:Sorry I am a code noob.
Everyone starts that way, including me
Re: Creating a Building That Requires No Power?
Posted: Wed Jan 28, 2015 6:02 pm
by TheLastRonin
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.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)
TheLastRonin wrote:Sorry I am a code noob.
Everyone starts that way, including me
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?
Re: Creating a Building That Requires No Power?
Posted: Wed Jan 28, 2015 6:18 pm
by FreeER
TheLastRonin wrote:So how would I change the code so that instead of giving energy it inserts 1 supercoal when built?
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}"