Skip to content

Commit

Permalink
add luacheck and ci workflow (#88)
Browse files Browse the repository at this point in the history
* add luacheck and ci workflow

* fix another bunch

* more fixes

* more fixes

* regex magic

* add deps

* doc.lua special rules

* more regex magic

* final fixes

---------

Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
  • Loading branch information
BuckarooBanzay and BuckarooBanzay committed Jun 19, 2023
1 parent 3f9ca87 commit 3e1c1ca
Show file tree
Hide file tree
Showing 25 changed files with 668 additions and 604 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: luacheck

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- 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 ./
27 changes: 27 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
max_line_length = 200

globals = {
"digtron",
"catacomb"
}

read_globals = {
-- Stdlib
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
"VoxelManip",

-- Minetest
"minetest",
"vector", "ItemStack",
"dump", "VoxelArea",

-- Deps
"default", "awards", "pipeworks", "hopper", "technic", "doc", "intllib"
}

files = {
["doc.lua"] = {
max_line_length = 1000
}
}
16 changes: 8 additions & 8 deletions awards.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
if not minetest.get_modpath("awards") then
digtron.award_item_dug = function (items, name, count) end
digtron.award_layout = function (layout, name) end
digtron.award_item_built = function(item_name, name) end
digtron.award_crate = function (layout, name) end
digtron.award_item_dug = function() end
digtron.award_layout = function() end
digtron.award_item_built = function() end
digtron.award_crate = function() end
return
end

---------------------------------------------------------------------------

-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local S = dofile(MP.."/intllib.lua")

awards.register_trigger("digtron_dig", {
type = "counted_key",
progress = "@1/@2 excavated",
auto_description = {"Excavate 1 @2 using a Digtron.", "Excavate @1 @2 using a Digtron."},
auto_description_total = {"Excavate @1 block using a Digtron.", "Excavate @1 blocks using a Digtron."},
get_key = function(self, def)
get_key = function(_, def)
return minetest.registered_aliases[def.trigger.node] or def.trigger.node
end,
key_is_item = true,
Expand All @@ -37,7 +37,7 @@ awards.register_trigger("digtron_build", {
progress = "@1/@2 built",
auto_description = {"Build 1 @2 using a Digtron.", "Build @1 @2 using a Digtron."},
auto_description_total = {"Build @1 block using a Digtron.", "Build @1 blocks using a Digtron."},
get_key = function(self, def)
get_key = function(_, def)
return minetest.registered_aliases[def.trigger.node] or def.trigger.node
end,
key_is_item = true,
Expand Down Expand Up @@ -75,7 +75,7 @@ digtron.award_layout = function(layout, player)
if layout.builders ~= nil and table.getn(layout.builders) > 24 then
awards.unlock(name, "digtron_builder25")
end

if layout.controller.y > 100 then
awards.unlock(name, "digtron_height100")
if layout.controller.y > 1000 then
Expand Down
32 changes: 15 additions & 17 deletions class_fakeplayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
-- demand a "Player" object as a parameter and hopefully prevent the mods that have
-- registered with those callbacks from crashing on a nil dereference or bad function
-- call. This is not supposed to be a remotely functional thing, it's just supposed
-- to provide dummy methods and return values of the correct data type for anything that
-- to provide dummy methods and return values of the correct data type for anything that
-- might ignore the false "is_player()" return and go ahead and try to use this thing
-- anyway.

-- I'm trying to patch holes in bad mod programming, essentially. If a mod is so badly
-- programmed that it crashes anyway there's not a lot else I can do on my end of things.

DigtronFakePlayer = {}
DigtronFakePlayer.__index = DigtronFakePlayer
digtron.DigtronFakePlayer = {}
digtron.DigtronFakePlayer.__index = digtron.DigtronFakePlayer

local function return_value(x)
return (function() return x end)
Expand All @@ -32,18 +32,18 @@ local function return_empty_table()
return {}
end

function DigtronFakePlayer.update(self, pos, player_name)
function digtron.DigtronFakePlayer.update(self, pos, player_name)
self.is_fake_player = ":digtron " .. player_name
self.get_pos = return_value(pos)
end

function DigtronFakePlayer.create(pos, player_name)
function digtron.DigtronFakePlayer.create(pos, player_name)
local self = {}
setmetatable(self, DigtronFakePlayer)
setmetatable(self, digtron.DigtronFakePlayer)

self.is_fake_player = ":digtron " .. player_name

-- ObjectRef
-- ObjectRef
self.get_pos = return_value(pos)
self.set_pos = return_nil
self.move_to = return_nil
Expand Down Expand Up @@ -87,7 +87,6 @@ function DigtronFakePlayer.create(pos, player_name)
self.get_luaentity = return_nil

-- Player object

self.get_player_name = return_empty_string
self.get_player_velocity = return_nil
self.get_look_dir = return_value({x=0,y=1,z=0})
Expand All @@ -112,13 +111,12 @@ function DigtronFakePlayer.create(pos, player_name)

self.set_physics_override = return_nil
self.get_physics_override = return_value({speed = 1, jump = 1, gravity = 1, sneak = true, sneak_glitch = false, new_move = true,})



self.hud_add = return_nil
self.hud_remove = return_nil
self.hud_change = return_nil
self.hud_get = return_nil -- possibly important return value?
self.hud_set_flags = return_nil
self.hud_set_flags = return_nil
self.hud_get_flags = return_value({ hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true, minimap=true })
self.hud_set_hotbar_itemcount = return_nil
self.hud_get_hotbar_itemcount = return_zero
Expand All @@ -128,18 +126,18 @@ function DigtronFakePlayer.create(pos, player_name)
self.hud_get_hotbar_selected_image = return_empty_string
self.set_sky = return_nil
self.get_sky = return_empty_table -- may need members on this table

self.set_clouds = return_nil
self.get_clouds = return_value({density = 0, color = "#fff0f0e5", ambient = "#000000", height = 120, thickness = 16, speed = {x=0, y=-2}})

self.override_day_night_ratio = return_nil
self.get_day_night_ratio = return_nil

self.set_local_animation = return_nil
self.get_local_animation = return_empty_table

self.set_eye_offset = return_nil
self.get_eye_offset = return_value({x=0,y=0,z=0},{x=0,y=0,z=0})

return self
end

0 comments on commit 3e1c1ca

Please sign in to comment.