mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-07-15 01:24:37 +02:00
Merge pull request #853 from plague006/restrict_script
luacheckrc tweaks to script and commands
This commit is contained in:
15
.luacheckrc
15
.luacheckrc
@ -1,3 +1,11 @@
|
|||||||
|
--[[
|
||||||
|
This is a RedMew-customized version of Nexala's luacheckrc and differs in
|
||||||
|
the following ways:
|
||||||
|
- RedMew adds its own globals. See: globals, or search for "RedMew-specific globals"
|
||||||
|
- Removes entries for certain LuaBootstrap (aka script) functions as they should
|
||||||
|
be used through the event module
|
||||||
|
]]
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
--[LICENSE]--
|
--[LICENSE]--
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -180,8 +188,9 @@ stds.factorio_control = {
|
|||||||
-- @commands@:
|
-- @commands@:
|
||||||
commands = {
|
commands = {
|
||||||
fields = {
|
fields = {
|
||||||
"add_command", "commands", "game_commands", "remove_command"
|
"commands", "game_commands", "remove_command"
|
||||||
},
|
},
|
||||||
|
other_fields = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- @settings@:
|
-- @settings@:
|
||||||
@ -198,8 +207,8 @@ stds.factorio_control = {
|
|||||||
-- (http://lua-api.factorio.com/latest/LuaBootstrap.html)
|
-- (http://lua-api.factorio.com/latest/LuaBootstrap.html)
|
||||||
script = {
|
script = {
|
||||||
fields = {
|
fields = {
|
||||||
"on_event", "on_nth_tick", "on_configuration_changed", "on_init", "on_load", "generate_event_name",
|
"on_configuration_changed", "raise_event",
|
||||||
"raise_event", "get_event_handler", "mod_name", "get_event_order"
|
"get_event_handler", "mod_name", "get_event_order"
|
||||||
},
|
},
|
||||||
other_fields = false,
|
other_fields = false,
|
||||||
},
|
},
|
||||||
|
@ -160,8 +160,8 @@ local function linkportals()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
commands.add_command('linkchests', 'Select a chest to link to another. Run this command again to select the other one.', linkchests)
|
commands.add_command('linkchests', 'Select a chest to link to another. Run this command again to select the other one.', linkchests) -- luacheck: ignore
|
||||||
commands.add_command('linkportals', 'Select a portal to link to another. Run this command again to select the other one.', linkportals)
|
commands.add_command('linkportals', 'Select a portal to link to another. Run this command again to select the other one.', linkportals) -- luacheck: ignore
|
||||||
Event.add(defines.events.on_tick, dim_on_tick)
|
Event.add(defines.events.on_tick, dim_on_tick)
|
||||||
|
|
||||||
return Public
|
return Public
|
||||||
|
@ -70,7 +70,7 @@ local function get_resource(x, y)
|
|||||||
return {name = name, position = {x, y}, amount = value}
|
return {name = name, position = {x, y}, amount = value}
|
||||||
end
|
end
|
||||||
|
|
||||||
function run_combined_module(event) -- luacheck: ignore global run_combined_module
|
function run_combined_module(event) -- luacheck: globals run_combined_module
|
||||||
if not global.blocks then
|
if not global.blocks then
|
||||||
init_blocks()
|
init_blocks()
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ box = b.any{box, line}
|
|||||||
|
|
||||||
local boxes = {}
|
local boxes = {}
|
||||||
for i = 0, 3 do
|
for i = 0, 3 do
|
||||||
local b = b.rotate(box, degrees(i*90)) -- luacheck:ignore 421
|
local b = b.rotate(box, degrees(i*90)) -- luacheck: ignore 421
|
||||||
table.insert(boxes, b)
|
table.insert(boxes, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -249,9 +249,9 @@ Event.add(defines.events.on_player_joined_game, player_joined_game)
|
|||||||
Event.add(defines.events.on_player_left_game, player_left_game)
|
Event.add(defines.events.on_player_left_game, player_left_game)
|
||||||
Event.add(defines.events.on_player_respawned, player_respawned)
|
Event.add(defines.events.on_player_respawned, player_respawned)
|
||||||
|
|
||||||
commands.add_command('tpspawn', '<player> <spawn_name> teleports a player to the spawn point (Admins only)', tp_spawn_command)
|
commands.add_command('tpspawn', '<player> <spawn_name> teleports a player to the spawn point (Admins only)', tp_spawn_command) -- luacheck: ignore
|
||||||
commands.add_command('changespawn', '<player> <spawn_name> changes the spawn point for a player (Admins only)', change_spawn_command)
|
commands.add_command('changespawn', '<player> <spawn_name> changes the spawn point for a player (Admins only)', change_spawn_command) -- luacheck: ignore
|
||||||
commands.add_command('printspawns', 'prints info on all spawn points (Admins only)', print_spawns_command)
|
commands.add_command('printspawns', 'prints info on all spawn points (Admins only)', print_spawns_command) -- luacheck: ignore
|
||||||
commands.add_command('printplayersforspawn', '<spawn_name> prints all the connected players for a spawn (Admins only)', print_players_for_spawn_command)
|
commands.add_command('printplayersforspawn', '<spawn_name> prints all the connected players for a spawn (Admins only)', print_players_for_spawn_command) -- luacheck: ignore
|
||||||
|
|
||||||
return Module
|
return Module
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
-- luacheck: globals commands
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Game = require 'utils.game'
|
local Game = require 'utils.game'
|
||||||
local Utils = require 'utils.core'
|
local Utils = require 'utils.core'
|
||||||
@ -290,7 +291,8 @@ end
|
|||||||
--- Traps command errors if not in DEBUG.
|
--- Traps command errors if not in DEBUG.
|
||||||
if not _DEBUG then
|
if not _DEBUG then
|
||||||
local old_add_command = commands.add_command
|
local old_add_command = commands.add_command
|
||||||
commands.add_command = function(name, desc, func) -- luacheck: ignore 122
|
commands.add_command =
|
||||||
|
function(name, desc, func)
|
||||||
old_add_command(
|
old_add_command(
|
||||||
name,
|
name,
|
||||||
desc,
|
desc,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
-- luacheck: globals script
|
||||||
--- This Module allows for registering multiple handlers to the same event, overcoming the limitation of script.register.
|
--- This Module allows for registering multiple handlers to the same event, overcoming the limitation of script.register.
|
||||||
--
|
--
|
||||||
-- ** Event.add(event_name, handler) **
|
-- ** Event.add(event_name, handler) **
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
-- luacheck: globals script
|
||||||
-- This module exists to break the circular dependency between event.lua and global.lua.
|
-- This module exists to break the circular dependency between event.lua and global.lua.
|
||||||
-- It is not expected that any user code would require this module instead event.lua should be required.
|
-- It is not expected that any user code would require this module instead event.lua should be required.
|
||||||
local ErrorLogging = require 'utils.error_logging'
|
local ErrorLogging = require 'utils.error_logging'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
--luacheck:ignore global math
|
--luacheck: globals math
|
||||||
local _sin = math.sin
|
local _sin = math.sin
|
||||||
local _cos = math.cos
|
local _cos = math.cos
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
--luacheck:ignore global table
|
--luacheck: globals table
|
||||||
local random = math.random
|
local random = math.random
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local remove = table.remove
|
local remove = table.remove
|
||||||
|
Reference in New Issue
Block a user