LuaControl.move_crafting(start_index, end_index, count)

Things that we aren't going to implement
User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 421
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

LuaControl.move_crafting(start_index, end_index, count)

Post by y.petremann »

TL;DR
LuaControl.move_crafting would permit to reorder crafting queue without quirks
LuaControl.begin_crafting and LuaControl.cancel_crafting can cause unwanted side effects when reordering and need some hacks to prevent them which cause other unwanted side effects.
What ?
LuaControl.move_crafting(from_index, to_index, merge, count) → uint
reorder given count of the recipe at given crafting queue index to the given index position.
If specified, does a merge of the moved recipe stack in the target recipe stack if they correspond to the same recipe. otherwise the new stack is placed before
Child crafts are automatically moved with actual craft to keep consistency.
Child crafts can't be moved alone.

Parameters
  • from_index :: uint: The recipe stack index to reorder.
  • to_index :: uint: The target index in crafting queue to reorder to.
  • merge :: boolean (optional): Does it merge. Default to false
  • count :: uint (optional): The count to move. Count greater than recipe stack size would be ignored. By default move the whole recipe stack.
Return value
The count that was actually moved.
Examples ?

Code: Select all

player.move_crafting(#player.crafting_queue, 1) -- move last recipe stack to front
player.move_crafting(2, 1, false) -- move second stack to front, without merge
player.move_crafting(2, 1, true) -- move second stack to front, with merge if possible
player.move_crafting(1, 1, false, 1) -- split the first recipe stack with one recipe placed before the others
Why ?
LuaControl.begin_crafting need items in inventory, LuaControl.cancel_crafting put items in inventory or dump them on ground,
When reordering those side effect need a hack to prevent dymping on ground, so usually LuaControl.character_inventory_slots_bonus is modified
When modifying LuaControl.character_inventory_slots_bonus, inventory is "reset" and so each Gui using it is rerendered, which effectively reset scrollbars and selectors

LuaControl.move_crafting wouldn't do inventory manipulation and so would never need such hack.

Another solution would be to consider that dump to ground is done after scripts and that inventory can temporary overfill which would don't need the LuaControl.character_inventory_slots_bonus hack

Another solution would be to not trigger a rerendering if LuaControl.character_inventory_slots_bonus has kept his original value
Rseding91
Factorio Staff
Factorio Staff
Posts: 14250
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaControl.move_crafting(start_index, end_index, count)

Post by Rseding91 »

Sorry but this isn't going to happen. The crafting queue isn't built to support something like this and even if it was; it's not something we ever want to encourage - even in mods.
If you want to get ahold of me I'm almost always on Discord.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 693
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: LuaControl.move_crafting(start_index, end_index, count)

Post by Xorimuth »

And I'm guessing the reasoning behind not improving the crafting queue is because the intention is to encourage players to automate crafting and not handcraft everything.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Post Reply

Return to “Won't implement”