This commit is contained in:
2026-04-06 22:00:40 -07:00
commit cdc2d3200e
5 changed files with 373 additions and 0 deletions

54
startup.lua Normal file
View File

@@ -0,0 +1,54 @@
-- Source - https://stackoverflow.com/a/1579673
-- Posted by Faisal Hanif, modified by community. See post 'Timeline' for change history
-- Retrieved 2026-04-05, License - CC BY-SA 3.0
---splits a string by a pattern
---@param pString string
---@param pPattern string
---@return string[]
local function split(pString, pPattern)
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end
local printer = peripheral.find("printer")
if not printer then error("no printer found") end
printer.getSize = printer.getPageSize
local stratumDBlib = require("stratumDBlib")
local meshnetBackend = require("meshnetBackend")
meshnetBackend.setTarget(10)
stratumDBlib.setBackend(meshnetBackend)
print("connecting to database...")
local trans = stratumDBlib.loadTransforms("transforms","stratumDBlib")
while true do
print("Press any key to print the first in queue order")
os.pullEvent("key")
local name,request = trans.removeOrder(1)
if name then
if not printer.newPage() then error("failed to create a page") end
print("Name:",name)
printer.setPageTitle("Order From "..name)
print("Request:",request)
setfenv(write,setmetatable({term = printer},{__index=_ENV}))(request)
setfenv(write,_ENV)
printer.endPage()
print("printed page!")
else
print("no orders in queue")
end
end