Fixed Existing Lua Check Errors

This commit is contained in:
Cooldude2606
2020-05-26 18:21:10 +01:00
parent 2aaeb06be3
commit 32507492b8
76 changed files with 1622 additions and 1617 deletions

View File

@@ -4,15 +4,17 @@
--- These are called factories because they return another function
-- use these as a simple methods of adding new items
-- they will do most of the work for you
-- ['item-name']=factory(params)
-- ['item-name'] = factory(params)
-- luacheck:ignore 212/amount_made 212/items_made 212/player
-- Use these to adjust for ticks ie game.tick < 5*minutes
-- luacheck:ignore 211/seconds 211/minutes 211/hours
local seconds, minutes, hours = 60, 3600, 216000
--- Use to make a split point for the number of items given based on time
-- ['stone-furnace']=cutoff_time(5*minutes,4,0) -- before 5 minutes give four items after 5 minutes give none
local function cutoff_time(time,before,after)
return function(amount_made,items_made,player)
-- ['stone-furnace']=cutoff_time(5*minutes, 4,0) -- before 5 minutes give four items after 5 minutes give none
local function cutoff_time(time, before, after)
return function(amount_made, items_made, player)
if game.tick < time then return before
else return after
end
@@ -20,9 +22,9 @@ local function cutoff_time(time,before,after)
end
--- Use to make a split point for the number of items given based on amount made
-- ['firearm-magazine']=cutoff_amount_made(100,10,0) -- give 10 items until 100 items have been made
local function cutoff_amount_made(amount,before,after)
return function(amount_made,items_made,player)
-- ['firearm-magazine']=cutoff_amount_made(100, 10, 0) -- give 10 items until 100 items have been made
local function cutoff_amount_made(amount, before, after)
return function(amount_made, items_made, player)
if amount_made < amount then return before
else return after
end
@@ -30,9 +32,9 @@ local function cutoff_amount_made(amount,before,after)
end
--- Same as above but will not give any items if x amount has been made of another item, useful for tiers
-- ['light-armor']=cutoff_amount_made_unless(5,0,1,'heavy-armor',5) -- give light armor once 5 have been made unless 5 heavy armor has been made
local function cutoff_amount_made_unless(amount,before,after,second_item,second_amount)
return function(amount_made,items_made,player)
-- ['light-armor']=cutoff_amount_made_unless(5, 0,1,'heavy-armor',5) -- give light armor once 5 have been made unless 5 heavy armor has been made
local function cutoff_amount_made_unless(amount, before, after, second_item, second_amount)
return function(amount_made, items_made, player)
if items_made(second_item) < second_amount then
if amount_made < amount then return before
else return after
@@ -43,11 +45,11 @@ local function cutoff_amount_made_unless(amount,before,after,second_item,second_
end
-- Use for mass production items where you want the amount to change based on the amount already made
-- ['iron-plate']=scale_amount_made(5*minutes,10,10) -- for first 5 minutes give 10 items then after apply a factor of 10
local function scale_amount_made(amount,before,scalar)
return function(amount_made,items_made,player)
-- ['iron-plate']=scale_amount_made(5*minutes, 10, 10) -- for first 5 minutes give 10 items then after apply a factor of 10
local function scale_amount_made(amount, before, scalar)
return function(amount_made, items_made, player)
if amount_made < amount then return before
else return (amount_made*scalar)/math.pow(game.tick/minutes,2)
else return (amount_made*scalar)/math.pow(game.tick/minutes, 2)
end
end
end
@@ -65,30 +67,30 @@ return {
skip_intro=true, --- @setting skip_intro skips the intro given in the default factorio free play scenario
skip_victory=true, --- @setting skip_victory will skip the victory screen when a rocket is launched
disable_base_game_silo_script=true, --- @setting disable_base_game_silo_script will not load the silo script at all
research_queue_from_start=true, --- @setting research_queue_from_start when true the research queue is useible from the start
research_queue_from_start=true, --- @setting research_queue_from_start when true the research queue is useable from the start
friendly_fire=false, --- @setting friendly_fire weather players will be able to attack each other on the same force
enemy_expansion=false, --- @setting enemy_expansion a catch all for in case the map settings file fails to load
chart_radius=10*32, --- @setting chart_radius the number of tiles that will be charted when the map starts
items = { --- @setting items items and there condition for being given
-- ['item-name'] = function(amount_made,production_stats,player) return <Number> end -- 0 means no items given
-- ['item-name'] = function(amount_made, production_stats, player) return <Number> end -- 0 means no items given
-- Plates
['iron-plate']=scale_amount_made(100,10,10),
['copper-plate']=scale_amount_made(100,0,8),
['steel-plate']=scale_amount_made(100,0,4),
['iron-plate']=scale_amount_made(100, 10, 10),
['copper-plate']=scale_amount_made(100, 0,8),
['steel-plate']=scale_amount_made(100, 0,4),
-- Secondary Items
['electronic-circuit']=scale_amount_made(1000,0,6),
['iron-gear-wheel']=scale_amount_made(1000,0,6),
['electronic-circuit']=scale_amount_made(1000, 0,6),
['iron-gear-wheel']=scale_amount_made(1000, 0,6),
-- Starting Items
['burner-mining-drill']=cutoff_time(10*minutes,4,0),
['stone-furnace']=cutoff_time(10*minutes,4,0),
['burner-mining-drill']=cutoff_time(10*minutes, 4,0),
['stone-furnace']=cutoff_time(10*minutes, 4,0),
-- Armor
['light-armor']=cutoff_amount_made_unless(5,0,1,'heavy-armor',5),
['heavy-armor']=cutoff_amount_made(5,0,1),
['light-armor']=cutoff_amount_made_unless(5, 0,1,'heavy-armor',5),
['heavy-armor']=cutoff_amount_made(5, 0,1),
-- Weapon
['pistol']=cutoff_amount_made_unless(0,1,1,'submachine-gun',5),
['submachine-gun']=cutoff_amount_made(5,0,1),
['pistol']=cutoff_amount_made_unless(0, 1,1,'submachine-gun',5),
['submachine-gun']=cutoff_amount_made(5, 0,1),
-- Ammo
['firearm-magazine']=cutoff_amount_made_unless(100,10,0,'piercing-rounds-magazine',100),
['piercing-rounds-magazine']=cutoff_amount_made(100,0,10),
['firearm-magazine']=cutoff_amount_made_unless(100, 10, 0,'piercing-rounds-magazine',100),
['piercing-rounds-magazine']=cutoff_amount_made(100, 0,10),
}
}

View File

@@ -1,11 +1,12 @@
--- This is a very simple config file which adds a admin only auth functio;
--- This is a very simple config file which adds a admin only auth function;
-- not much to change here its more so it can be enabled and disabled from ./config/file_loader.lua;
-- either way you can change the requirements to be "admin" if you wanted to
-- @config Commands-Auth-Admin
local Commands = require 'expcore.commands' --- @dep expcore.commands
Commands.add_authenticator(function(player,command,tags,reject)
-- luacheck:ignore 212/command
Commands.add_authenticator(function(player, command, tags, reject)
if tags.admin_only then
if player.admin then
return true

View File

@@ -4,7 +4,8 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
local Roles = require 'expcore.roles' --- @dep expcore.roles
Commands.add_authenticator(function(player,command,tags,reject)
-- luacheck:ignore 212/tags
Commands.add_authenticator(function(player, command, tags, reject)
if Roles.player_allowed(player,'command/'..command) then
return true
else

View File

@@ -1,7 +1,7 @@
--[[-- This file contains some common command param parse functions;
this file is less of a config and more of a requirement but you may wish to change how some behave;
as such you need to be confident with lua but you edit this config file;
use Commands.add_parse('name',function(input,player,reject) end) to add a parse;
use Commands.add_parse('name',function(input, player, reject) end) to add a parse;
see ./expcore/commands.lua for more details
@config Commands-Parse
@usage Adds Parses:
@@ -22,9 +22,8 @@ see ./expcore/commands.lua for more details
local Commands = require 'expcore.commands' --- @dep expcore.commands
local Game = require 'utils.game' --- @dep utils.game
Commands.add_parse('boolean',function(input,player,reject)
-- luacheck:ignore 212/player
Commands.add_parse('boolean',function(input, player)
if not input then return end -- nil check
input = input:lower()
if input == 'yes'
@@ -37,7 +36,7 @@ Commands.add_parse('boolean',function(input,player,reject)
end
end)
Commands.add_parse('string-options',function(input,player,reject,options)
Commands.add_parse('string-options',function(input, player, reject, options)
if not input then return end -- nil check
input = input:lower()
for option in options do
@@ -48,7 +47,7 @@ Commands.add_parse('string-options',function(input,player,reject,options)
return reject{'reject-string-options',options:concat(', ')}
end)
Commands.add_parse('string-max-length',function(input,player,reject,max_length)
Commands.add_parse('string-max-length',function(input, player, reject, max_length)
if not input then return end -- nil check
local length = input:len()
if length > max_length then
@@ -58,7 +57,7 @@ Commands.add_parse('string-max-length',function(input,player,reject,max_length)
end
end)
Commands.add_parse('number',function(input,player,reject)
Commands.add_parse('number',function(input, player, reject)
if not input then return end -- nil check
local number = tonumber(input)
if not number then
@@ -68,7 +67,7 @@ Commands.add_parse('number',function(input,player,reject)
end
end)
Commands.add_parse('integer',function(input,player,reject)
Commands.add_parse('integer',function(input, player, reject)
if not input then return end -- nil check
local number = tonumber(input)
if not number then
@@ -78,27 +77,27 @@ Commands.add_parse('integer',function(input,player,reject)
end
end)
Commands.add_parse('number-range',function(input,player,reject,range_min,range_max)
local number = Commands.parse('number',input,player,reject)
Commands.add_parse('number-range',function(input, player, reject, range_min, range_max)
local number = Commands.parse('number',input, player, reject)
if not number then return end -- nil check
if number < range_min or number > range_max then
return reject{'expcore-commands.reject-number-range',range_min,range_max}
return reject{'expcore-commands.reject-number-range',range_min, range_max}
else
return number
end
end)
Commands.add_parse('integer-range',function(input,player,reject,range_min,range_max)
local number = Commands.parse('integer',input,player,reject)
Commands.add_parse('integer-range',function(input, player, reject, range_min, range_max)
local number = Commands.parse('integer',input, player, reject)
if not number then return end -- nil check
if number < range_min or number > range_max then
return reject{'expcore-commands.reject-number-range',range_min,range_max}
return reject{'expcore-commands.reject-number-range',range_min, range_max}
else
return number
end
end)
Commands.add_parse('player',function(input,player,reject)
Commands.add_parse('player',function(input, player, reject)
if not input then return end -- nil check
local input_player = Game.get_player_from_any(input)
if not input_player then
@@ -108,8 +107,8 @@ Commands.add_parse('player',function(input,player,reject)
end
end)
Commands.add_parse('player-online',function(input,player,reject)
local input_player = Commands.parse('player',input,player,reject)
Commands.add_parse('player-online',function(input, player, reject)
local input_player = Commands.parse('player',input, player, reject)
if not input_player then return end -- nil check
if not input_player.connected then
return reject{'expcore-commands.reject-player-online'}
@@ -118,8 +117,8 @@ Commands.add_parse('player-online',function(input,player,reject)
end
end)
Commands.add_parse('player-alive',function(input,player,reject)
local input_player = Commands.parse('player-online',input,player,reject)
Commands.add_parse('player-alive',function(input, player, reject)
local input_player = Commands.parse('player-online',input, player, reject)
if not input_player then return end -- nil check
if not input_player.character or not input_player.character.health or input_player.character.health <= 0 then
return reject{'expcore-commands.reject-player-alive'}
@@ -128,7 +127,7 @@ Commands.add_parse('player-alive',function(input,player,reject)
end
end)
Commands.add_parse('force',function(input,player,reject)
Commands.add_parse('force',function(input, player, reject)
if not input then return end -- nil check
local force = game.forces[input]
if not force then
@@ -138,7 +137,7 @@ Commands.add_parse('force',function(input,player,reject)
end
end)
Commands.add_parse('surface',function(input,player,reject)
Commands.add_parse('surface',function(input, player, reject)
if not input then return end
local surface = game.surfaces[input]
if not surface then

View File

@@ -12,14 +12,15 @@ local Roles = require 'expcore.roles' --- @dep expcore.roles
local auto_complete = _C.auto_complete --- @dep expcore.common
require 'config.expcore.command_general_parse'
Commands.add_parse('role',function(input,player,reject)
-- luacheck:ignore 212/player
Commands.add_parse('role',function(input, player, reject)
if not input then return end
local roles = Roles.config.order
local rev_roles = {}
for i=#roles,1,-1 do
table.insert(rev_roles,roles[i])
for i=#roles, 1,-1 do
table.insert(rev_roles, roles[i])
end
local role = auto_complete(rev_roles,input)
local role = auto_complete(rev_roles, input)
role = Roles.get_role_by_name(role)
if not role then
return reject{'expcore-role.reject-role'}
@@ -28,8 +29,8 @@ Commands.add_parse('role',function(input,player,reject)
end
end)
Commands.add_parse('player-role',function(input,player,reject)
local input_player = Commands.parse('player',input,player,reject)
Commands.add_parse('player-role',function(input, player, reject)
local input_player = Commands.parse('player',input, player, reject)
if not input_player then return end -- nil check
local player_highest = Roles.get_player_highest_role(player)
local input_player_highest = Roles.get_player_highest_role(input_player)
@@ -40,14 +41,14 @@ Commands.add_parse('player-role',function(input,player,reject)
end
end)
Commands.add_parse('player-role-online',function(input,player,reject)
local input_player = Commands.parse('player-role',input,player,reject)
Commands.add_parse('player-role-online',function(input, player, reject)
local input_player = Commands.parse('player-role',input, player, reject)
if not input_player then return end -- nil check
return Commands.parse('player-online',input_player,player,reject)
return Commands.parse('player-online',input_player, player, reject)
end)
Commands.add_parse('player-role-alive',function(input,player,reject)
local input_player = Commands.parse('player-role',input,player,reject)
Commands.add_parse('player-role-alive',function(input, player, reject)
local input_player = Commands.parse('player-role',input, player, reject)
if not input_player then return end -- nil check
return Commands.parse('player-alive',input_player,player,reject)
return Commands.parse('player-alive',input_player, player, reject)
end)

View File

@@ -6,7 +6,7 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
local Global = require 'utils.global' --- @dep utils.global
local disabled_commands = {}
Global.register(disabled_commands,function(tbl)
Global.register(disabled_commands, function(tbl)
disabled_commands = tbl
end)
@@ -22,7 +22,8 @@ function Commands.enable(command_name)
disabled_commands[command_name] = nil
end
Commands.add_authenticator(function(player,command,tags,reject)
-- luacheck:ignore 212/player 212/tags
Commands.add_authenticator(function(player, command, tags, reject)
if disabled_commands[command] then
return reject{'command-auth.command-disabled'}
else