Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Turtle-side Shop App
- local w,h=term.getSize()
- function receiveAll()
- id,sumChar,prot=rednet.receive("shop")
- id,cartItemsSerial,prot=rednet.receive("shop")
- end
- function processPackage()
- sum=tonumber(sumChar)
- cartItems=textutils.unserialize(cartItemsSerial)
- end
- function writeSum()
- term.setCursorPos(26,1)
- term.setTextColor(colors.red)
- term.write(" ")
- term.setCursorPos(26,1)
- term.write(sum)
- end
- function rednetGetInfo()
- rednet.open("left")
- receiveAll()
- processPackage()
- rednet.close("left")
- end
- function checkPayment()
- turtle.select(4)
- turtle.suck()
- turtle.select(1)
- if turtle.compareTo(4)==true then
- turtle.drop()
- end
- turtle.select(4)
- turtle.drop()
- turtle.select(1)
- end
- function buttonCheck()
- while true do
- local event,button,x,y=os.pullEvent("mouse_click")
- if ((x>=(w-8) and x<=(w)) and y==1) then
- checkPayment()
- break
- end
- if ((x>=(w-8) and x<=(w)) and y==3) then
- break
- end
- end
- end
- function terminalSetup()
- term.clear()
- term.setTextColor(colors.lightBlue)
- term.setCursorPos(1,1)
- term.write("Your Total Amount Due is: ")
- term.setCursorPos(w-8,1)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lime)
- term.write(" SUBMIT ")
- term.setCursorPos(w-8,3)
- term.setBackgroundColor(colors.red)
- term.write(" CANCEL ")
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,3)
- term.setTextColor(colors.white)
- term.write("Place payment in the top-left ")
- term.setCursorPos(1,4)
- term.write("slot of the turtle. Then click")
- term.setCursorPos(1,5)
- term.write("either SUBMIT or CANCEL to tell")
- term.setCursorPos(1,6)
- term.write("the turtle to proceed to it's ")
- term.setCursorPos(1,7)
- term.write("item gathering and payment pro-")
- term.setCursorPos(1,8)
- term.write("cessing. Please be patient.")
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.gray)
- for i=1,w do
- term.setCursorPos(i,2)
- term.write("-")
- end
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,9)
- end
- terminalSetup()
- while true do
- rednetGetInfo()
- writeSum()
- buttonCheck()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement