Decider combinator configuration question

Place to get help with not working mods / modding interface.
Tritano
Burner Inserter
Burner Inserter
Posts: 17
Joined: Tue Sep 22, 2015 5:12 pm
Contact:

Decider combinator configuration question

Post by Tritano »

I try to configure a decider combinator in a mod as an auxiliary entity. What the code does is create a decider-combinator and configure it's control behaviour. According to the game's html documentation the control behaviour parameters are read/write. Unfortunately the behaviour does not change, as the log below shows and opening the GUI of the entity proofs.

In a nutshell the code is:

Code: Select all

local combinator = entity.surface.create_entity({ name = "decider-combinator",
    position = { entity.position.x + 1, entity.position.y } , force = entity.force })

log("controlBehavior before: "..inspect(combinator.get_or_create_control_behavior().parameters))

combinator.get_or_create_control_behavior().parameters =
  { first_signal = { type="item", name="iron-plate"}, constant = 100, comparator = "<",
    output_signal = { type="item", name="copper-plate"}, copy_count_from_input = false }

log("controlBehavior after: "..inspect(combinator.get_or_create_control_behavior().parameters))
The code above is run in an on_built_entity event when the primary entity is placed.
The log output is:
30.370 Script control.lua:46: controlBehavior before: {
parameters = { comparator = ">", constant = 0, copy_count_from_input = true,
first_signal = { type = "item" },
output_signal = { type = "item" }
}
}
30.370 Script control.lua:54: controlBehavior after: {
parameters = { comparator = ">", constant = 0, copy_count_from_input = true,
first_signal = { type = "item" },
output_signal = { type = "item" }
}
}
I would be very grateful for tips on what I am doing wrong.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Decider combinator configuration question

Post by Choumiko »

Try

Code: Select all

combinator.get_or_create_control_behavior().parameters.parameters =
  { first_signal = { type="item", name="iron-plate"}, constant = 100, comparator = "<",
    output_signal = { type="item", name="copper-plate"}, copy_count_from_input = false }
Yes, double parameters :roll: A bit confusing and hard getting used to :D
Tritano
Burner Inserter
Burner Inserter
Posts: 17
Joined: Tue Sep 22, 2015 5:12 pm
Contact:

Re: Decider combinator configuration question

Post by Tritano »

I have seen the double parameters used with another entity type, but unfortunately it does not work for the decider-combinator.

update

I made a tiny demo mod to easier reproduce it.
Set a wooden chest and get a free (but unconfigured) decider combinator.
data.lua is empty, and control.lua is very simple:

Code: Select all

require "inspect"

function onBuildEntity(event)
  local entity = event.created_entity
  log("onBuildEntity " .. entity.name)
  
  if entity.name == "wooden-chest" then
    local combinator = entity.surface.create_entity({ name = "decider-combinator",
        position = { entity.position.x + 1, entity.position.y },
        force = entity.force })

    combinator.get_or_create_control_behavior().parameters.parameters =
        { first_signal = { type="item", name="iron-plate"}, 
          constant = 100, comparator = "<", copy_count_from_input = false,
          output_signal = { type="item", name="copper-plate"} }

    log("parameters: " .. inspect(combinator.get_or_create_control_behavior().parameters.parameters))
  end
end

script.on_event(defines.events.on_built_entity, onBuildEntity)
script.on_event(defines.events.on_robot_built_entity, onBuildEntity)
Tritano
Burner Inserter
Burner Inserter
Posts: 17
Joined: Tue Sep 22, 2015 5:12 pm
Contact:

Re: Decider combinator configuration question

Post by Tritano »

I am still hoping that somebody has a hint for me.
As it stands now it looks to me like a bug in the game :?
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Decider combinator configuration question

Post by gheift »

Tritano wrote:I have seen the double parameters used with another entity type, but unfortunately it does not work for the decider-combinator.

update

I made a tiny demo mod to easier reproduce it.
Set a wooden chest and get a free (but unconfigured) decider combinator.
data.lua is empty, and control.lua is very simple:

Code: Select all

require "inspect"

function onBuildEntity(event)
  local entity = event.created_entity
  log("onBuildEntity " .. entity.name)
  
  if entity.name == "wooden-chest" then
    local combinator = entity.surface.create_entity({ name = "decider-combinator",
        position = { entity.position.x + 1, entity.position.y },
        force = entity.force })

    combinator.get_or_create_control_behavior().parameters.parameters =
        { first_signal = { type="item", name="iron-plate"}, 
          constant = 100, comparator = "<", copy_count_from_input = false,
          output_signal = { type="item", name="copper-plate"} }

    log("parameters: " .. inspect(combinator.get_or_create_control_behavior().parameters.parameters))
  end
end

script.on_event(defines.events.on_built_entity, onBuildEntity)
script.on_event(defines.events.on_robot_built_entity, onBuildEntity)
Use the following:

Code: Select all

combinator.get_or_create_control_behavior().parameters = {
parameters =
        { first_signal = { type="item", name="iron-plate"}, 
          constant = 100, comparator = "<", copy_count_from_input = false,
          output_signal = { type="item", name="copper-plate"} }
}
Tritano
Burner Inserter
Burner Inserter
Posts: 17
Joined: Tue Sep 22, 2015 5:12 pm
Contact:

Re: Decider combinator configuration question

Post by Tritano »

Thanks a lot, this did the trick :D
Post Reply

Return to “Modding help”