[LuaCheck]: Various improvements and changes (#1)

* Add GitHub workflow

* Tweak LuaCheck configuration

* Fix various LuaCheck warnings

* Add build status badge to README.md
master
David Leal 2020-11-25 19:35:49 -06:00 committed by GitHub
parent 41e0d803d5
commit cd954713ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 18 deletions

11
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,11 @@
on: [push, pull_request]
name: build
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""

View File

@ -1,14 +1,20 @@
-- Originally from bls_custom
unused_args = false
allow_defined_top = true
max_line_length = 80
globals = {
'INIT',
'minetest',
-- 'sscsm'
'sscsm',
table = {fields = {'copy'}},
'core',
}
read_globals = {
string = {fields = {'split', 'trim'}},
table = {fields = {'copy'}},
"__FLAGS__",
}
files["example_sscsm.lua"].ignore = { "" }

View File

@ -1,5 +1,7 @@
# Minetest server-sent CSM proof-of-concept
[![Build status](https://github.com/luk3yx/minetest-sscsm/workflows/build/badge.svg)](https://github.com/luk3yx/minetest-sscsm/actions)
[Source](https://git.minetest.land/luk3yx/sscsm)
Attempts to run server-sent CSMs locally in a sandbox.

View File

@ -59,22 +59,20 @@ local csm_order = false
-- Recalculate the CSM loading order
-- TODO: Make this nicer
local function recalc_csm_order()
local loaded = {}
local staging = {}
local order = {':init'}
local unsatisfied = {}
for name, def in pairs(sscsm.registered_csms) do
assert(name == def.name)
if name:sub(1, 1) == ':' then
loaded[name] = true
elseif not def.depends or #def.depends == 0 then
loaded[name] = true
table.insert(staging, name)
else
unsatisfied[name] = {}
for _, mod in ipairs(def.depends) do
if mod:sub(1, 1) ~= ':' then
unsatisfied[name][mod] = true
if name:sub(1, 1) ~= ':' then
if not def.depends or #def.depends == 0 then
table.insert(staging, name)
else
unsatisfied[name] = {}
for _, mod in ipairs(def.depends) do
if mod:sub(1, 1) ~= ':' then
unsatisfied[name][mod] = true
end
end
end
end

View File

@ -78,7 +78,7 @@ local matches = {
-- Handle backslashes
repeat
local s, e, pattern = find_multiple(code, '\\', char)
local _, e, pattern = find_multiple(code, '\\', char)
if pattern == char then
res = res .. code:sub(1, e)
code = code:sub(e + 1)

View File

@ -264,8 +264,8 @@ local function load_split_message(chan, msg)
-- Return true if all the messages have been received
if #msgs < l then return end
for i = 1, l do
if not msgs[i] then
for count = 1, l do
if not msgs[count] then
return
end
end
@ -305,9 +305,9 @@ minetest.register_on_receiving_chat_message(function(message)
-- Run callbacks
for _, func in ipairs(callbacks) do
local ok, msg = pcall(func, msg)
local ok, text = pcall(func, msg)
if not ok then
minetest.log('error', '[SSCSM] ' .. tostring(msg))
minetest.log('error', '[SSCSM] ' .. tostring(text))
end
end
return true