Add some insanity

This commit is contained in:
jordan4ibanez 2023-11-06 16:27:58 -05:00
parent 75123743d6
commit 6101aa9800
7 changed files with 118 additions and 15 deletions

View File

@ -1991,10 +1991,6 @@ function t.key_value_swap(_: table): table end
function t.shuffle(_: table, _: number, _: number, _: function): table end
-- This isn't cheating.
-- The rest of this is Forgotten Lands global definitions.
global function println(...: any) print(...) end
global function switch(input: any, ...: any | function(any): any): any print(input, ...) end

View File

@ -1,4 +1,4 @@
print("Pixel Perfection loaded.
Creator: Sofar
Maintainers: Sofar & TacoTexMex
Copyright: CC-BY-SA-4.0")
print("Pixel Perfection loaded." ..
"Creator: Sofar" ..
"Maintainers: Sofar & TacoTexMex" ..
"Copyright: CC-BY-SA-4.0")

View File

@ -1,4 +1,4 @@
print("Pixel Perfection loaded.
Creator: Sofar
Maintainers: Sofar & TacoTexMex
Copyright: CC-BY-SA-4.0")
print("Pixel Perfection loaded." ..
"Creator: Sofar" ..
"Maintainers: Sofar & TacoTexMex" ..
"Copyright: CC-BY-SA-4.0")

View File

@ -0,0 +1,4 @@
name = Pixel Perfection
description = The Pixel Perfection texture pack.
depends =
optional_depends =

49
mods/utility/init.lua Normal file
View File

@ -0,0 +1,49 @@
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs
function println(...) end
function switch(input, ...)
local tableized = { ... }
for k, v in ipairs(tableized) do
if ((k + 1) % 2 == 0) then
if (input == v or v == "else") then
local foundType = type(tableized[k + 1])
if (foundType == "function") then
return (tableized[k + 1])(input)
else
return tableized[k + 1]
end
end
end
end
end
local switch = switch
function println(...)
local builder = ""
for _, val in ipairs({ ... }) do
builder = builder .. switch(type(val),
"string", val,
"number", function() return tostring(val) end,
"table", function() return dump(val) end,
"userdata", function()
local thing = val
if (thing:is_player()) then return thing:get_player_name() end
return thing.name
end,
"else", function(input) print(input); return "" end)
end
print(builder)
end
minetest.register_globalstep(function(_delta)
local blah = minetest.get_player_by_name("singleplayer")
println("hi there\n",
"this is a test\n",
"of the thing\n", 1234, "\n", blah, "\n", { "test", 123, test = "hi" })
end)

54
mods/utility/init.tl Normal file
View File

@ -0,0 +1,54 @@
global function println(...: any) end
global function switch(input: any, ...: any | function(any): any): any
local tableized = {...}
for k,v in ipairs(tableized) do
if ((k + 1) % 2 == 0) then
if (input == v or v == "else") then
local foundType = type(tableized[k + 1])
if (foundType == "function") then
return (tableized[k + 1] as function)(input)
else
return tableized[k + 1]
end
end
end
end
end
local switch = switch
global function println(...: any)
local builder: string = ""
for _,val in ipairs({...}) do
builder = builder .. switch(type(val),
"string", val,
"number", function(): string return tostring(val) end,
"table", function(): string return dump(val) end,
"userdata", function(): string
local thing = val as ObjectRef
if (thing:is_player()) then return thing:get_player_name() end
return thing.name
end,
"else", function(input: any): string print("failure:",input) return "" end
) as string
end
print(builder)
end
-- minetest.register_globalstep(function(_delta: number)
-- local blah: ObjectRef = minetest.get_player_by_name("singleplayer")
-- println(
-- "hi there\n",
-- "this is a test\n",
-- "of the thing\n",
-- 1234, "\n",
-- blah, "\n",
-- {"test", 123, test = "hi"}
-- )
-- end)

0
mods/utility/mod.conf Normal file
View File