Piznium source codes for versions/14-03-2022/175

-- Define variables code = {} -- The code Sent Lua will execute

-- TEMPORARY SECTION - get code code = { "main.main", "main.print.hi haha", } -- END TEMPORARY SECTION

logs = {} -- Some logs doing = 0 -- The current line we're doing status = 6 -- The status of the compilation

olr = {} -- One line ram ram = {} -- Many line ram i = 0 -- i, Index, used in loops installed = {} -- All installed modules currently

hasComment = false -- Whether the line we're doing has a comment module = "" -- The module of the given line command = "" -- The command of the given line params = {} -- The parameters of the given line

pizniumVersion = "Release 15/03/2022" pizzariaVer = ""

-- Configs which shouldn't really be changed but ok useStrictMode = false deleteIndents = true maxCodeLength = 10000

showLogs = true -- TEMPORARY - disable when actual usage showErrors = true showStatusOnEnd = true

-- Global UI element Configs (uiElems = user interface Elements), not used much, -- only for global things, not function things etc, contains 17 entries uiElems = { "Something logged: ", -- 1. showLogs begin text "Error at line ", -- 2. showErrors begin text ": \n ", -- 3. showErrors between/end text "Code is too long, max length is ", -- 4. maxCodeLength exceeded begin text ". Proceeding to not execute following code.", -- 5. maxCodeLength exceeded end text "A function returned: ", -- 6. Function returned begin text (TEMPORARY) "\n<< Process finished >>", -- 7. Process finished text "The module \"", -- 8. Module not found begin text "\" doesn't exist, but is called up.", -- 9. Module not found end text "The command \"", -- 10. Command not found begin text "\" doesn't exist, but is called up.", -- 11. Command not found end text "The parameter \"", -- 12. Parameter not found begin text "\" doesn't exist, but is called up.", -- 13. Parameter not found end text "The module \"", -- 14. Module not installed begin text "\" is not installed, so it can't be used.", -- 15. Module not installed end text "\" is not installed and doesn't even exist", -- 16. Module doesn't exist installed end text ", so it can't be used.", -- 17. Module doesn't exist installed end text section 2 } -- Word and character UI elements (mostly unused), contains 85 entries shortElems = {  "","","","","","","","","","","","","","","", -- fillers (REALLY TEMPORARY)  "well", -- 16. Well  "okay", -- 17. Okay  "ok", -- 18. no ay  "sorry, but", -- 19. Sorry but  "successful", -- 20. Successful  "successfully", -- 21. ly  "failed", -- 22. Failed  "failed to", -- 23. Failed to  "unknown", -- 24. Unknown something  "warning", -- 25. Warning  "error", -- 26. Error  "at", -- 27. At  "line", -- 28. Line  "-", -- 29. Dash  "in", -- 30. In  "on", -- 31. On  "the", -- 32. The  "a", -- 33. A  "W", -- 34. W (capitalization intentional)  "proceed", -- 35. Proceed  "proceeding", -- 36. ing  "done", -- 37. Done  "no", -- 38. No  "not", -- 39. t "yes", -- 40. Yes "correct", -- 41. Correct ".", -- 42. Full stop ",", -- 43. Comma "!", -- 44. Exclamation mark "?", -- 45. Question mark " - ", -- 46. Spaced dash ":", -- 47. Colon ";", -- 48. Semicolon "is", -- 49. Is "are", -- 50. Are "an", -- 51. An "have", -- 52. Have "had", -- 53. Had "has", -- 54. Has "'", -- 55. Apostrophe "\"", -- 56. Quotation "\\", -- 57. Backslash  "/", -- 58. Slash  "|", -- 59. Pipe  "&", -- 60. Ampersand  "*", -- 61. Asterisk  "=", -- 62. Equals  ">", -- 63. Greater than  "<", -- 64. Less than  "~", -- 65. Tilde  "`", -- 66. Grave  "_", -- 67. Underscore  "[", -- 68. Square bracket left (formatted string opener)  "nbsp", -- 69. nbsp  "can accept", -- 70. Can accept  "will decline", -- 71. Will decline  "garbage", -- 72. Garbage  "stop", -- 73. Stop  "out", -- 74. out  "of", -- 75. of  "just", -- 76. Just  "never ever", -- 77. never ever  "stupid", -- 78. Stupid  "collect", -- 79. Collect  "get", -- 80. Get  "", -- 81. Blank  "\n", -- 82. Newline  " ", -- 83. Space  "", -- 84. Empty parens  "-/-", -- 85. Dash slash dash (not actually used in {_dsd}) } -- Define modules modules = {  "sys",  "main",  "math",  "tt",  "time", }

-- Logging functions, replace, and basic arithmetics calculator function log(message) table.insert(logs,message) if showLogs then print(uiElems[1] .. message) end end

function error(message) table.insert(logs,message) if showErrors then print(uiElems[2] .. doing .. uiElems[3] .. message) end end

function replace(str,from,to) -- Basically string.gsub - same params, same usage, this exists because string.gsub is kinda a confusing name. noNumAfter = string.gsub(str,from,to) return noNumAfter end

function parseBasicArith(toparse) local tocalc = replace(toparse,"x","*") tocalc = replace(tocalc,"×","*") -- x and × is an alias of * tocalc = replace(tocalc,"÷","/") -- ÷ is an alias of / -- Below are text aliases tocalc = replace(tocalc,"plus","+") tocalc = replace(tocalc,"minus","-") tocalc = replace(tocalc,"multiply","*") tocalc = replace(tocalc,"divide","/") return load("return " .. tocalc) -- Do the actual calculation using load end

-- Generic table functions function tableLength(table) local count = 0 for i in pairs(table) do   count = count + 1 end return count end

codelen = tableLength(code) -- The length of the code given

if codelen > maxCodeLength then error(uiElems[4] .. maxCodeLength .. uiElems[5]) return end

function displayTable(table) for i in pairs(table) do     print(table[i]) end end

-- Prepare strict mode and delete indents if enabled if useStrictMode then -- Meh, nothing for now (TEMPORARY) end if deleteIndents then for i in pairs(code) do   code[i] = code[i]:gsub("%s*","") end end

-- Parameter tool functions function param(index) return params[index] -- TEMPORARY - need more checks here etc end

function getType(strtoget) return "str" -- TEMPORARY end

function paramType(index) -- TEMPORARY - more stuffs go here return getType(params[index]) end

-- Underscore variable definers, the bunnyface and bunny ones are a joke underscoreVars = { "dot", "dsd", "bunnyface", "bunny", } underscoreVarsHas = { ".", "-/-",  "🐰",  "🐇", }

function parseFormatStr(string) -- Parse formatted strings -- Includes both underscore vars and normal vars local parsing = string local doing = 1 repeat parsing = replace(parsing,"{_" .. underscoreVars[doing] .. "}",underscoreVarsHas[doing]) doing = doing + 1 until doing > tableLength(underscoreVars) return parsing end

-- Globally used generic but pretty useful functions function returns(returning) local hasreturned = tostring(returning) print(uiElems[6] .. hasreturned) -- TEMPORARY until we get a proper returning system end

function strSplit(inputstr,sep) local t = {} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do   table.insert(t, str) end return t end

function isAllSpaces(str) -- All spaces or blank local removedLength = string.len(string.gsub(str,"%s","")) if removedLength == 0 then return true else return false end end

-- Execute function function execFunc(module,command,params) if module == "piznium" then -- Piznium if command == "piznium" then -- Piznium returns("Piznium") elseif command == "pizzaria" then -- Pizzaria -- Note: Pizzaria is a planned plugin returns("Pizzaria") elseif command == "version" then -- Version returns(pizniumVersion) elseif command == "riaver" then -- RiaVer returns(pizzariaVer) end elseif module == "main" then -- Main if command == "main" then -- Main error("Unexpected main.main call.") elseif command == "print" then -- Print if paramType(1) == "str" then print(param(1)) elseif paramType(1) == "num" then print(tostring(param(1))) else error("Can only print string or number, got " .. paramType(1) .. ".") end end elseif module == "math" then -- Math if command == "ba" then -- BA   -- this is deprecated as it will be replaced by just putting in data no need for a function if paramType(1) == "str" then returns(parseBasicArith(param(1))) else error("Can only do maths on strings, but got " .. paramType(1) .. ".") end end elseif module == "tt" then -- Tt elseif module == "time" then -- Time else error(uiElems[8] .. module .. uiElems[9]) end end

repeat -- Increment the current line and is it a blank line or comment doing = doing + 1 if isAllSpaces(code[doing]) then hasComment = true log("Line " .. doing .. " is a blank line.") else hasComment = false

-- Get module, command, and params params = strSplit(code[doing],".") if params[1] == nil then module = "main" command = "main" else module = string.lower(params[1]) table.remove(params,1) if params[1] == nil then command = "main" else command = string.lower(params[1]) end table.remove(params,1) end -- Check if a module is requested to be installed or the given module is installed -- if module == "install" then --   table.insert(installed,command) --   return -- end -- if installed[module] == nil then --   error("Module " .. module .. " is not installed.") -- end -- TEMPORARY - IT DOESNT WORK YET -- Is it a coating -- TEMPORARY - NOT IMPLEMENTED YET

-- It is a function and we have everything properly set up for the function runner, so run it! execFunc(module,command,params) end until doing >= codelen

print(uiElems[7])