Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jodokus31 committed Aug 7, 2023
1 parent 2ad93e0 commit 0a6039a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 54 deletions.
73 changes: 39 additions & 34 deletions logistic-mall-assembling-machine/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,32 @@ local function set_requests(lmam, recipe)

local previous_tier_item_group = get_previous_tier_item_group(product_item_group, ingredient_name)
if previous_tier_item_group then
request_amount = 1
if previous_tier_item_group == "ammo" then
request_amount = 20

elseif previous_tier_item_group == "capsule" then
request_amount = 2

else
request_amount = 1
end

request_from_buffers = true

else
local factor = 1
request_amount = v.amount
if product_item_group then
if product_item_group == "placeable" then
factor = 2
request_amount = 2*v.amount

elseif product_item_group == "repair-tool"
or product_item_group == "ammo"
or product_item_group == "capsule" then
factor = 5
request_amount = 5*v.amount

elseif product_item_group == "rail-planner" then
factor = 50
request_amount = 50
end
end
local ingredient_prototype = game.item_prototypes[ingredient_name]
local ingredient_stacksize = ingredient_prototype and ingredient_prototype.stack_size
request_amount = factor * v.amount
if ingredient_prototype and request_amount > ingredient_stacksize then
request_amount = ingredient_stacksize
end
Expand All @@ -155,8 +153,7 @@ local function set_requests(lmam, recipe)
local product_prototype = product_name and game.item_prototypes[product_name] or nil

if product_name and product_prototype then
local chest_output_capacity = 48 * product_prototype.stack_size
--local chest_output_capacity = lmam.chest_output.request_slot_count * product_prototype.stack_size
local chest_output_capacity = lmam.chest_output.prototype.get_inventory_size(defines.inventory.chest) * product_prototype.stack_size
if chest_output_capacity > 0 then
lmam.chest_output.set_request_slot( { name = product_name, count = chest_output_capacity }, 1)
end
Expand Down Expand Up @@ -384,6 +381,33 @@ local REMOVE_MODE =
script_destroyed = 4,
}

local function handle_chest(chest, player, force, remove_mode)
local chest_remainder_input = replace_chest(chest, player)
if chest_remainder_input then
chest_remainder_input.order_deconstruction(force, player)
if remove_mode == REMOVE_MODE.by_player then
player.mine_entity(chest_remainder_input, false)
end

else
destroy_entity(chest)
end
end

local function handle_inserter(inserter, player, force, remove_mode)
if inserter and inserter.valid and inserter.has_items_inside() then
inserter.minable = true
inserter.destructible = true
inserter.order_deconstruction(force, player)
if remove_mode == REMOVE_MODE.by_player then
player.mine_entity(inserter, false)
end

else
destroy_entity(inserter)
end
end

local function remove_lmam(entity, player, force, remove_mode)
local lmam = global.Existing_Lmams[entity.unit_number]
if not lmam then return end
Expand All @@ -401,30 +425,11 @@ local function remove_lmam(entity, player, force, remove_mode)
destroy_entity(lmam.inserter_output)

else
local chest_remainder_input = replace_chest(lmam.chest_input, player)
if chest_remainder_input then
chest_remainder_input.order_deconstruction(force, player)
if remove_mode == REMOVE_MODE.by_player then
player.mine_entity(chest_remainder_input, false)
end

else
destroy_entity(lmam.chest_input)
end
handle_chest(lmam.chest_input, player, force, remove_mode)
handle_chest(lmam.chest_output, player, force, remove_mode)

local chest_remainder_output = replace_chest(lmam.chest_output, player)
if chest_remainder_output then
chest_remainder_output.order_deconstruction(force, player)
if remove_mode == REMOVE_MODE.by_player then
player.mine_entity(chest_remainder_output, false)
end

else
destroy_entity(lmam.chest_output)
end

destroy_entity(lmam.inserter_input)
destroy_entity(lmam.inserter_output)
handle_inserter(lmam.inserter_input, player, force, remove_mode)
handle_inserter(lmam.inserter_output, player, force, remove_mode)
end

