v 0.3.0: add military-beacon (distress flare) and ultra zoom

This commit is contained in:
Peter 2019-03-10 14:05:55 +08:00
parent 3824601a57
commit 8f3af2d358
19 changed files with 158 additions and 26 deletions

BIN
2019-03-10 13-58-59.mov Normal file

Binary file not shown.

BIN
2019-03-10 13-58-59.mov.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@ -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,8 +12,8 @@ end
local function update_state(event, equipment_type)
update_armor(event)
player = game.players[event.player_index].index
local grid = global.shortcuts_armor[player]
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
@ -34,6 +34,7 @@ local function update_state(event, equipment_type)
end
end
end
end
end
local function toggle_light(player)
@ -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)

View File

@ -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
@ -44,3 +46,16 @@ for i=1,(#disabled_equipment),1 do
data:extend({disabled_equipment_item[i]})
data:extend({disabled_equipment[i]})
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)}

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,6 +1,6 @@
{
"name": "Shortcuts",
"version": "0.2.2",
"version": "0.3.0",
"factorio_version": "0.17",
"title": "Shortcuts",
"author": "npc_strider(morley376)",

25
Shortcuts/settings.lua Normal file
View File

@ -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,
}
})

View File

@ -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",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
image3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB