troelsbjerre / Bottleneck

Factorio mod that tell you which assemblers are starved of ingredients
Other
29 stars 21 forks source link

Update to use Settings, Variants and Picker Support #26

Closed Nexela closed 7 years ago

Nexela commented 7 years ago

Check it out and let me know your thoughts. Don't push a release yet I need to update bottleneck logistics and might have to make more changes :)

troelsbjerre commented 7 years ago

Very nicely done! Exactly what I was hoping for. I fixed a small bug (toggling bottleneck-enabled only toggled about half of the signals) by resetting the update index on change of the setting.

Speaking of Bottleneck Logistics, I've played around with getting the "desired bottleneck behavior" in the mod, and it seems like it can be done without too much overhead in most cases, and approximated well in others. For instance, the following code gives some useful info for requester chests and isn't prohibitively expensive:

local function color_logistic_inputinventory(filters, inv) for ,filter in pairs(filters) do local icount = inv.get_item_count(filter.name) if icount == 0 then return "red" elseif icount < filter.count then return "green" end end return "yellow" end

local function update_signal(data) local entity = data.entity if entity.logistic_network then local point = entity.get_logistic_point()[1] if point.mode == defines.logistic_mode.requester then if point.filters then change_signal(data.signal, color_logistic_input_inventory(point.filters, entity.get_inventory(defines.inventory.chest))) else change_signal(data.signal, "yellow") end else change_signal(data.signal, "green") end else change_signal(data.signal, "red") end end

The idea is that red mean trouble, green means currently doing something constructive, and yellow means idle.

troelsbjerre commented 7 years ago

It might be worth while have toggling as a hotkey... It is a little cumbersome to get to the settings menu.

Nexela commented 7 years ago

Unfortunately the settings and hotkeys would not sync

Nexela commented 7 years ago

I have a few more changes incoming in a few minutes

Nexela commented 7 years ago

Thank you so much for that example code, It is making its way into BL right now!