Browse Source

Add luacheck

master
MoNTE48 1 year ago
parent
commit
3a17818e34
  1. 17
      .github/workflows/luacheck.yml
  2. 2
      .gitignore
  3. 22
      .luacheckrc
  4. 4
      hud.lua
  5. 1
      internal.lua
  6. 9
      protector.lua

17
.github/workflows/luacheck.yml

@ -0,0 +1,17 @@
name: luacheck
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: apt
run: sudo apt-get install -y luarocks
- name: luacheck install
run: luarocks install --local luacheck
- name: luacheck run
run: $HOME/.luarocks/bin/luacheck ./

2
.gitignore vendored

@ -0,0 +1,2 @@
*~

22
.luacheckrc

@ -0,0 +1,22 @@
unused_args = false
read_globals = {
"DIR_DELIM",
"core",
"dump",
"vector", "nodeupdate",
"VoxelManip", "VoxelArea",
"PseudoRandom", "ItemStack",
"AreaStore",
"default",
"intllib",
"hud",
"mesecon",
table = { fields = { "copy", "getn", "indexof" } }
}
globals = {
"minetest",
-- mod namespace
"areas"
}

4
hud.lua

@ -22,12 +22,12 @@ minetest.register_playerstep(function(_, playernames)
if minetest.is_valid_pos(pos) then
local areaStrings = {}
for id, area in pairs(areas:getAreasAtPos(pos)) do
for id, area in pairs(areas:getAreasAtPos(pos)) do
areaStrings[#areaStrings+1] = ("%s [%u] (%s%s)")
:format(area.name, id, area.owner,
area.open and ":open" or "")
end
local str = ""
for _, area in pairs(areas:getExternalHudEntries(pos)) do
if area.name then str = area.name .. " " end

1
internal.lua

@ -34,7 +34,6 @@ function areas:load()
return err
end
local data = file:read("*a")
local err
if data:sub(1, 1) == "[" then
self.areas, err = minetest.parse_json(data)
else

9
protector.lua

@ -39,7 +39,7 @@ minetest.register_node("areas:protector", {
minetest.chat_send_player(name, red(S("You have already protected this area.")))
return itemstack
end
local id = areas:add(name, S("Protector Block"), pos1, pos2)
areas:save()
minetest.chat_send_player(name,
@ -69,7 +69,8 @@ minetest.register_node("areas:protector", {
end,
on_punch = function(pos)
local objs = minetest.get_objects_inside_radius(pos, 0.5) -- a radius of 0.5 since the entity serialization seems to be not that precise
-- a radius of 0.5 since the entity serialization seems to be not that precise
local objs = minetest.get_objects_inside_radius(pos, 0.5)
local displayed = false
for _, o in pairs(objs) do
if not o:is_player() and o:get_luaentity().name == "areas:display" then
@ -84,12 +85,12 @@ minetest.register_node("areas:protector", {
})
-- entities code below (and above) mostly copied-pasted from Zeg9's protector mod
minetest.register_entity("areas:display", {
physical = false,
collisionbox = {0},
visual = "wielditem",
visual_size = {x = 1.0 / 1.5, y = 1.0 / 1.5}, -- wielditem seems to be scaled to 1.5 times original node size
-- wielditem seems to be scaled to 1.5 times original node size
visual_size = {x = 1.0 / 1.5, y = 1.0 / 1.5},
textures = {"areas:display_node"},
timer = 0,
on_step = function(self, dtime)

Loading…
Cancel
Save