From 224e58577f3662277a484456f57c1ae0a7f5016f Mon Sep 17 00:00:00 2001 From: Seven Of Aces Date: Tue, 10 Dec 2024 16:51:04 -0800 Subject: [PATCH 1/2] added lua tools to flake --- flake.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flake.nix b/flake.nix index 19ad15f..031da23 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,6 @@ { # Tooling file for Nix and NixOS to get a quick start + # Run 'nix develop' to enter the development shell description = "pending"; inputs = { @@ -15,6 +16,11 @@ buildInputs = [ # Run CI/CD actions locally pkgs.act + # Lua 5.1 development tools + lua51Packages.lua + lua51Packages.luarocks + lua51Packages.busted + lua51Packages.luacheck ]; shellHook = '' alias run_workflows='act -W $PWD/.forgejo/workflows -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest --pull=false' From 19fab12455aa9463e34420065d56c9b708efdb00 Mon Sep 17 00:00:00 2001 From: Seven Of Aces Date: Tue, 10 Dec 2024 17:03:00 -0800 Subject: [PATCH 2/2] fixes :3 --- .vscode/settings.json | 3 ++ mods/BLOCKS/overworld/init.lua | 6 ---- mods/CORE/colors/init.lua | 60 ++++++++++++++++++---------------- mods/CORE/vox_main/init.lua | 2 +- mods/HUD/inventory/init.lua | 6 ++-- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1438e4f..592016b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,8 @@ "modname", "modpath", "Voxelis" + ], + "Lua.diagnostics.globals": [ + "vox_colors" ] } \ No newline at end of file diff --git a/mods/BLOCKS/overworld/init.lua b/mods/BLOCKS/overworld/init.lua index 219caf1..ce968ab 100644 --- a/mods/BLOCKS/overworld/init.lua +++ b/mods/BLOCKS/overworld/init.lua @@ -11,9 +11,3 @@ -- with this program; if not, see . --------------------------------------------------------------------------- -core.register_node("vox:grass", { - description = "Grass", - tiles = {"vox_grass.png"}, - groups = {cracky = 3} -}) -core.register_alias("grass", "vox:grass") diff --git a/mods/CORE/colors/init.lua b/mods/CORE/colors/init.lua index 8acf17e..c8a8c16 100644 --- a/mods/CORE/colors/init.lua +++ b/mods/CORE/colors/init.lua @@ -11,8 +11,6 @@ -- with this program; if not, see . --------------------------------------------------------------------------- -vox_colors_bg_brightness = 0.8; - vox_colors = { WHITE = "#FFFFFF", LIGHTGREY = "#D3D3D3", @@ -46,53 +44,57 @@ vox_colors = { FLAMINGO = "#FC8EAC", } -function vox_colors.bg(color) { - return vox_colors_multiplier(color, vox_colors_bg_brightness); -} +vox_colors.bg_brightness = 0.8; + +function vox_colors.bg(color) + return vox_colors.multiplier(color, vox_colors.bg_brightness); +end -- Validate that the provided color string is a valid hex color -function vox_colors.validate(color) { - if (color == nil) { +function vox_colors.validate(color) + if color == nil then return false; - } + end -- Hex colors should always be a length of 7 (1 pound, 6 hex) - if (string.len(color) != 7) { + if string.len(color) ~= 7 then return false; - } + end -- Ensure first character is a pound - if (string.sub(color, 1, 1) != "#") { + if string.sub(color, 1, 1) ~= "#" then return false; - } + end -- Ensure that RR, GG, and BB are valid hex fields - if (string.match(string.sub(color, 2, 3), "[0-9A-Fa-f]") == nil) { + if (string.match(string.sub(color, 2, 3), "[0-9A-Fa-f]") == nil) then return false; - } + end return true; -} +end --- Extract color information from the color and return a { red: Number, green: Number, blue: Number } table -function vox_colors.extract_channels(color) { - return { - red: tonumber(string.sub(color, 2, 3), 16), - green: tonumber(string.sub(color, 4, 5), 16), - blue: tonumber(string.sub(color, 6, 7), 16) - }; -} +-- Extract color information from the color and return a [ Number, Number, Number ] array +function vox_colors.extract_channels(color) + local result = {}; -function vox_colors.from_channels(red, green, blue) { + result[0] = tonumber(string.sub(color, 2, 3), 16); + result[1] = tonumber(string.sub(color, 4, 5), 16); + result[2] = tonumber(string.sub(color, 6, 7), 16); + + return result; +end + +function vox_colors.from_channels(red, green, blue) return "#" .. string.format("%02X", red) .. string.format("%02X", green) .. string.format("%02X", blue); -} +end -- Multiply the color by a percentage -function vox_colors.multiplier(color, percentage) { - local channels = vox_colors_extract_channels(color); - return vox_colors_from_channels( +function vox_colors.multiplier(color, percentage) + local channels = vox_colors.extract_channels(color); + return vox_colors.from_channels( math.floor(channels.red * percentage), math.floor(channels.green * percentage), math.floor(channels.blue * percentage) ); -} \ No newline at end of file +end \ No newline at end of file diff --git a/mods/CORE/vox_main/init.lua b/mods/CORE/vox_main/init.lua index 0b5abeb..313a80d 100644 --- a/mods/CORE/vox_main/init.lua +++ b/mods/CORE/vox_main/init.lua @@ -15,7 +15,7 @@ core.register_node("vox_main:grass", { description = "Grass", - tiles = {"vox_main_grass.png"}, + tiles = {"vox_grass.png"}, groups = {cracky = 3} }) core.register_alias("grass", "vox_main:grass") diff --git a/mods/HUD/inventory/init.lua b/mods/HUD/inventory/init.lua index bf49497..8652ec3 100644 --- a/mods/HUD/inventory/init.lua +++ b/mods/HUD/inventory/init.lua @@ -11,8 +11,6 @@ -- with this program; if not, see . --------------------------------------------------------------------------- -vox_inventory {} - -- Includes dofile(core.get_modpath(core.get_current_modname()) .. "/survival.lua") @@ -26,7 +24,7 @@ function core.creative_enabled_for(name) if player then return player:get_meta():get_string("gamemode") == "creative" end - core.log(["warning"], "core.creative_enabled_for: player not found: " .. name) + core.log("warning", "core.creative_enabled_for: player not found: " .. name) return false end @@ -36,6 +34,6 @@ function core.survival_enabled_for(name) if player then return player:get_meta():get_string("gamemode") == "survival" end - core.log(["warning"], "core.survival_enabled_for: player not found: " .. name) + core.log("warning", "core.survival_enabled_for: player not found: " .. name) return false end \ No newline at end of file