mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
Renamed variables to match codestyle and moved block to it's logical location
This commit is contained in:
parent
621c1486bf
commit
340ee13fb9
@ -614,24 +614,22 @@ end
|
||||
local function on_player_cancelled_crafting(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
local count = event.items.get_item_count() -- Error in calculations were just misinterpretation of API, #event.items returned item slots, not actual count.
|
||||
local crafting_queue_item_count = event.items.get_item_count()
|
||||
local player_inventory_maximum_slot_count = #player.get_main_inventory()
|
||||
local crafting_queue_canceled_item_slot_count = #event.items
|
||||
|
||||
local playerInventoryStacks = #player.get_main_inventory() -- Get this to calculate overhead + player inventory
|
||||
local canceledCraftingQueueStacks = #event.items -- Get item stacks num from crafting queue
|
||||
|
||||
if canceledCraftingQueueStacks > playerInventoryStacks then
|
||||
player.character.character_inventory_slots_bonus = canceledCraftingQueueStacks + playerInventoryStacks -- Resize player's inventory for this entity at maximum level to hold crafting queue + inventory, so don't cause item drop.
|
||||
for i = 1, canceledCraftingQueueStacks do -- Manually insert crafting queue to inventory
|
||||
if crafting_queue_canceled_item_slot_count > player_inventory_maximum_slot_count then
|
||||
player.character.character_inventory_slots_bonus = crafting_queue_canceled_item_slot_count + player_inventory_maximum_slot_count
|
||||
for i = 1, crafting_queue_canceled_item_slot_count do
|
||||
player.character.get_main_inventory().insert(event.items[i])
|
||||
end
|
||||
player.character.die('player') -- Kill griefer!11 Thanks to RPG system - inventory size will automagically returned to it's previous state, so there is no abuse of playable RPG.
|
||||
end
|
||||
player.character.die('player')
|
||||
|
||||
if count > 40 then
|
||||
Utils.action_warning(
|
||||
'{Crafting}',
|
||||
player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. count .. ' in raw items (' .. canceledCraftingQueueStacks .. ' slots)' -- Corrected message
|
||||
player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafting_queue_canceled_item_slot_count .. ' slots) and was punished.'
|
||||
)
|
||||
|
||||
if not this.cancel_crafting_history[player.index] then
|
||||
this.cancel_crafting_history[player.index] = {}
|
||||
end
|
||||
@ -643,7 +641,7 @@ local function on_player_cancelled_crafting(event)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' canceled '
|
||||
str = str .. ' item ' .. event.recipe.name
|
||||
str = str .. ' count was a total of: ' .. count
|
||||
str = str .. ' count was a total of: ' .. crafting_queue_item_count
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(player.position.x)
|
||||
str = str .. ' Y:'
|
||||
|
Loading…
x
Reference in New Issue
Block a user