Last active
September 24, 2025 07:11
-
-
Save vinaghost/eac7d71905c06b3ae3695cfb952c7a99 to your computer and use it in GitHub Desktop.
single dropping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function ingredients_contains(ingredients, item_name) | |
| for _, ingredient in pairs(ingredients) do | |
| if ingredient.name == item_name then | |
| return true | |
| end | |
| end | |
| return false | |
| end | |
| script.on_event(defines.events.on_player_cursor_stack_changed, function(event) | |
| local player = game.get_player(event.player_index) | |
| if not player then return end | |
| local item_stack = player.cursor_stack | |
| if not item_stack then return end | |
| local old_content = storage.cursor_stack_contents | |
| local current_content = item_stack.valid_for_read and { name = item_stack.name, count = item_stack.count } or nil | |
| storage.cursor_stack_contents = current_content | |
| if not storage.elements.settings.capture_put.state then return end | |
| if not old_content then return end | |
| if not current_content then return end | |
| if old_content.name ~= current_content.name then return end | |
| if old_content.count - current_content.count ~= 1 then return end | |
| local entity = player.selected | |
| if not entity then return end | |
| local item_name = old_content.name | |
| local inventory = nil | |
| if entity.get_fuel_inventory() and prototypes.item[item_name].fuel_category then | |
| inventory = "Fuel" | |
| elseif entity.type == "lab" then | |
| if prototypes.item[item_name].type == "module" then | |
| inventory = "Modules" | |
| else | |
| inventory = "Input" | |
| end | |
| elseif entity.type == "mining-drill" then | |
| inventory = "Modules" | |
| elseif entity.type == "container" then | |
| inventory = chest_list[entity.name] ~= nil and "Chest" or "Wreck" | |
| elseif entity.type == "beacon" then | |
| inventory = "Modules" | |
| elseif prototypes.item[item_name].type == "module" then | |
| local recipe = entity.type == "assembling-machine" and entity.get_recipe() or nil | |
| local ingredients = recipe and recipe.ingredients | |
| if ingredients and ingredients_contains(ingredients, item_name) then | |
| inventory = "Input" | |
| elseif entity.get_module_inventory() == entity.get_inventory(defines.inventory.crafter_modules) then | |
| inventory = "Modules" | |
| end | |
| -- otherwise, ??? don't know which inventory this module goes in | |
| elseif entity.type == "car" and prototypes.item[item_name].type == "ammo" then | |
| inventory = "Ammo 1" | |
| else | |
| if entity.get_inventory(defines.inventory.crafter_input) then | |
| inventory = "Input" | |
| else | |
| return | |
| end | |
| end | |
| local modifier | |
| if entity.type == "car" then --TODO handle other vehicles | |
| modifier = "vehicle" | |
| end | |
| if inventory then | |
| local transfer_count = 1 | |
| local transfer_count_description = transfer_count .. " x" | |
| add_action({"tas_helper.description_put", transfer_count_description, item_name, entity_to_string(entity)}, { | |
| type = "put", | |
| entity = entity, | |
| position = entity.position, | |
| item_name = item_name, | |
| count = transfer_count, | |
| inventory = inventory, | |
| modifier = modifier, | |
| highlight_box_bounds = entity.selection_box, | |
| }) | |
| else | |
| game.print("Error: Couldn't identify correct inventory when exporting action 'Put' with entity " .. entity.name .. " and item " .. item_name) | |
| end | |
| end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment