[MOD 0.12.x] Lua Combinator 0.0.1

Topics and discussion about specific mods
aahaxor
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 27, 2016 3:18 am

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by aahaxor » Mon Jul 31, 2017 8:31 pm

Working on an update... Will be done shortly.
Last edited by aahaxor on Mon Jul 31, 2017 8:35 pm, edited 1 time in total.

aahaxor
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 27, 2016 3:18 am

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by aahaxor » Mon Jul 31, 2017 8:35 pm

Sorry that this has taken so long... I've had a busy summer...
But here it is!
https://mods.factorio.com/mods/aahaxor/LuaCombinator

ReasonX
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Dec 21, 2017 7:52 pm

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by ReasonX » Sat Dec 23, 2017 8:07 am

Can some one upgrade it to 0.16?

aahaxor
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 27, 2016 3:18 am

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by aahaxor » Fri Apr 13, 2018 4:01 am

It is now updated to 0.16. Sorry for the wait!
Link: https://mods.factorio.com/mod/LuaCombinator

jdarko
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Jan 11, 2019 10:38 pm

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by jdarko » Fri Jan 11, 2019 10:40 pm

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:

Code: Select all

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

Also i changed the script input field to multiline textbox ;)

You need to alter the data.lua in the zip at end and replace gui-style tags:

Code: Select all

data.raw["gui-style"].default["wide_textbox_style_lua"] =
{
      type = "textfield_style",
      parent = "textfield",      	
}
Need to look how factorio handles scrollbars on gui
Last edited by jdarko on Fri Jan 11, 2019 11:18 pm, edited 3 times in total.

jdarko
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Jan 11, 2019 10:38 pm

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by jdarko » Fri Jan 11, 2019 10:58 pm

Simple 7 segment display using lamps to visualize numbers (in this case a simple counter)
JEMhndm3Fo.gif
JEMhndm3Fo.gif (6.24 MiB) Viewed 35 times

Code: Select all

if state.interval == nil or state.interval >= 2 then
local mainentity = output.entity                                                                  
local disp = {}
disp[0] = {segments = {"A","B","C","D","E","F"} }
disp[1] = {segments = {"B","C"} }
disp[2] = { segments = {"A","B","G","D","E"} }
disp[3] = { segments = {"A","B","C","D","G"} }
disp[4] = { segments = {"C","F","G"} }
disp[5] = { segments = {"A","C","D","F","G"} }
disp[6] =  {segments = {"A","C","D","E","F","G"} }
disp[7] = {segments = {"A","B","C"} }
disp[8] = {segments = {"A","B","C","D","E","F","G"} }
disp[9] = {segments = {"A","B","C","D","F","G"} }

local params = {parameters={  } }

if state.a == nil or state.a >= 10 then state.a = 0 end

local i = 1
for bla,segment in pairs(disp[state.a].segments) do
  params.parameters[i] = { index=i,signal={type="virtual",name="signal-"..segment},count=1}  
  i = i + 1
end

local control = mainentity.get_or_create_control_behavior()
control.parameters = params;
state.a = state.a + 1
state.interval = 0
end
state.interval  = state.interval + 1
Note, Lua Combinator executes the script on repeat every 0.5 second. Thats why the the state.interval variable is used to change the counter every 1 second.

Post Reply

Return to “Mods”