lmam.selected_recipe_name = nil
Expand Down
34 changes: 14 additions & 20 deletions logistic-mall-assembling-machine/data.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local bobsmodactive = mods["bobassembly"]
local bobsmodactive = mods["bobassembly"] ~= nil

do
local mall_crafting_recipe_category = {
Expand All @@ -16,12 +16,14 @@ do
if bobsmodactive then
tech_prerequisites = {
"automation-3",
"logistic-robotics"
"logistic-robotics",
"stack-inserter"
}
else
tech_prerequisites = {
"automation-2",
"logistic-robotics"
"logistic-robotics",
"stack-inserter"
}
end

Expand Down Expand Up @@ -57,9 +59,9 @@ do
prerequisites = tech_prerequisites,
unit =
{
count = 75,
count = 100,
ingredients = tech_ingredients,
time = 60
time = 30
},
order = bobsmodactive and "a-b-ca" or "a-b-ba"
}
Expand All @@ -81,11 +83,10 @@ do

lmam_assembling_machine_entity.name = "lmam-assembling-machine"
lmam_assembling_machine_entity.minable.result = "lmam-assembling-machine"
lmam_assembling_machine_entity.selection_box = {{-1.2, -1.2}, {1.2, 1.2}}
lmam_assembling_machine_entity.selection_box = {{-1.1, -1.1}, {1.1, 1.1}}
lmam_assembling_machine_entity.next_upgrade = nil
lmam_assembling_machine_entity.fast_replaceable_group = nil
lmam_assembling_machine_entity.crafting_categories = { "mall-crafting" }
--lmam_assembling_machine_entity.icon = "__logistic-mall-assembling-machine__/graphics/icon/logistic-mall-assembling-machine.png"

local lmam_assembling_machine_item = util.table.deepcopy(data.raw["item"]["assembling-machine-3"])
lmam_assembling_machine_item.name = "lmam-assembling-machine"
Expand Down Expand Up @@ -161,8 +162,6 @@ do
lmam_input_inserter_entity.minable = {mining_time = 0.001, result = nil}
lmam_input_inserter_entity.flags = {"player-creation"}
lmam_input_inserter_entity.collision_mask = {}
--lmam_input_inserter_entity.collision_box = {{-0.15, -0.15}, {0.15, 0.15}}
--lmam_input_inserter_entity.selection_box = {{0,0}, {0,0}}
lmam_input_inserter_entity.allow_custom_vectors = true
lmam_input_inserter_entity.pickup_position = {0, -1}
lmam_input_inserter_entity.insert_position = {1.2, 0}
Expand All @@ -184,8 +183,6 @@ do
lmam_output_inserter_entity.minable = {mining_time = 0.001, result = nil}
lmam_output_inserter_entity.flags = {"player-creation"}
lmam_output_inserter_entity.collision_mask = {}
--lmam_output_inserter_entity.collision_box = {{-0.15, -0.15}, {0.15, 0.15}}
--lmam_output_inserter_entity.selection_box = {{0,0}, {0,0}}
lmam_output_inserter_entity.allow_custom_vectors = true
lmam_output_inserter_entity.pickup_position = {-1, 0}
lmam_output_inserter_entity.insert_position = {0, -1.2}
Expand All @@ -200,26 +197,23 @@ do
})
end




do
local recipe_ingredients
if bobsmodactive then
recipe_ingredients =
{
{"assembling-machine-3", 1},
{"advanced-circuit", 2 },
{"electronic-circuit", 20 },
{"steel", 16 },
{"advanced-circuit", 3 },
{"electronic-circuit", 10 },
{"steel-plate", 10 },
}
else
recipe_ingredients =
{
{"assembling-machine-2", 1},
{"advanced-circuit", 10 },
{"electronic-circuit", 20 },
{"steel", 16 },
{"advanced-circuit", 3 },
{"electronic-circuit", 10 },
{"steel-plate", 10 },
}
end

Expand Down

0 comments on commit 0a6039a

Please sign in to comment.