0.2.0: nve, flashlight and belt toggles
78
Shortcuts/control.lua
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
local function update_armor(event)
|
||||||
|
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
|
||||||
|
if power_armor[1].grid.valid then
|
||||||
|
global.shortcuts_armor[player.index] = power_armor[1].grid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
local function toggle_light(player)
|
||||||
|
if global.shortcuts_light[player.index] == nil then
|
||||||
|
global.shortcuts_light[player.index] = true
|
||||||
|
end
|
||||||
|
if global.shortcuts_light[player.index] == true then
|
||||||
|
player.character.disable_flashlight()
|
||||||
|
global.shortcuts_light[player.index] = false
|
||||||
|
elseif global.shortcuts_light[player.index] == false then
|
||||||
|
player.character.enable_flashlight()
|
||||||
|
global.shortcuts_light[player.index] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function toggle_type(event)
|
||||||
|
if event.prototype_name == "night-vision-toggle" then
|
||||||
|
update_state(event, "night-vision-equipment")
|
||||||
|
elseif event.prototype_name == "belt-immunity-toggle" then
|
||||||
|
update_state(event, "belt-immunity-equipment")
|
||||||
|
elseif event.prototype_name == "flashlight-toggle" then
|
||||||
|
toggle_light(game.players[event.player_index])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function initialize()
|
||||||
|
if global.shortcuts_light == nil then
|
||||||
|
global.shortcuts_light = {}
|
||||||
|
end
|
||||||
|
if global.shortcuts_armor == nil then
|
||||||
|
global.shortcuts_armor = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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_init(initialize)
|
||||||
|
script.on_configuration_changed(initialize)
|
43
Shortcuts/data.lua
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
require("shortcuts")
|
||||||
|
data.raw["recipe"]["artillery-targeting-remote"].hidden = true
|
||||||
|
local effect = data.raw["technology"]["artillery"].effects
|
||||||
|
for i=1,(#effect) do
|
||||||
|
if effect[i].type == "unlock-recipe" then
|
||||||
|
if effect[i].recipe == "artillery-targeting-remote" then
|
||||||
|
table.remove(effect, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local disabled_equipment = {}
|
||||||
|
local disabled_equipment_item = {}
|
||||||
|
local equipment_list = {
|
||||||
|
"night-vision-equipment",
|
||||||
|
"belt-immunity-equipment",
|
||||||
|
}
|
||||||
|
for i=1,(#equipment_list) do
|
||||||
|
for _, equipment in pairs(data.raw[equipment_list[i]]) do
|
||||||
|
local i = #disabled_equipment+1
|
||||||
|
disabled_equipment[i] = util.table.deepcopy(equipment)
|
||||||
|
disabled_equipment_item[i] = util.table.deepcopy(data.raw["item"][equipment_list[i]])
|
||||||
|
local name = disabled_equipment[i].name
|
||||||
|
local newname = "disabled-" .. name
|
||||||
|
disabled_equipment[i].name = newname
|
||||||
|
disabled_equipment[i].energy_input = "0kW"
|
||||||
|
if equipment_list[i] == "belt-immunity-equipment" then
|
||||||
|
disabled_equipment[i].energy_source.input_flow_limit = "0kW"
|
||||||
|
disabled_equipment[i].energy_source.buffer_capacity = "0kJ"
|
||||||
|
disabled_equipment[i].energy_source.drain = "1kW"
|
||||||
|
end
|
||||||
|
disabled_equipment_item[i].name = newname
|
||||||
|
disabled_equipment_item[i].localised_name = {"", {"equipment-name." .. name}, " (", {"gui-constant.off"}, ")"}
|
||||||
|
disabled_equipment_item[i].localised_description = {"item-description." .. name}
|
||||||
|
disabled_equipment[i].localised_name = {"", {"equipment-name." .. name}, " (", {"gui-constant.off"}, ")"}
|
||||||
|
disabled_equipment_item[i].placed_as_equipment_result = newname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1,(#disabled_equipment),1 do
|
||||||
|
data:extend({disabled_equipment_item[i]})
|
||||||
|
data:extend({disabled_equipment[i]})
|
||||||
|
end
|
BIN
Shortcuts/graphics/artillery-targeting-remote-x24-white.png
Normal file
After Width: | Height: | Size: 643 B |
BIN
Shortcuts/graphics/artillery-targeting-remote-x24.png
Normal file
After Width: | Height: | Size: 606 B |
BIN
Shortcuts/graphics/artillery-targeting-remote-x32-white.png
Normal file
After Width: | Height: | Size: 712 B |
BIN
Shortcuts/graphics/artillery-targeting-remote-x32.png
Normal file
After Width: | Height: | Size: 680 B |
BIN
Shortcuts/graphics/belt-immunity-toggle-x24-white.png
Normal file
After Width: | Height: | Size: 935 B |
BIN
Shortcuts/graphics/belt-immunity-toggle-x24.png
Normal file
After Width: | Height: | Size: 811 B |
BIN
Shortcuts/graphics/belt-immunity-toggle-x32-white.png
Normal file
After Width: | Height: | Size: 689 B |
BIN
Shortcuts/graphics/belt-immunity-toggle-x32.png
Normal file
After Width: | Height: | Size: 629 B |
BIN
Shortcuts/graphics/flashlight-toggle-x24-white.png
Normal file
After Width: | Height: | Size: 926 B |
BIN
Shortcuts/graphics/flashlight-toggle-x24.png
Normal file
After Width: | Height: | Size: 825 B |
BIN
Shortcuts/graphics/flashlight-toggle-x32-white.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
Shortcuts/graphics/flashlight-toggle-x32.png
Normal file
After Width: | Height: | Size: 971 B |
BIN
Shortcuts/graphics/night-vision-toggle-x24-white.png
Normal file
After Width: | Height: | Size: 728 B |
BIN
Shortcuts/graphics/night-vision-toggle-x24.png
Normal file
After Width: | Height: | Size: 660 B |
BIN
Shortcuts/graphics/night-vision-toggle-x32-white.png
Normal file
After Width: | Height: | Size: 858 B |
BIN
Shortcuts/graphics/night-vision-toggle-x32.png
Normal file
After Width: | Height: | Size: 877 B |
10
Shortcuts/info.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "Shortcuts",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"factorio_version": "0.17",
|
||||||
|
"title": "Shortcuts",
|
||||||
|
"author": "npc_strider(morley376)",
|
||||||
|
"contact": "",
|
||||||
|
"homepage": "http://steamcommunity.com/id/morley376",
|
||||||
|
"description": "Adds in a shortcut button for the artillery remote, and toggles for night-vision-equipment, belt-immunity-equipment and the player lamp. Suggest any new shortcut ideas to the discussion page."
|
||||||
|
}
|
143
Shortcuts/shortcuts.lua
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
data:extend(
|
||||||
|
{
|
||||||
|
{
|
||||||
|
type = "shortcut",
|
||||||
|
name = "artillery-targeting-remote",
|
||||||
|
order = "a[artillery-targeting-remote]",
|
||||||
|
action = "create-blueprint-item",
|
||||||
|
localised_name = {"item-name.artillery-targeting-remote"},
|
||||||
|
technology_to_unlock = "artillery",
|
||||||
|
item_to_create = "artillery-targeting-remote",
|
||||||
|
style = "red",
|
||||||
|
icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/artillery-targeting-remote-x32-white.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 32,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/artillery-targeting-remote-x24.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
disabled_small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/artillery-targeting-remote-x24-white.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "shortcut",
|
||||||
|
name = "night-vision-toggle",
|
||||||
|
order = "a[night-vision-toggle]",
|
||||||
|
action = "lua",
|
||||||
|
localised_name = {"equipment-name.night-vision-equipment"},
|
||||||
|
technology_to_unlock = "night-vision-equipment",
|
||||||
|
toggleable = true,
|
||||||
|
icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/night-vision-toggle-x32.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 32,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/night-vision-toggle-x24.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
disabled_small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/night-vision-toggle-x24-white.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "shortcut",
|
||||||
|
name = "belt-immunity-toggle",
|
||||||
|
order = "a[belt-immunity-toggle]",
|
||||||
|
action = "lua",
|
||||||
|
localised_name = {"item-name.belt-immunity-equipment"},
|
||||||
|
technology_to_unlock = "belt-immunity-equipment",
|
||||||
|
toggleable = true,
|
||||||
|
icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/belt-immunity-toggle-x32.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 32,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/belt-immunity-toggle-x24.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
disabled_small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/belt-immunity-toggle-x24-white.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "shortcut",
|
||||||
|
name = "flashlight-toggle",
|
||||||
|
order = "a[flashlight-toggle]",
|
||||||
|
action = "lua",
|
||||||
|
localised_name = {"entity-name.small-lamp"},
|
||||||
|
toggleable = true,
|
||||||
|
icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/flashlight-toggle-x32.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 32,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/flashlight-toggle-x24.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
disabled_small_icon =
|
||||||
|
{
|
||||||
|
filename = "__Shortcuts__/graphics/flashlight-toggle-x24-white.png",
|
||||||
|
priority = "extra-high-no-scale",
|
||||||
|
size = 24,
|
||||||
|
scale = 1,
|
||||||
|
flags = {"icon"}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- Custom shortcut can be defined as follows:
|
||||||
|
-- {
|
||||||
|
-- type = "shortcut",
|
||||||
|
-- name = "shortcut-name",
|
||||||
|
-- action = "lua",
|
||||||
|
-- toggleable = true, -- whether or not the shortcut button is a toggle button or not
|
||||||
|
-- order, localised_name, technology_to_unlock, icon, small_icon, disabled_icon, disabled_small_icon as above
|
||||||
|
-- }
|
||||||
|
})
|
BIN
Shortcuts/thumbnail.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
image1.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
image2.png
Normal file
After Width: | Height: | Size: 40 KiB |