diff --git a/modules/autostash.lua b/modules/autostash.lua index a6683ffa..640400f5 100644 --- a/modules/autostash.lua +++ b/modules/autostash.lua @@ -232,6 +232,9 @@ local function insert_to_furnace(player_inventory, chests, name, count, floaty_t if valid_to_insert then if chest_inventory.can_insert({name = name, count = amount}) then local inserted_count = chest_inventory.insert({name = name, count = amount}) + if inserted_count < 0 then + return + end player_inventory.remove({name = name, count = inserted_count}) prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count) count = count - inserted_count @@ -251,6 +254,9 @@ local function insert_to_furnace(player_inventory, chests, name, count, floaty_t else if chest_inventory.can_insert({name = name, count = amount}) then local inserted_count = chest_inventory.insert({name = name, count = amount}) + if inserted_count < 0 then + return + end player_inventory.remove({name = name, count = inserted_count}) prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count) count = count - inserted_count @@ -279,6 +285,9 @@ local function insert_to_furnace(player_inventory, chests, name, count, floaty_t local chest_inventory = chest.get_inventory(defines.inventory.chest) if chest_inventory and chest_inventory.can_insert({name = name, count = amount}) then local inserted_count = chest_inventory.insert({name = name, count = amount}) + if inserted_count < 0 then + return + end player_inventory.remove({name = name, count = inserted_count}) prepare_floaty_text(floaty_text_list, chest.surface, chest.position, name, inserted_count) count = count - inserted_count diff --git a/modules/rpg/spells.lua b/modules/rpg/spells.lua index 472a840c..a5912aa1 100644 --- a/modules/rpg/spells.lua +++ b/modules/rpg/spells.lua @@ -128,6 +128,7 @@ local function create_projectiles(data) local force = data.force local target_pos = data.target_pos local range = data.range + local projectile_types = Public.projectile_types if self.aoe then for _ = 1, self.amount do @@ -139,7 +140,7 @@ local function create_projectiles(data) left_top = {x = position.x - 2, y = position.y - 2}, right_bottom = {x = position.x + 2, y = position.y + 2} } - do_projectile(surface, self.entityName, position, force, target_pos, range) + do_projectile(surface, projectile_types[self.entityName].name, position, force, target_pos, range) Public.remove_mana(player, self.mana_cost) if self.damage then for _, e in pairs(surface.find_entities_filtered({area = damage_area})) do @@ -152,7 +153,7 @@ local function create_projectiles(data) left_top = {x = position.x - 2, y = position.y - 2}, right_bottom = {x = position.x + 2, y = position.y + 2} } - do_projectile(surface, self.entityName, position, force, target_pos, range) + do_projectile(surface, projectile_types[self.entityName].name, position, force, target_pos, range) Public.remove_mana(player, self.mana_cost) if self.damage then