1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Merge pull request #853 from plague006/restrict_script

luacheckrc tweaks to script and commands
This commit is contained in:
Matthew 2019-03-06 16:44:18 -05:00 committed by GitHub
commit 2fa76ac85e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 27 additions and 14 deletions

View File

@ -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]--
-------------------------------------------------------------------------------
@ -180,8 +188,9 @@ stds.factorio_control = {
-- @commands@:
commands = {
fields = {
"add_command", "commands", "game_commands", "remove_command"
"commands", "game_commands", "remove_command"
},
other_fields = false,
},
-- @settings@:
@ -198,8 +207,8 @@ stds.factorio_control = {
-- (http://lua-api.factorio.com/latest/LuaBootstrap.html)
script = {
fields = {
"on_event", "on_nth_tick", "on_configuration_changed", "on_init", "on_load", "generate_event_name",
"raise_event", "get_event_handler", "mod_name", "get_event_order"
"on_configuration_changed", "raise_event",
"get_event_handler", "mod_name", "get_event_order"
},
other_fields = false,
},

View File

@ -160,8 +160,8 @@ local function linkportals()
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('linkportals', 'Select a portal to link to another. Run this command again to select the other one.', linkportals)
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) -- luacheck: ignore
Event.add(defines.events.on_tick, dim_on_tick)
return Public

View File

@ -70,7 +70,7 @@ local function get_resource(x, y)
return {name = name, position = {x, y}, amount = value}
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
init_blocks()
end

View File

@ -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_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('changespawn', '<player> <spawn_name> changes the spawn point for a player (Admins only)', change_spawn_command)
commands.add_command('printspawns', 'prints info on all spawn points (Admins only)', print_spawns_command)
commands.add_command('printplayersforspawn', '<spawn_name> prints all the connected players for a spawn (Admins only)', print_players_for_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) -- luacheck: ignore
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) -- luacheck: ignore
return Module

View File

@ -1,3 +1,4 @@
-- luacheck: globals commands
local Event = require 'utils.event'
local Game = require 'utils.game'
local Utils = require 'utils.core'
@ -290,7 +291,8 @@ end
--- Traps command errors if not in DEBUG.
if not _DEBUG then
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(
name,
desc,

View File

@ -1,3 +1,4 @@
-- luacheck: globals script
--- This Module allows for registering multiple handlers to the same event, overcoming the limitation of script.register.
--
-- ** Event.add(event_name, handler) **

View File

@ -1,3 +1,4 @@
-- luacheck: globals script
-- 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.
local ErrorLogging = require 'utils.error_logging'

View File

@ -1,4 +1,4 @@
--luacheck:ignore global math
--luacheck: globals math
local _sin = math.sin
local _cos = math.cos

View File

@ -1,4 +1,4 @@
--luacheck:ignore global table
--luacheck: globals table
local random = math.random
local floor = math.floor
local remove = table.remove