68 lines
2.6 KiB
Lua
68 lines
2.6 KiB
Lua
--os.pullEvent = os.pullEventRaw
|
|
local stratumDBlib = require("stratumDBlib")
|
|
local meshnetBackend = require("meshnetBackend")
|
|
meshnetBackend.setTarget(10)
|
|
stratumDBlib.setBackend(meshnetBackend)
|
|
print("connecting to database...")
|
|
local trans = stratumDBlib.loadTransforms("transforms","stratumDBlib")
|
|
|
|
local greeting = "Welcome to Caden's Smithy!"
|
|
local instruction = "Please state your name to make an order:"
|
|
local instruction2 = "Now please type out a request for your order."
|
|
local pressanykey = "Press any key to continue."
|
|
local lastchance1 = "Are you sure you want to put in an order?"
|
|
local lastchance2 = "Press the enter key to continue."
|
|
local lastchance3 = "Hold ctrl+r (or cmd+r on macos) to cancel"
|
|
local ordersubmitted1 = "Your order has been submitted!"
|
|
while true do
|
|
local dx,dy = term.getSize()
|
|
term.setBackgroundColor(colors.gray)
|
|
term.clear()
|
|
term.setCursorPos(dx/2-#greeting/2,dy/2-3)
|
|
term.write(greeting)
|
|
term.setCursorPos(dx/2-#instruction/2,dy/2-2)
|
|
term.write(instruction)
|
|
term.setBackgroundColor(colors.lightGray)
|
|
term.setCursorPos(1,dy/2+1)
|
|
term.clearLine()
|
|
term.setBackgroundColor(colors.lightGray)
|
|
term.setCursorPos(1,dy/2-1)
|
|
term.clearLine()
|
|
term.setCursorPos(1,dy/2)
|
|
term.setBackgroundColor(colors.black)
|
|
term.clearLine()
|
|
local name = read()
|
|
if name ~= "" then
|
|
term.setBackgroundColor(colors.gray)
|
|
term.clear()
|
|
term.setCursorPos(dx/2-#instruction2/2,dy/2)
|
|
term.write(instruction2)
|
|
term.setCursorPos(dx/2-#pressanykey/2,dy/2+1)
|
|
term.write(pressanykey)
|
|
os.pullEvent("key")
|
|
local request = loadfile("orderedit.lua","t",_ENV)()
|
|
if request:gsub("[\n ]","") ~= "" then
|
|
term.setBackgroundColor(colors.gray)
|
|
term.clear()
|
|
term.setCursorPos(dx/2-#lastchance1/2,dy/2)
|
|
term.write(lastchance1)
|
|
term.setCursorPos(dx/2-#pressanykey/2,dy/2+1)
|
|
term.write(pressanykey)
|
|
term.setCursorPos(dx/2-#lastchance3/2,dy/2+2)
|
|
term.write(lastchance3)
|
|
term.setCursorBlink(false)
|
|
local _,key
|
|
repeat
|
|
_,key = os.pullEvent("key")
|
|
until key == keys.enter
|
|
trans.addOrder(name,request)
|
|
term.setBackgroundColor(colors.gray)
|
|
term.clear()
|
|
term.setCursorPos(dx/2-#ordersubmitted1/2,dy/2)
|
|
term.write(ordersubmitted1)
|
|
term.setCursorPos(dx/2-#pressanykey/2,dy/2+1)
|
|
term.write(pressanykey)
|
|
os.pullEvent("key")
|
|
end
|
|
end
|
|
end |