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

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)
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.
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.
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?