diff --git a/2019-03-10 13-58-59.mov b/2019-03-10 13-58-59.mov new file mode 100644 index 0000000..5f9b154 Binary files /dev/null and b/2019-03-10 13-58-59.mov differ diff --git a/2019-03-10 13-58-59.mov.gif b/2019-03-10 13-58-59.mov.gif new file mode 100644 index 0000000..9ddadab Binary files /dev/null and b/2019-03-10 13-58-59.mov.gif differ diff --git a/Shortcuts/control.lua b/Shortcuts/control.lua index 247a9c9..4022c05 100644 --- a/Shortcuts/control.lua +++ b/Shortcuts/control.lua @@ -1,5 +1,5 @@ local function update_armor(event) - player = game.players[event.player_index] + local player = game.players[event.player_index] power_armor = player.get_inventory(defines.inventory.player_armor) if power_armor and power_armor.valid then if power_armor[1].valid_for_read then @@ -12,25 +12,26 @@ end local function update_state(event, equipment_type) update_armor(event) - player = game.players[event.player_index].index - local grid = global.shortcuts_armor[player] - for _, equipment in pairs(grid.equipment) do - if equipment.valid and equipment.type == equipment_type then - local name = equipment.name - local position = equipment.position - local energy = equipment.energy - if not (string.sub(equipment.name,1,9) == "disabled-") then - grid.take(equipment) - local new_equipment = grid.put{name="disabled-" .. name, position=position} - if new_equipment and new_equipment.valid then - new_equipment.energy = energy + local grid = global.shortcuts_armor[game.players[event.player_index].index] + if grid then + for _, equipment in pairs(grid.equipment) do + if equipment.valid and equipment.type == equipment_type then + local name = equipment.name + local position = equipment.position + local energy = equipment.energy + if not (string.sub(equipment.name,1,9) == "disabled-") then + grid.take(equipment) + local new_equipment = grid.put{name="disabled-" .. name, position=position} + if new_equipment and new_equipment.valid then + new_equipment.energy = energy + end + elseif (string.sub(equipment.name,1,9) == "disabled-") then + grid.take(equipment) + local new_equipment = grid.put{name=(string.sub(name,10,#name)), position=position} + if new_equipment and new_equipment.valid then + new_equipment.energy = energy + end end - elseif (string.sub(equipment.name,1,9) == "disabled-") then - grid.take(equipment) - local new_equipment = grid.put{name=(string.sub(name,10,#name)), position=position} - if new_equipment and new_equipment.valid then - new_equipment.energy = energy - end end end end @@ -49,13 +50,35 @@ local function toggle_light(player) end end -local function toggle_type(event) - if event.prototype_name == "night-vision-toggle" then +local function shortcut_type(event) + local prototype_name = event.prototype_name + if prototype_name == "night-vision-toggle" then update_state(event, "night-vision-equipment") - elseif event.prototype_name == "belt-immunity-toggle" then + elseif prototype_name == "belt-immunity-toggle" then update_state(event, "belt-immunity-equipment") - elseif event.prototype_name == "flashlight-toggle" then + elseif prototype_name == "flashlight-toggle" then toggle_light(game.players[event.player_index]) + elseif prototype_name == "big-zoom" then + local player = game.players[event.player_index] + if settings.global["disable-zoom"].value == true then + player.zoom = settings.get_player_settings(player)["zoom-level"].value + else + player.print({"", {"error.error-message-box-title"}, ": ", {"controls.alt-zoom-out"}, " ", {"gui-mod-info.status-disabled"}}) + end + elseif prototype_name == "signal-flare" then + local player = game.players[event.player_index] + if settings.global["disable-zoom"].value == true then + player.force.print({"", "[img=virtual-signal.signal-danger] [color=1,0.1,0.1]", {"entity-name.player"}, " " .. player.name .. " [gps=" .. math.floor(player.position.x+0.5) .. "," .. math.floor(player.position.y+0.5) .. "][/color] [img=virtual-signal.signal-danger]"}) + else + player.print({"", {"error.error-message-box-title"}, ": ", {"technology-name.military"}, " ", {"entity-name.beacon"}, " ", {"gui-mod-info.status-disabled"}}) + end + end +end + +local function remove_remote(event) + local trash = game.players[event.player_index].get_inventory(defines.inventory.player_main) + if trash and trash.valid then + trash.remove("artillery-targeting-remote") end end @@ -72,7 +95,9 @@ script.on_event(defines.events.on_player_armor_inventory_changed, update_armor) script.on_event(defines.events.on_player_placed_equipment, update_armor) script.on_event(defines.events.on_player_removed_equipment, update_armor) -script.on_event(defines.events.on_lua_shortcut, toggle_type) +script.on_event(defines.events.on_lua_shortcut, shortcut_type) + +script.on_event(defines.events.on_player_main_inventory_changed, remove_remote) script.on_init(initialize) script.on_configuration_changed(initialize) \ No newline at end of file diff --git a/Shortcuts/data.lua b/Shortcuts/data.lua index 6dd72f0..5874270 100644 --- a/Shortcuts/data.lua +++ b/Shortcuts/data.lua @@ -1,4 +1,5 @@ require("shortcuts") + data.raw["recipe"]["artillery-targeting-remote"].hidden = true local effect = data.raw["technology"]["artillery"].effects for i=1,(#effect) do @@ -34,6 +35,7 @@ for i=1,(#equipment_list) do disabled_equipment_item[i] = util.table.deepcopy(data.raw["item"]["night-vision-equipment"]) end disabled_equipment_item[i].name = newname + disabled_equipment_item[i].hidden = true disabled_equipment_item[i].localised_name = {"", {"equipment-name." .. name}, " (", {"gui-constant.off"}, ")"} disabled_equipment_item[i].localised_description = {"item-description." .. name} disabled_equipment_item[i].placed_as_equipment_result = newname @@ -43,4 +45,17 @@ end for i=1,(#disabled_equipment),1 do data:extend({disabled_equipment_item[i]}) data:extend({disabled_equipment[i]}) -end \ No newline at end of file +end + +local warning = { + type = "virtual-signal", -- TODO: placeholder, when removing, remember to remove localised name too! + name = "signal-danger", + localised_name = {"gui-alert-tooltip.title"}, + icon = "__core__/graphics/danger-icon.png", + icon_size = 64, + subgroup = "virtual-signal-color", + order = "d[colors]-[9danger]", + hidden = true, +} + +data:extend{(warning)} \ No newline at end of file diff --git a/Shortcuts/graphics/big-zoom-x24-white.png b/Shortcuts/graphics/big-zoom-x24-white.png new file mode 100644 index 0000000..c455dfc Binary files /dev/null and b/Shortcuts/graphics/big-zoom-x24-white.png differ diff --git a/Shortcuts/graphics/big-zoom-x24.png b/Shortcuts/graphics/big-zoom-x24.png new file mode 100644 index 0000000..fa17513 Binary files /dev/null and b/Shortcuts/graphics/big-zoom-x24.png differ diff --git a/Shortcuts/graphics/big-zoom-x32-white.png b/Shortcuts/graphics/big-zoom-x32-white.png new file mode 100644 index 0000000..a1ee2dc Binary files /dev/null and b/Shortcuts/graphics/big-zoom-x32-white.png differ diff --git a/Shortcuts/graphics/big-zoom-x32.png b/Shortcuts/graphics/big-zoom-x32.png new file mode 100644 index 0000000..bc241fa Binary files /dev/null and b/Shortcuts/graphics/big-zoom-x32.png differ diff --git a/Shortcuts/graphics/danger-icon.png b/Shortcuts/graphics/danger-icon.png new file mode 100644 index 0000000..736f88d Binary files /dev/null and b/Shortcuts/graphics/danger-icon.png differ diff --git a/Shortcuts/graphics/signal-flare-x24-white.png b/Shortcuts/graphics/signal-flare-x24-white.png new file mode 100644 index 0000000..92943a8 Binary files /dev/null and b/Shortcuts/graphics/signal-flare-x24-white.png differ diff --git a/Shortcuts/graphics/signal-flare-x24.png b/Shortcuts/graphics/signal-flare-x24.png new file mode 100644 index 0000000..3017664 Binary files /dev/null and b/Shortcuts/graphics/signal-flare-x24.png differ diff --git a/Shortcuts/graphics/signal-flare-x32-white.png b/Shortcuts/graphics/signal-flare-x32-white.png new file mode 100644 index 0000000..f718ada Binary files /dev/null and b/Shortcuts/graphics/signal-flare-x32-white.png differ diff --git a/Shortcuts/graphics/signal-flare-x32.png b/Shortcuts/graphics/signal-flare-x32.png new file mode 100644 index 0000000..1bca617 Binary files /dev/null and b/Shortcuts/graphics/signal-flare-x32.png differ diff --git a/Shortcuts/graphics/u1F50D.png b/Shortcuts/graphics/u1F50D.png new file mode 100644 index 0000000..fb36dde Binary files /dev/null and b/Shortcuts/graphics/u1F50D.png differ diff --git a/Shortcuts/info.json b/Shortcuts/info.json index 1d0b774..14e9ff0 100644 --- a/Shortcuts/info.json +++ b/Shortcuts/info.json @@ -1,6 +1,6 @@ { "name": "Shortcuts", - "version": "0.2.2", + "version": "0.3.0", "factorio_version": "0.17", "title": "Shortcuts", "author": "npc_strider(morley376)", diff --git a/Shortcuts/settings.lua b/Shortcuts/settings.lua new file mode 100644 index 0000000..2b99504 --- /dev/null +++ b/Shortcuts/settings.lua @@ -0,0 +1,25 @@ +data:extend({ + { + type = "double-setting", + name = "zoom-level", + localised_name = {"", {"controls.alt-zoom-out"}, " ", {"description.module-bonus-limit"}}, + setting_type = "runtime-per-user", + default_value = 0.1, + minimum_value = 0.0, + maximum_value = 16.0, + }, + { + type = "bool-setting", + name = "disable-zoom", + localised_name = {"", {"gui-control-behavior-modes.enable-disable"}, " ", {"controls.alt-zoom-out"}}, + setting_type = "runtime-global", + default_value = true, + }, + { + type = "bool-setting", + name = "disable-flare", + localised_name = {"", {"gui-control-behavior-modes.enable-disable"}, " ", {"technology-name.military"}, " ", {"entity-name.beacon"}}, + setting_type = "runtime-global", + default_value = true, + } +}) \ No newline at end of file diff --git a/Shortcuts/shortcuts.lua b/Shortcuts/shortcuts.lua index e3feb77..f371821 100644 --- a/Shortcuts/shortcuts.lua +++ b/Shortcuts/shortcuts.lua @@ -132,6 +132,73 @@ data:extend( flags = {"icon"} }, }, + { + type = "shortcut", + name = "big-zoom", + order = "a[big-zoom]", + technology_to_unlock = "optics", + action = "lua", + localised_name = {"controls.alt-zoom-out"}, + toggleable = true, + style = "blue", + icon = + { + filename = "__Shortcuts__/graphics/big-zoom-x32-white.png", + priority = "extra-high-no-scale", + size = 32, + scale = 1, + flags = {"icon"} + }, + small_icon = + { + filename = "__Shortcuts__/graphics/big-zoom-x24.png", + priority = "extra-high-no-scale", + size = 24, + scale = 1, + flags = {"icon"} + }, + disabled_small_icon = + { + filename = "__Shortcuts__/graphics/big-zoom-x24-white.png", + priority = "extra-high-no-scale", + size = 24, + scale = 1, + flags = {"icon"} + }, + }, + { + type = "shortcut", + name = "signal-flare", + order = "a[signal-flare]", + action = "lua", + localised_name = {"", {"technology-name.military"}, " ", {"entity-name.beacon"}, " (", {"description.force"}, " ", {"deconstruction-tile-mode.only"}, ")"}, + toggleable = true, + style = "red", + icon = + { + filename = "__Shortcuts__/graphics/signal-flare-x32-white.png", + priority = "extra-high-no-scale", + size = 32, + scale = 1, + flags = {"icon"} + }, + small_icon = + { + filename = "__Shortcuts__/graphics/signal-flare-x24.png", + priority = "extra-high-no-scale", + size = 24, + scale = 1, + flags = {"icon"} + }, + disabled_small_icon = + { + filename = "__Shortcuts__/graphics/signal-flare-x24-white.png", + priority = "extra-high-no-scale", + size = 24, + scale = 1, + flags = {"icon"} + }, + }, -- Custom shortcut can be defined as follows: -- { -- type = "shortcut", diff --git a/Shortcuts/thumbnail.png b/Shortcuts/thumbnail.png index 177d15c..5d901ef 100644 Binary files a/Shortcuts/thumbnail.png and b/Shortcuts/thumbnail.png differ diff --git a/image3.png b/image3.png new file mode 100644 index 0000000..63be399 Binary files /dev/null and b/image3.png differ