This commit is contained in:
2025-09-29 00:03:57 -04:00
parent 5111182a4b
commit abd573f686
64 changed files with 2407 additions and 157 deletions

View File

@@ -0,0 +1,50 @@
-- Copyright (C) 2025 ASTRONAND
--local oldComponent = component
--_G.component={}
--local components={}
--local all={}
--local blacklisted={}
--
--function table.contains(tabl, query)
-- for i,v in ipairs(tabl) do
-- if v==query then
-- return true
-- end
-- end
-- return false
--end
--
--for i,v in oldComponent.list() do
-- if not components[i] then
-- components[i]={}
-- end
-- components[i][#components[i]+1]={typ=i,obj=v}
-- all[#all+1]={typ=i,obj=v}
--end
--
--function component.list(filter)
-- filter=filter or "all"
-- local filtered
-- if filter=="all" then
-- filtered=all
-- else
-- filtered=components[filter]
-- end
-- local i=0
-- return function()
-- while i<#filtered do
-- i=i+1
-- if not table.contains(blacklisted, v.typ) then
-- return v.typ, v.obj
-- end
-- end
-- end
--end
--
--function component.getSudo(key)
-- if key==masterKey then
-- return oldComponent
-- end
--end
--
--

View File

@@ -0,0 +1,53 @@
-- Copyright (C) 2025 ASTRONAND
function string.hasSuffix(str, suffix)
return string.sub(str, #suffix+1) == suffix
end
function string.hasPrefix(str, prefix)
return string.sub(str, 1, #prefix) == prefix
end
function string.getSuffix(str, prefix)
return string.sub(str, #prefix+1)
end
function string.getPrefix(str, suffix)
return string.sub(str, 1, #suffix)
end
function string.join(delim, ...)
return table.concat(table.pack(...), delim)
end
function string.split(str, delim, maxResultCountOrNil)
assert(#delim == 1, "only delim len 1 supported for now")
maxResultCountOrNil = (maxResultCountOrNil or 0)-1
local rv = {}
local buf = ""
for i = 1, #str do
local c = string.sub(str,i,i)
if #rv ~= maxResultCountOrNil and c == delim then
table.insert(rv, buf)
buf = ""
else
buf = buf..c
end
end
table.insert(rv, buf)
return rv
end
function string.replace(str, search, replacement)
local rv = ""
local consumedLen = 1
local i = 1
while i<#str do
if string.sub(str, i, i+#search-1) == search then
rv = rv .. string.sub(str, consumedLen, i-1) .. replacement
i=i+#search
consumedLen = i
end
i=i+1
end
return rv .. string.sub(str, consumedLen)
end

View File

@@ -0,0 +1,39 @@
-- Copyright (C) 2025 ASTRONAND
function table.deepcopy(orig, copies)
copies = copies or {}
if type(orig) ~= 'table' then
return orig
elseif copies[orig] then
return copies[orig]
end
local copy = {}
copies[orig] = copy
for k, v in next, orig, nil do
local copied_key = table.deepcopy(k, copies)
local copied_val = table.deepcopy(v, copies)
copy[copied_key] = copied_val
end
return copy
end
function table.hasKey(tabl, query)
for i,v in pairs(tabl) do
if i==query then
return true
end
end
return false
end
function table.hasVal(tabl, query)
for i,v in pairs(tabl) do
if v==query then
return true
end
end
return false
end