Add luacheck
parent
61cff1a7b5
commit
5218684993
|
@ -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: ""
|
|
@ -0,0 +1,27 @@
|
|||
max_line_length = 100
|
||||
|
||||
read_globals = {
|
||||
"DIR_DELIM",
|
||||
"dump",
|
||||
"vector",
|
||||
"VoxelManip", "VoxelArea",
|
||||
"PseudoRandom", "ItemStack",
|
||||
"AreaStore",
|
||||
"default",
|
||||
"intllib",
|
||||
"hud",
|
||||
"armor",
|
||||
"invisibility",
|
||||
"player_api",
|
||||
table = { fields = { "copy", "getn", "indexof" } },
|
||||
string = { fields = { "split" } }
|
||||
}
|
||||
|
||||
globals = {
|
||||
"minetest",
|
||||
"inv_access",
|
||||
"random_messages",
|
||||
"xban",
|
||||
}
|
||||
|
||||
ignore = {"212/self"}
|
|
@ -26,7 +26,7 @@ minetest.register_on_leaveplayer(function(player)
|
|||
players[playerName] = nil
|
||||
end)
|
||||
|
||||
minetest.register_on_chat_message(function(playerName, message)
|
||||
minetest.register_on_chat_message(function(playerName)
|
||||
players[playerName]["lastAction"] = minetest.get_gametime()
|
||||
end)
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ if enabled then
|
|||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
minetest.after(1, function()
|
||||
local name = player:get_player_name()
|
||||
local pos = player:get_pos()
|
||||
if not pos then
|
||||
return
|
||||
|
|
|
@ -46,7 +46,7 @@ minetest.register_chatcommand("nightandday", {
|
|||
params = "nightandday server",
|
||||
description = "Change day and night speeds",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
func = function(_, param)
|
||||
local p = string.split(param, " ", false, 2, false)
|
||||
if #p == 2 then
|
||||
local ds = tonumber(p[1])
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
-- Intllib
|
||||
local S = intllib.make_gettext_pair()
|
||||
|
||||
local function red(str)
|
||||
return minetest.colorize("#FF0000", str)
|
||||
end
|
||||
|
||||
local function green(str)
|
||||
return minetest.colorize("#7CFC00", str)
|
||||
end
|
||||
|
||||
minetest.register_node("player_password:wood", {
|
||||
description = S("Change Password"),
|
||||
tiles = {"signs_wood.png"},
|
||||
|
@ -14,33 +22,32 @@ minetest.register_node("player_password:wood", {
|
|||
"button_exit[1.01,1.4;2.8,1;;" .. S("Change Password") .. "]")
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, _, fields, sender)
|
||||
on_receive_fields = function(_, _, fields, sender)
|
||||
local name = sender:get_player_name()
|
||||
local pwd = fields.pwd
|
||||
if not name or not pwd then return end
|
||||
|
||||
if pwd == "" then
|
||||
minetest.chat_send_player(name,
|
||||
minetest.colorize("#FF0000", S("You cannot set an empty password!")))
|
||||
minetest.chat_send_player(name, red(S("You cannot set an empty password!")))
|
||||
return
|
||||
end
|
||||
if #pwd < 3 then
|
||||
minetest.chat_send_player(name,
|
||||
minetest.colorize("#FF0000", S("The password is too short! Minimum length - 3 characters.")))
|
||||
red(S("The password is too short! Minimum length - 3 characters.")))
|
||||
return
|
||||
end
|
||||
if #pwd > 24 then
|
||||
minetest.chat_send_player(name,
|
||||
minetest.colorize("#FF0000", S("The password is too long! Maximum length - 24 characters.")))
|
||||
red(S("The password is too long! Maximum length - 24 characters.")))
|
||||
return
|
||||
end
|
||||
if pwd:find("[^a-zA-Z0-9%-_]") then
|
||||
minetest.chat_send_player(name,
|
||||
minetest.colorize("#FF0000", S("The password contains prohibited characters! Use only Latin letters or numbers.")))
|
||||
red(S("The password contains prohibited characters! Use only Latin letters or numbers.")))
|
||||
end
|
||||
|
||||
local password = minetest.get_password_hash(name, pwd)
|
||||
minetest.set_player_password(name, password)
|
||||
minetest.chat_send_player(name, minetest.colorize("#7CFC00", S("Password changed! Your new password: @1", pwd)))
|
||||
minetest.chat_send_player(name, green(S("Password changed! Your new password: @1", pwd)))
|
||||
end
|
||||
})
|
||||
|
|
|
@ -132,9 +132,8 @@ end)
|
|||
|
||||
minetest.register_chatcommand("xban_gui", {
|
||||
description = "Show XBan GUI",
|
||||
params = "",
|
||||
privs = { ban=true, },
|
||||
func = function(name, params)
|
||||
func = function(name)
|
||||
minetest.show_formspec(name, FORMNAME, make_fs(name))
|
||||
end
|
||||
})
|
||||
|
|
|
@ -384,17 +384,13 @@ end
|
|||
minetest.register_chatcommand("xban_cleanup", {
|
||||
description = "Removes all non-banned entries from the xban db",
|
||||
privs = { server=true },
|
||||
func = function(name, params)
|
||||
func = function()
|
||||
local old_count = #db
|
||||
|
||||
local i = 1
|
||||
while i <= #db do
|
||||
for i = 0, #db do
|
||||
if not db[i].banned then
|
||||
-- not banned, remove from db
|
||||
table.remove(db, i)
|
||||
else
|
||||
-- banned, hold entry back
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue