[Request] Deevolution script
[Request] Deevolution script
I would like to request that someone makes a script that would track the number of (mod) furnaces put down and keep track of when each finishes an item. Each time an item would be finished the aliens would de-evolve. I am only requesting the script, because i can make rest of the mod myself.
Re: [Request] Deevolution script
Here, have some untested code that might not even remotely work :
(Although even if it doesn't work it'll probably get the idea across)
(Although even if it doesn't work it'll probably get the idea across)
Code: Select all
game.onload(function() OnLoad() end)
game.oninit(function() OnLoad() end)
game.ontick(function() OnTick() end)
game.onbuiltentity(function(entity) OnBuilt(entity) end)
game.onrobotbuiltentity(function(entity) OnBuilt(entity) end)
game.onentitydied(function(entity) OnRemoved(entity) end)
game.onpreplayermineditem(function(entity) OnRemoved(entity) end)
game.onrobotpremined(function(entity) OnRemoved(entity) end)
function OnLoad()
if not glob.furnaces then
glob.furnaces = {}
end
end
function OnTick()
-- Check every furnace.
for _, furnace in pairs(glob.furnaces) do
local inv = furnace.getoutputinventory()
if not inv.isempty() then
-- It's finished crafting.
game.evolutionfactor = game.evolutionfactor - 1
-- Remove the crafted item.
inv.clear()
end
end
end
function OnBuilt(entity)
if entity.name == "pollutionfurnace" then
-- Store for later use
glob.furnaces.insert(entity)
end
end
function OnRemoved(entity)
if entity.name == "pollutionfurnace" then
-- Find and remove it from the table.
for i, v in pairs(glob.furnaces)
if v.equals(entity) then
glob.furnaces.remove(i)
break
end
end
end
end
My mods: Red Alert Harvesters - Clean Pipes - Filtered Splitters
Re: [Request] Deevolution script
You also might want to look at the alien temple mod: https://forums.factorio.com/forum/vie ... =14&t=8863
It does something very similar
It does something very similar
Re: [Request] Deevolution script
Yes, i have used that mod and i found it to be overpowered. Even after increasing the power consumption. What i would like to make is a more balanced mod that needs alien artefacts to de-evolve aliens, so that alien evolution will never be decresed by much. I am aiming to balance it so that it will serve more in the sense of slowing alien progression rather then reversing it.
Re: [Request] Deevolution script
I tested the script and it doesnt work. I was able to fix some syntax errors but thats as far as my lua knowledge goes. These lua tables are the wierdest thing to me ( im used to C). Anyone willing to help me out?
Re: [Request] Deevolution script
I had misdefined the event triggers, it's been a while since I last modded. (This thread did get me back into it though )
Code: Select all
game.onevent(defines.events.ontick, function() OnTick() end)
game.onevent(defines.events.onbuiltentity, function(event) OnBuilt(event.createdentity) end)
game.onevent(defines.events.onrobotbuiltentity, function(event) OnBuilt(event.createdentity) end)
game.onevent(defines.events.onpreplayermineditem, function(event) OnRemoved(event.entity) end)
game.onevent(defines.events.onrobotpremined, function(event) OnRemoved(event.entity) end)
game.onevent(defines.events.onentitydied, function(event) OnRemoved(event.entity) end)
My mods: Red Alert Harvesters - Clean Pipes - Filtered Splitters
Re: [Request] Deevolution script
I noticed and fixed that. There must be something else that is wrong. When the furnace finishes crafting nothing happens. Are you sure the code in ontick function is correct?