Re: [MOD 0.12.x] Lua Combinator 0.0.1
Posted: Mon Jul 31, 2017 8:31 pm
Working on an update... Will be done shortly.
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
Code: Select all
data.raw["gui-style"].default["wide_textbox_style_lua"] =
{
type = "textfield_style",
parent = "textfield",
}
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
Your first change fixes the error message on screen when trying to set_count, thanks.jdarko wrote: Fri Jan 11, 2019 10:40 pmTo 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", }
Code: Select all
data.raw["gui-style"].default["wide_textbox_style_lua"] =
{
type = "textfield_style",
parent = "textfield",
minimal_width = 300,
maximal_width = 300,
}
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"})
I'm guessing this is needed:Error while running event
LuaCombinator::on_tick (ID 0)
__LuaCombinator__/control.lua:226: bad argument #1 to 'pairs' (table expected, got nil)
Code: Select all
if network_r.signals ~= nil then
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
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