diff --git a/.gitignore b/.gitignore index ec172c9..e1f8651 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ factorio_mods Instructions.png Instructions2.png cookiejar.txt +.vscode/settings.json diff --git a/constants.lua b/constants.lua index cbb9c7b..8adb345 100644 --- a/constants.lua +++ b/constants.lua @@ -20,6 +20,7 @@ constants.trash_blacklist = { ["upgrade-item"] = true, ["copy-paste-tool"] = true, ["selection-tool"] = true, + ["spidertron-remote"] = true, } constants.gui_dimensions = { diff --git a/control.lua b/control.lua index a18f0d6..04880a7 100644 --- a/control.lua +++ b/control.lua @@ -525,6 +525,32 @@ local function on_research_finished(e) end event.on_research_finished(on_research_finished) +local function on_entity_logistic_slot_changed(e) + if e.player_index == nil then return end + + local player = game.get_player(e.player_index) + if not (player.character) then return end + local pdata = global._pdata[e.player_index] + + local request = player.get_personal_logistic_slot(e.slot_index) + -- Request removed + if request.name == nil then end + + -- Don't add request if it's already fulfilled + local contents = player.get_main_inventory().get_contents() + local item_count = contents[request.name] or 0 + if item_count >= request.min and item_count <= request.max then + player.clear_personal_logistic_slot(e.slot_index) + player.print{"temporary-request-already-fulfilled"} + return + end + + if player_data.set_request(player, global._pdata[player.index], request, true) then + player.print({"at-message.added-to-temporary-requests", at_util.item_prototype(request.name).localised_name}) + end +end +event.on_entity_logistic_slot_changed(on_entity_logistic_slot_changed) + local at_commands = { import = function(args) local player_index = args.player_index diff --git a/locale/en/en.cfg b/locale/en/en.cfg index e1e494a..377e5ad 100644 --- a/locale/en/en.cfg +++ b/locale/en/en.cfg @@ -15,6 +15,7 @@ status-display=Show status display trash-above-requested=Autotrash above requests trash-unrequested=Autotrash unrequested items trash-in-main-network=Autotrash only in main networks +config-button-apply=Apply changes tooltip-pause-trash=(__CONTROL__autotrash_pause__) tooltip-pause-requests=(__CONTROL__autotrash_pause_requests__) tooltip-rip=Load preset when respawning @@ -57,6 +58,8 @@ invalid-gui=Auto Trash: The GUI has become invalid. This likely means that anoth no-presets-to-export=No presets to export. preset-updated=Preset "__1__" updated. added-to-temporary-trash=Added __1__ to temporary trash. +added-to-temporary-requests=Added __1__ to temporary requests. +temporary-request-already-fulfilled=Temporary request already fulfilled by items in inventory. removed-from-temporary-requests=Removed __1__ from temporary requests. character-needed=Personal logistic requests are only possible when using a character. empty-cursor-needed=Click with an empty cursor. diff --git a/scripts/global-data.lua b/scripts/global-data.lua index 61b81c6..c65d0aa 100644 --- a/scripts/global-data.lua +++ b/scripts/global-data.lua @@ -18,6 +18,7 @@ function global_data.refresh() {filter = "type", type = "upgrade-item", invert = true, mode = "and"}, {filter = "type", type = "copy-paste-tool", invert = true, mode = "and"}, {filter = "type", type = "selection-tool", invert = true, mode = "and"}, + {filter = "type", type = "spidertron-remote", invert = true, mode = "and"}, {filter = "flag", flag = "hidden", invert = true, mode = "and"}, --{filter = "place-result", mode = "and"} } diff --git a/scripts/gui.lua b/scripts/gui.lua index 8a24f98..1ae8ee2 100644 --- a/scripts/gui.lua +++ b/scripts/gui.lua @@ -634,6 +634,8 @@ at_gui.handlers.presets = { local player = e.player local pdata = e.pdata local name = e.element.caption + local textfield = pdata.gui.presets.textfield + textfield.text = name if not e.shift then pdata.selected_presets = {[name] = true} pdata.config_tmp = at_util.copy_preset(pdata.presets[name]) @@ -1138,7 +1140,7 @@ function at_gui.create_main_window(player, pdata) {type = "label", style = "subheader_caption_label", caption = {"at-gui.logistics-configuration"}}, gui_util.pushers.horizontal, {type = "sprite-button", style = "item_and_count_select_confirm", - sprite = "utility/check_mark", tooltip = {"module-inserter-config-button-apply"}, + sprite = "utility/check_mark", tooltip = {"at-gui.config-button-apply"}, actions = {on_click = {gui = "main", action = "apply_changes"}}, }, {type = "sprite-button", style = "tool_button_red", ref = {"main", "reset_button"}, sprite = "utility/reset",