#Crafting Speed Problem
1 messages · Page 1 of 1 (latest)
thank you
continuing from yesterday
i'm trying to make an leveling mod where one part is increasing crafting speed
vanilla crafting speed is capped at one item per tick which is quite a nuisance since lot of items have crafting time of .5 seconds which means player.character_crafting_speed_modifier = 29 already reaches this cap
a possible solution for increassing the cap would be mantaining some kind of time_bank for crafting time that was not utilized, so i can complete the crafting manually
- since there is no function to complete the crafting order, the only option i see is to cancel it, remove the returned items and give the player the products
- problem with this is that normal crafting queue will wait until there is space in players inventory and will halt, don't see a way to do this here
- another solvable problem is that a player can issue crafting for too many items to complete at once and to mantain the order in which they are supposed to complete would require to cancel part of the crafting, giving the player the intermmediate resources and restart the crafting from where it should currently be (meaning restarting the whole crafting queue and putting this one to the front)
if player has infinite crafting speed it would cancel the queue whole and give the player the products directly
maybe if there is not enough space in players inventory i could increase it resume the crafting and decrease the size afterwards (that should halt the crafting process as in vanilla)
local function skip_crafting(player, crafting_queue_index, crafting_queue_count)
global.skip_crafting = {}
player.cancel_crafting { index = crafting_queue_index, count = crafting_queue_count } -- will raise `on_player_cancelled_crafting` immediatelly
for _, item in ipairs(global.simple_complete.ingredients) do
player.remove_item(item)
end
-- return the inventory back
global.skip_crafting = nil
end
script.on_event(defines.events.on_player_cancelled_crafting, function(event)
if global.skip_crafting then
global.skip_crafting.ingredients = {}
for item, count in pairs(event.items) do
table.insert(global.simple_complete.ingredients, { name = item, count = count })
end
-- make sure the returned ingredients will fit into players inventory
end
end) -- after this function is done the items are inserted into players inventory
to make sure the returned ingredients fit into players inventory, i could increase the player.character_inventory_slots_bonus
but there might be filters so i need to remove those and add them back afterwards
does anyone see anything simpler?
I think that's about as simple as it gets
Honestly, do you even care?
Who actually needs to complete more than 60 crafts per second?
i do care
you can use the mod for a eg. custom scenario which is based on crafting by hand (like mountain fortress)