[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
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by aahaxor »

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
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by aahaxor »

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: 18
Joined: Thu Dec 21, 2017 7:52 pm
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by ReasonX »

Can some one upgrade it to 0.16?

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

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by aahaxor »

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
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by jdarko »

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
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by jdarko »

Simple 7 segment display using lamps to visualize numbers (in this case a simple counter)
JEMhndm3Fo.gif
JEMhndm3Fo.gif (6.24 MiB) Viewed 2903 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.

AndrewIRL
Fast Inserter
Fast Inserter
Posts: 240
Joined: Fri Mar 24, 2017 2:17 pm
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by AndrewIRL »

jdarko wrote:
Fri Jan 11, 2019 10:40 pm
To fix that put the modified "output.lua" file into the mod zip and overwrite it:

...edit...

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",      	
}
Your first change fixes the error message on screen when trying to set_count, thanks.

Your second change appears to have no effect. The code in the mod is:

Code: Select all

data.raw["gui-style"].default["wide_textbox_style_lua"] =
{
      type = "textfield_style",
      parent = "textfield",      
      minimal_width = 300,
      maximal_width = 300,  
}
Removing the minimal_width and maximal_width doesn't seem to do much. Did you make other changes?

I assume we need some sort of:
"text-box": A multi-line text box that supports selection and copy-paste.
https://lua-api.factorio.com/latest/LuaGuiElement.html
but I wasn't able to get it working as I have zero modding experience.

The only place I found a reference to wide_textbox_style_lua was in control.lua

Code: Select all

	lua_command = gui_or_new(command,"lua_command",{type="textfield", name="lua_command", text=lamp.command , style="wide_textbox_style_lua", parent="wide_textbox_style_lua"})
Lastly when the comparison in a newly placed combinator (no wires attached) is done vs anything or everything the game crashes.
Error while running event
LuaCombinator::on_tick (ID 0)
__LuaCombinator__/control.lua:226: bad argument #1 to 'pairs' (table expected, got nil)
I'm guessing this is needed:

Code: Select all

if network_r.signals ~= nil then
There also seems to be a minor mixup between r/g on line 230. I think that should be a network_g test.

AndrewIRL
Fast Inserter
Fast Inserter
Posts: 240
Joined: Fri Mar 24, 2017 2:17 pm
Contact:

Re: [MOD 0.12.x] Lua Combinator 0.0.1

Post by AndrewIRL »

Code: Select all

function banner(text,position,color,player)
	player.surface.create_entity{name="flying-text-banner_lua", position=position, text="Hello", color=color}
end
This seems like it should be:

Code: Select all

function banner(text,position,color,player)
	player.surface.create_entity{name="flying-text-banner_lua", position=position, text=text, color=color}
end
Otherwise the banner gets stuck on "Hello" permanently.

Post Reply

Return to “Mods”