Hey everyone!
Today I present a few simple functions for managing tables!
strtab()
local t=strtab[[ dark=false, red=lala, 5=32, kiss={ me,before,you,go } ]] |
a whitespace agnostic function for converting strings into tables. numbers and booleans are cast into their respective types. this lets you write tables out in a human readable way, making it a powerful tool for data-driven development. note that because it removes all white space, there is currently no way to include strings with white space.
tblcpy()
local t2=tblcpy(t,{ kiss={ please=don't } }) result: { dark=false, red=lala, 5=32, kiss={ me,before,you,go,please=don't } } |
this function (optionally) deep copies any table, and can optionally take another table as a parameter to overwrite values into it. combined with strtab(), this can form a simple yet powerful entity and inheritance system, which I am using in a current project.
tass()
print(tass(t2)) |
convert a table into a whitespace-formatted string. great for debugging!
rmchr()
str=rmchr("hyuck","h") result: "yuck" |
removes a character from a given string. this is primarily a helper function for strtab().
I hope these may be useful for you! happy pico-8'ing! 💖
[Please log in to post a comment]