mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2024-11-22 07:23:48 +01:00
add luacheck
This commit is contained in:
parent
521b73d4ed
commit
62526b9a3b
18
.github/workflows/luacheck.yml
vendored
Normal file
18
.github/workflows/luacheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
name: luacheck
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- 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 ./
|
25
.luacheckrc
Normal file
25
.luacheckrc
Normal file
@ -0,0 +1,25 @@
|
||||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
exclude_files = {".luacheckrc"}
|
||||
|
||||
globals = {
|
||||
"minetest", "core",
|
||||
|
||||
--mod provided
|
||||
"unifieddyes",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
--luac
|
||||
"math", "table",
|
||||
|
||||
-- Builtin
|
||||
"vector", "ItemStack", "dump", "DIR_DELIM", "VoxelArea", "Settings", "PcgRandom", "VoxelManip", "PseudoRandom",
|
||||
|
||||
--mod produced
|
||||
|
||||
}
|
36
airbrush.lua
36
airbrush.lua
@ -49,7 +49,7 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
||||
return
|
||||
end
|
||||
|
||||
local palette = nil
|
||||
local palette
|
||||
local fdir = 0
|
||||
if not def or not def.palette then
|
||||
minetest.chat_send_player(player_name, "*** That node can't be colored -- it's either undefined or has no palette.")
|
||||
@ -71,12 +71,15 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
||||
|
||||
local idx, hue = unifieddyes.getpaletteidx(painting_with, palette)
|
||||
local inv = player:get_inventory()
|
||||
if (not creative or not creative.is_enabled_for(player_name)) and not inv:contains_item("main", painting_with) then
|
||||
if (not minetest.is_creative_enabled(player_name)) and not inv:contains_item("main", painting_with) then
|
||||
local suff = ""
|
||||
if not idx then
|
||||
suff = " Besides, "..string.sub(painting_with, 5).." can't be applied to that node."
|
||||
end
|
||||
minetest.chat_send_player(player_name, "*** You're in survival mode, and you're out of "..string.sub(painting_with, 5).."."..suff)
|
||||
minetest.chat_send_player(
|
||||
player_name,
|
||||
"*** You're in survival mode, and you're out of "..string.sub(painting_with, 5).."."..suff
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
@ -92,8 +95,8 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
||||
|
||||
local modname = string.sub(name, 1, string.find(name, ":")-1)
|
||||
local nodename2 = string.sub(name, string.find(name, ":")+1)
|
||||
local oldcolor = "snozzberry"
|
||||
local newcolor = "razzberry" -- intentionally misspelled ;-)
|
||||
local oldcolor
|
||||
local newcolor
|
||||
|
||||
if def.ud_color_start and def.ud_color_end then
|
||||
oldcolor = string.sub(node.name, def.ud_color_start, def.ud_color_end)
|
||||
@ -123,7 +126,7 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
||||
return
|
||||
end
|
||||
minetest.swap_node(pos, {name = name, param2 = fdir + idx})
|
||||
if not creative or not creative.is_enabled_for(player_name) then
|
||||
if not minetest.is_creative_enabled(player_name) then
|
||||
inv:remove_item("main", painting_with)
|
||||
return
|
||||
end
|
||||
@ -144,7 +147,7 @@ function unifieddyes.make_readable_color(color)
|
||||
local s = string.gsub(color, "_s50", "")
|
||||
|
||||
-- replace underscores with spaces to make it look nicer
|
||||
local s = string.gsub(s, "_", " ")
|
||||
s = string.gsub(s, "_", " ")
|
||||
|
||||
-- capitalize words, you know, looks nicer ;)
|
||||
s = string.gsub(s, "(%l)(%w*)", function(a,b) return string.upper(a)..b end)
|
||||
@ -160,7 +163,8 @@ function unifieddyes.make_readable_color(color)
|
||||
return s
|
||||
end
|
||||
|
||||
function unifieddyes.make_colored_square(hexcolor, colorname, showall, creative, painting_with, nodepalette, hp, v2, selindic, inv, explist)
|
||||
function unifieddyes.make_colored_square(hexcolor, colorname, showall, creative, painting_with, nodepalette, hp, v2,
|
||||
selindic, inv, explist)
|
||||
|
||||
local dye = "dye:"..colorname
|
||||
|
||||
@ -216,7 +220,7 @@ function unifieddyes.show_airbrush_form(player)
|
||||
|
||||
local player_name = player:get_player_name()
|
||||
local painting_with = unifieddyes.player_selected_dye[player_name] or unifieddyes.player_current_dye[player_name]
|
||||
local creative = creative and creative.is_enabled_for(player_name)
|
||||
local creative = minetest.is_creative_enabled(player_name)
|
||||
local inv = player:get_inventory()
|
||||
local nodepalette = "extended"
|
||||
local showall = unifieddyes.player_showall[player_name]
|
||||
@ -280,7 +284,8 @@ function unifieddyes.show_airbrush_form(player)
|
||||
|
||||
local hexcolor = string.format("%02x", r2)..string.format("%02x", g2)..string.format("%02x", b2)
|
||||
local f
|
||||
f, selindic = unifieddyes.make_colored_square(hexcolor, val..hue..sat, showall, creative, painting_with, nodepalette, hp, v2, selindic, inv, explist)
|
||||
f, selindic = unifieddyes.make_colored_square(hexcolor, val..hue..sat, showall, creative, painting_with, nodepalette,
|
||||
hp, v2, selindic, inv, explist)
|
||||
t[#t+1] = f
|
||||
end
|
||||
|
||||
@ -313,7 +318,8 @@ function unifieddyes.show_airbrush_form(player)
|
||||
|
||||
local hexcolor = string.format("%02x", r3)..string.format("%02x", g3)..string.format("%02x", b3)
|
||||
local f
|
||||
f, selindic = unifieddyes.make_colored_square(hexcolor, val..hue..sat, showall, creative, painting_with, nodepalette, hp, v2, selindic, inv, explist)
|
||||
f, selindic = unifieddyes.make_colored_square(hexcolor, val..hue..sat, showall, creative, painting_with,
|
||||
nodepalette, hp, v2, selindic, inv, explist)
|
||||
t[#t+1] = f
|
||||
end
|
||||
end
|
||||
@ -335,7 +341,8 @@ function unifieddyes.show_airbrush_form(player)
|
||||
end
|
||||
|
||||
local f
|
||||
f, selindic = unifieddyes.make_colored_square(hexgrey, grey, showall, creative, painting_with, nodepalette, hp, v2, selindic, inv, explist)
|
||||
f, selindic = unifieddyes.make_colored_square(hexgrey, grey, showall, creative, painting_with, nodepalette, hp, v2,
|
||||
selindic, inv, explist)
|
||||
t[#t+1] = f
|
||||
|
||||
end
|
||||
@ -431,7 +438,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
minetest.chat_send_player(player_name, "*** Clicked \"Accept\", but the selected color can't be used on the")
|
||||
minetest.chat_send_player(player_name, "*** node that was right-clicked (and \"Show All\" wasn't in effect).")
|
||||
if unifieddyes.player_current_dye[player_name] then
|
||||
minetest.chat_send_player(player_name, "*** Ignoring it and sticking with "..string.sub(unifieddyes.player_current_dye[player_name], 5)..".")
|
||||
minetest.chat_send_player(player_name, "*** Ignoring it and sticking with "
|
||||
..string.sub(unifieddyes.player_current_dye[player_name], 5)..".")
|
||||
else
|
||||
minetest.chat_send_player(player_name, "*** Ignoring it.")
|
||||
end
|
||||
@ -451,7 +459,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local s3 = string.sub(s1,1, string.find(s1, '"')-1)
|
||||
|
||||
local inv = player:get_inventory()
|
||||
local creative = creative and creative.is_enabled_for(player_name)
|
||||
local creative = minetest.is_creative_enabled(player_name)
|
||||
local dye = "dye:"..s3
|
||||
|
||||
if (showall or unifieddyes.palette_has_color[nodepalette.."_"..s3]) and
|
||||
|
24
api.lua
24
api.lua
@ -1,7 +1,5 @@
|
||||
-- This file supplies the majority of Unified Dyes' API
|
||||
|
||||
local S = minetest.get_translator("unifieddyes")
|
||||
|
||||
unifieddyes.player_current_dye = {}
|
||||
unifieddyes.player_selected_dye = {}
|
||||
unifieddyes.player_last_right_clicked = {}
|
||||
@ -51,7 +49,7 @@ minetest.register_on_placenode(
|
||||
|
||||
local function move_item(item, pos, inv, digger, fix_color)
|
||||
if not (digger and digger:is_player()) then return end
|
||||
local creative = creative_mode or minetest.check_player_privs(digger, "creative")
|
||||
local creative = minetest.is_creative_enabled(digger:get_player_name())
|
||||
item = unifieddyes.fix_bad_color_info(item, fix_color)
|
||||
if inv:room_for_item("main", item)
|
||||
and (not creative or not inv:contains_item("main", item, true)) then
|
||||
@ -78,9 +76,11 @@ function unifieddyes.on_dig(pos, node, digger)
|
||||
fix_color = 240
|
||||
elseif def.paramtype2 == "color" and oldparam2 == 0 and def.palette == "unifieddyes_palette_extended.png" then
|
||||
fix_color = 0
|
||||
elseif def.paramtype2 == "colorwallmounted" and math.floor(oldparam2 / 8) == 0 and def.palette == "unifieddyes_palette_colorwallmounted.png" then
|
||||
elseif def.paramtype2 == "colorwallmounted" and math.floor(oldparam2 / 8) == 0
|
||||
and def.palette == "unifieddyes_palette_colorwallmounted.png" then
|
||||
fix_color = 0
|
||||
elseif def.paramtype2 == "colorfacedir" and math.floor(oldparam2 / 32) == 0 and string.find(def.palette, "unifieddyes_palette_") then
|
||||
elseif def.paramtype2 == "colorfacedir" and math.floor(oldparam2 / 32) == 0
|
||||
and string.find(def.palette, "unifieddyes_palette_") then
|
||||
fix_color = 0
|
||||
end
|
||||
|
||||
@ -147,7 +147,7 @@ end
|
||||
|
||||
local function register_c(craft, h, sat, val)
|
||||
local hue = (type(h) == "table") and h[1] or h
|
||||
local color = ""
|
||||
local color
|
||||
if val then
|
||||
if craft.palette == "wallmounted" then
|
||||
color = val..hue..sat
|
||||
@ -288,9 +288,9 @@ end
|
||||
|
||||
function unifieddyes.get_hsv(name) -- expects a node/item name
|
||||
local hue = ""
|
||||
local a,b
|
||||
local a
|
||||
for _, i in ipairs(unifieddyes.HUES_EXTENDED) do
|
||||
a,b = string.find(name, "_"..i[1])
|
||||
a,_ = string.find(name, "_"..i[1])
|
||||
if a then
|
||||
hue = i[1]
|
||||
break
|
||||
@ -328,8 +328,6 @@ end
|
||||
|
||||
function unifieddyes.getpaletteidx(color, palette_type)
|
||||
|
||||
local origcolor = color
|
||||
|
||||
if string.sub(color,1,4) == "dye:" then
|
||||
color = string.sub(color,5,-1)
|
||||
elseif string.sub(color,1,12) == "unifieddyes:" then
|
||||
@ -383,7 +381,8 @@ function unifieddyes.getpaletteidx(color, palette_type)
|
||||
elseif color == "pink" then return 56,7
|
||||
elseif color == "blue" and shade == "light" then return 40,5
|
||||
elseif unifieddyes.gpidx_hues_wallmounted[color] and unifieddyes.gpidx_shades_wallmounted[shade] then
|
||||
return (unifieddyes.gpidx_shades_wallmounted[shade] * 64 + unifieddyes.gpidx_hues_wallmounted[color] * 8), unifieddyes.gpidx_hues_wallmounted[color]
|
||||
return (unifieddyes.gpidx_shades_wallmounted[shade] * 64 + unifieddyes.gpidx_hues_wallmounted[color] * 8),
|
||||
unifieddyes.gpidx_hues_wallmounted[color]
|
||||
end
|
||||
else
|
||||
if color == "brown" then
|
||||
@ -399,7 +398,8 @@ function unifieddyes.getpaletteidx(color, palette_type)
|
||||
end
|
||||
elseif palette_type == "extended" then
|
||||
if unifieddyes.gpidx_hues_extended[color] and unifieddyes.gpidx_shades_extended[shade] then
|
||||
return (unifieddyes.gpidx_hues_extended[color] + unifieddyes.gpidx_shades_extended[shade]*24), unifieddyes.gpidx_hues_extended[color]
|
||||
return (unifieddyes.gpidx_hues_extended[color] + unifieddyes.gpidx_shades_extended[shade]*24),
|
||||
unifieddyes.gpidx_hues_extended[color]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -91,24 +91,6 @@ for i = 1, 14 do
|
||||
end
|
||||
end
|
||||
|
||||
local default_dyes = {
|
||||
"black",
|
||||
"blue",
|
||||
"brown",
|
||||
"cyan",
|
||||
"dark_green",
|
||||
"dark_grey",
|
||||
"green",
|
||||
"grey",
|
||||
"magenta",
|
||||
"orange",
|
||||
"pink",
|
||||
"red",
|
||||
"violet",
|
||||
"white",
|
||||
"yellow"
|
||||
}
|
||||
|
||||
-- reverse lookups for getpaletteidx()
|
||||
|
||||
unifieddyes.gpidx_aliases = {
|
||||
|
@ -56,11 +56,11 @@ for _, h in ipairs(unifieddyes.HUES_EXTENDED) do
|
||||
local g3 = math.floor(p+(g2-p)*0.5)
|
||||
local b3 = math.floor(p+(b2-p)*0.5)
|
||||
|
||||
local color = string.format("%02x", r3)..string.format("%02x", g3)..string.format("%02x", b3)
|
||||
local ccolor = string.format("%02x", r3)..string.format("%02x", g3)..string.format("%02x", b3)
|
||||
|
||||
minetest.register_craftitem(":dye:"..val..hue.."_s50", {
|
||||
description = S(desc.." (low saturation)"),
|
||||
inventory_image = "unifieddyes_dye.png^[colorize:#"..color..":200",
|
||||
inventory_image = "unifieddyes_dye.png^[colorize:#"..ccolor..":200",
|
||||
groups = { dye=1, not_in_creative_inventory=1 },
|
||||
})
|
||||
minetest.register_alias("unifieddyes:"..val..hue.."_s50", "dye:"..val..hue.."_s50")
|
||||
|
3
init.lua
3
init.lua
@ -31,8 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
unifieddyes = {}
|
||||
|
||||
local creative_mode = minetest.settings:get_bool("creative_mode")
|
||||
|
||||
local S = minetest.get_translator("unifieddyes")
|
||||
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
@ -43,3 +41,4 @@ dofile(modpath.."/dyes-crafting.lua")
|
||||
dofile(modpath.."/aliases.lua")
|
||||
|
||||
print(S("[UnifiedDyes] Loaded!"))
|
||||
unifieddyes.init = true
|
Loading…
Reference in New Issue
Block a user