Patched LuaCombinator

by aahaxor

Finally updated from 0.12 to 0.16! A combinator to run lua commands ingame.

Utilities
6 years ago
0.14 - 0.16
10

g Fix for crash containing set_circuit_condition error when using output:set_count(..)

5 years ago

Hi,

the latest version of factorio doesn't support the set_circuit_condition method on entities. So the output command crashs.

To fix that put the modified "output.lua" file into the mod zip and overwrite it:

require("new_class")
output = {}

local output_mt = new_class(output)

function output:new(entity)
return setmetatable( {entity=entity}, output_mt)
end

function output:clear(output)
self.entity.get_or_create_control_behavior().parameters = {parameters={}}
end

-- function output:insert_count(type,name,count)
-- local condition = self.entity.get_circuit_condition(1)
-- local old_count = self.get_count(name)
-- self.set_count(type,name,count)
-- end

function output:get_count(name)
local condition = self.entity.get_or_create_control_behavior()

if condition.parameters.parameters[1].signal.name == nil then
    return 0
end

return condition.parameters.parameters[1].signal.count

end

function output:set_count(type,name,count)
local condition = self.entity.get_or_create_control_behavior()

local params = {parameters={
            {index=1,signal={type=type,name=name},count=count},
    }
}

self.entity.get_or_create_control_behavior().parameters = params

end

return output

New response