1
0
mirror of https://github.com/pyrollo/display_modpack.git synced 2024-11-15 23:00:30 +01:00

luacheck, remove old compatibility stuff

This commit is contained in:
Niklp09 2023-06-11 20:13:08 +02:00
parent 72a9d1bb7d
commit 1f31515cdd
17 changed files with 71 additions and 96 deletions

10
.github/workflows/luacheck.yml vendored Normal file
View File

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

25
.luacheckrc Normal file
View File

@ -0,0 +1,25 @@
unused_args = false
ignore = {
"431", -- Shadowing an upvalue
"432", -- Shadowing an upvalue argument
}
read_globals = {
"minetest",
"string",
"table",
"vector",
"default"
}
globals = {
"boards",
"display_api",
"font_api",
"ontime_clocks",
"signs",
"signs_api",
"signs_road",
"steles"
}

View File

@ -7,7 +7,7 @@
released under CC-BY-SA license
https://fontstruct.com/fontstructions/show/63155/tiny_cursive
Derivative texture are under CC-BY-SA license
Code is under LGPL v3 license
--]]
@ -19,7 +19,7 @@ font_api.register_font('tinycurs',
marginbottom = -2,
linespacing = -4,
height = 19,
widths = {
widths = {
[0]=9, [32]=9, [33]=6, [34]=7, [35]=10, [36]=14, [37]=14, [38]=12, [39]=3, [40]=6, [41]=6, [42]=9, [43]=8, [44]=3, [45]=7, [46]=3, [47]=9, [48]=9, [49]=7, [50]=10, [51]=9, [52]=9, [53]=10, [54]=10, [55]=9, [56]=10, [57]=8, [58]=5, [59]=5, [60]=8, [61]=8, [62]=8, [63]=8, [64]=12, [65]=9, [66]=7, [67]=9, [68]=10, [69]=8, [70]=8, [71]=8, [72]=10, [73]=7, [74]=8, [75]=9, [76]=9, [77]=12, [78]=10, [79]=9, [80]=9, [81]=9, [82]=11, [83]=11, [84]=8, [85]=11, [86]=11, [87]=12, [88]=12, [89]=11, [90]=11, [91]=8, [92]=5, [93]=8, [94]=8, [95]=8, [96]=5, [97]=6, [98]=6, [99]=6, [100]=7, [101]=6, [102]=5, [103]=6, [104]=6, [105]=4, [106]=5, [107]=7, [108]=5, [109]=9, [110]=8, [111]=6, [112]=9, [113]=8, [114]=7, [115]=7, [116]=6, [117]=8, [118]=8, [119]=11, [120]=10, [121]=8, [122]=8, [123]=8, [124]=6, [125]=9, [126]=10, [8216]=4, [8217]=4, [8220]=6, [8221]=6
},
}

View File

@ -49,7 +49,7 @@ local function on_receive_fields(pos, formname, fields, player)
end
end
models = {
local models = {
black_board = {
depth = 1/16, width = 1, height = 1,
entity_fields = {
@ -132,7 +132,7 @@ minetest.register_craft(
output = "boards:black_board",
recipe = {
{"group:wood", "group:stone", "dye:black"},
}
}
})
minetest.register_craft(
@ -140,6 +140,6 @@ minetest.register_craft(
output = "boards:green_board",
recipe = {
{"group:wood", "group:stone", "dye:dark_green"},
}
}
})

View File

@ -19,17 +19,17 @@
-- Deprecation
function deprecated_group(deprecated_group, replacement_group)
local function deprecated_group(old_group, replacement_group)
for name, ndef in pairs(minetest.registered_nodes) do
if ndef.groups and ndef.groups[deprecated_group] then
if ndef.groups and ndef.groups[old_group] then
minetest.log("warning", string.format(
'Node %s belongs to deprecated "%s" group which should be replaced with new "%s" group.',
name, deprecated_group, replacement_group))
name, old_group, replacement_group))
end
end
end
function deprecated_global_table(deprecated_global_name, replacement_global_name)
local function deprecated_global_table(deprecated_global_name, replacement_global_name)
assert(type(deprecated_global_name) == 'string', "deprecated_global_name should be a string.")
assert(type(replacement_global_name) == 'string', "replacement_global_name should be a string.")
assert(deprecated_global_name ~= '', "deprecated_global_name should not be empty.")

View File

@ -65,9 +65,7 @@ local function compute_values(r)
for _ = 1, r.x do d, w, h = rx(d), rx(w), rx(h) end
for _ = 1, r.y do d, w, h = ry(d), ry(w), ry(h) end
return {
rotation=r, depth=d, width=w, height=h,
restricted=(r.x==0 and r.z==0) }
return {rotation=r, depth=d, width=w, height=h}
end
for i, r in pairs(facedir_rotations) do
@ -78,25 +76,6 @@ for i, r in pairs(wallmounted_rotations) do
wallmounted_values[i] = compute_values(r)
end
-- Detect rotation restriction
local rotation_restricted = nil
minetest.register_entity('display_api:dummy_entity', {
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "upright_sprite",
textures = {} })
function display_api.is_rotation_restricted()
if rotation_restricted == nil then
local objref = minetest.add_entity(
{x=0, y=0, z=0}, 'display_api:dummy_entity')
if objref then
rotation_restricted = objref.set_rotation == nil
objref:remove()
end
end
return rotation_restricted
end
-- Clip position property to maximum entity position
local function clip_pos_prop(posprop)
@ -243,16 +222,6 @@ function display_api.on_place(itemstack, placer, pointed_thing, override_param2)
z = pointed_thing.under.z - pointed_thing.above.z,
}
local rotation_restriction = display_api.is_rotation_restricted()
if rotation_restriction then
-- If item is not placed on a wall, use the player's view direction instead
if dir.x == 0 and dir.z == 0 then
dir = placer:get_look_dir()
end
dir.y = 0
end
local param2 = 0
if ndef then
if ndef.paramtype2 == "wallmounted" or
@ -261,7 +230,7 @@ function display_api.on_place(itemstack, placer, pointed_thing, override_param2)
elseif ndef.paramtype2 == "facedir" or
ndef.paramtype2 == "colorfacedir" then
param2 = minetest.dir_to_facedir(dir, not rotation_restriction)
param2 = minetest.dir_to_facedir(dir, true)
end
end
return minetest.item_place(itemstack, placer, pointed_thing,
@ -291,7 +260,7 @@ function display_api.on_rotate(pos, node, user, _, new_param2)
return
end
if ov.restricted or not display_api.is_rotation_restricted() then
if ov.restricted then
minetest.swap_node(pos, node)
display_api.update_entities(pos)
return true

View File

@ -18,7 +18,7 @@
-- Deprecation
function deprecated_global_table(deprecated_global_name, replacement_global_name)
local function deprecated_global_table(deprecated_global_name, replacement_global_name)
assert(type(deprecated_global_name) == 'string', "deprecated_global_name should be a string.")
assert(type(replacement_global_name) == 'string', "replacement_global_name should be a string.")
assert(deprecated_global_name ~= '', "deprecated_global_name should not be empty.")

View File

@ -19,6 +19,7 @@
-- This is the unicode char fallback map. If a char is not present in
-- font, this maps indicates which char to try to use instead next.
-- luacheck: ignore
return {
-- Lowercase chars
['a'] = 'A', ['b'] = 'B', ['c'] = 'C', ['d'] = 'D',

View File

@ -212,7 +212,7 @@ end
-- @return Texture string
function Font:render(text, texturew, textureh, style)
local style = style or {}
style = style or {}
-- Split text into lines (and limit to style.lines # of lines)
local lines = {}
@ -243,17 +243,17 @@ function Font:render(text, texturew, textureh, style)
y = y + (self.margintop or 0)
for _, line in pairs(lines) do
for _, l in pairs(lines) do
if style.halign == "left" then
x = 0
elseif style.halign == "right" then
x = texturew - line.width
x = texturew - l.width
else
x = (texturew - line.width) / 2
x = (texturew - l.width) / 2
end
while line.text ~= '' do
codepoint, line.text = self:get_next_char(line.text)
while l.text ~= '' do
codepoint, l.text = self:get_next_char(l.text)
if codepoint == nil then return '' end -- UTF Error
-- Add image only if it is visible (at least partly)

View File

@ -60,6 +60,7 @@ local function get_default_font()
-- If failed, chose first font
if default_font == nil then
-- luacheck: ignore 512
for _, font in pairs(font_api.registered_fonts) do
default_font = font
break

View File

@ -1,11 +1,11 @@
--[[
Metro font for Font API
Original font Metro Sans
by Christian Munk (CMunk)
Original font Metro Sans
by Christian Munk (CMunk)
released under CC-BY-SA license
https://fontstruct.com/fontstructions/show/723864/metro_sans
Derivative textures and code are under CC-BY-SA license

View File

@ -1,5 +1,5 @@
--[[
ontime_clocks mod for Minetest - Clock nodes displaying ingame time
ontime_clocks mod for Minetest - Clock nodes displaying ingame time
(c) Pierre-Yves Rollo
This file is part of ontime_clocks.
@ -34,7 +34,7 @@ function ontime_clocks.get_m12()
end
function ontime_clocks.get_digital_properties(color_off, color_on, hour, minute)
return
return
{
textures={"ontime_clocks_digital_background.png^[colorize:"..color_off
.."^([combine:21x7"
@ -51,7 +51,7 @@ end
function ontime_clocks.get_needles_properties(color, size, hour, minute)
return
{
textures={"[combine:"..size.."x"..size
textures={"[combine:"..size.."x"..size
..":0,"..(-size*hour).."=ontime_clocks_needle_h"..size..".png"
..":0,"..(-size*minute).."=ontime_clocks_needle_m"..size..".png"
.."^[colorize:"..color},

View File

@ -1,5 +1,5 @@
--[[
ontime_clocks mod for Minetest - Clock nodes displaying ingame time
ontime_clocks mod for Minetest - Clock nodes displaying ingame time
(c) Pierre-Yves Rollo
This file is part of ontime_clocks.

View File

@ -1,5 +1,5 @@
--[[
ontime_clocks mod for Minetest - Clock nodes displaying ingame time
ontime_clocks mod for Minetest - Clock nodes displaying ingame time
(c) Pierre-Yves Rollo
This file is part of ontime_clocks.

View File

@ -227,7 +227,7 @@ minetest.register_node("ontime_clocks:frameless_white", {
minetest.register_lbm({
name = "ontime_clocks:nodetimer_init",
nodenames = {"ontime_clocks:green_digital", "ontime_clocks:red_digital", "ontime_clocks:white",
nodenames = {"ontime_clocks:green_digital", "ontime_clocks:red_digital", "ontime_clocks:white",
"ontime_clocks:frameless_black", "ontime_clocks:frameless_gold", "ontime_clocks:frameless_white"},
run_at_every_load = true,
action = function(pos)

View File

@ -89,7 +89,6 @@ end
function signs_api.on_place_direction(itemstack, placer, pointed_thing)
local name = itemstack:get_name()
local ndef = minetest.registered_nodes[name]
local restriction = display_api.is_rotation_restricted()
local bdir = {
x = pointed_thing.under.x - pointed_thing.above.x,
@ -101,24 +100,14 @@ function signs_api.on_place_direction(itemstack, placer, pointed_thing)
local ndir, test
if ndef and ndef.paramtype2 == "facedir" then
-- If legacy mode, only accept upright nodes
if restriction and bdir.x == 0 and bdir.z == 0 then
-- Ceiling or floor pointed (facedir chosen from player dir)
ndir = minetest.dir_to_facedir({x=pdir.x, y=0, z=pdir.z})
else
-- Wall pointed or no rotation restriction
ndir = minetest.dir_to_facedir(bdir, not restriction)
end
-- Wall pointed
ndir = minetest.dir_to_facedir(bdir, true)
test = { [0]=-pdir.x, pdir.z, pdir.x, -pdir.z, -pdir.x, [8]=pdir.x }
end
if ndef and ndef.paramtype2 == "wallmounted" then
ndir = minetest.dir_to_wallmounted(bdir)
-- If legacy mode, only accept upright nodes
if restriction and (ndir == 0 or ndir == 1) then
ndir = minetest.dir_to_wallmounted({x=pdir.x, y=0, z=pdir.z})
end
test = { [0]=-pdir.x, -pdir.x, pdir.z, -pdir.z, -pdir.x, pdir.x}
end
@ -141,7 +130,6 @@ function signs_api.on_place_direction(itemstack, placer, pointed_thing)
end
-- Handles screwdriver rotation
-- (see "if" block below for rotation restriction mode).
signs_api.on_rotate = function(pos, node, player, mode, new_param2)
-- If rotation mode is 1 and sign is directional, swap direction between
-- each rotation.
@ -165,25 +153,6 @@ signs_api.on_rotate = function(pos, node, player, mode, new_param2)
return display_api.on_rotate(pos, node, player, mode, new_param2)
end
-- Legacy mode with rotation restriction
-- TODO:When MT < 5.0 no more in use, to be removed
if display_api.is_rotation_restricted() then
signs_api.on_rotate = function(pos, node, player, mode, new_param2)
-- If rotation mode is 2 and sign is directional, swap direction.
-- Otherwise use display_api's on_rotate function.
if mode == 2 then
local ndef = minetest.registered_nodes[node.name]
if ndef and ndef.signs_other_dir then
minetest.swap_node(pos, {name = ndef.signs_other_dir,
param1 = node.param1, param2 = node.param2})
display_api.update_entities(pos)
return true
end
end
return display_api.on_rotate(pos, node, player, mode, new_param2)
end
end
function signs_api.register_sign(mod, name, model)
-- Default fields
local fields = {

View File

@ -21,10 +21,10 @@
local S = steles.S
steles.materials = {
'default:stone',
'default:sandstone',
'default:stone',
'default:sandstone',
'default:desert_stone',
'technic:marble',
'technic:marble',
'technic:granite',
}