Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- function fullLimitWrite(text,limit)
- term.write(#text < limit+1 and text..(string.rep(" ",limit-#text)) or string.sub(text,1,limit-3).."...")
- end
- function dualPull(...)
- local args={...}
- repeat
- local event = {os.pullEvent()}
- for i,v in pairs(args) do
- if event[1] == v then
- return event[1],event[2],event[3],event[4],event[5],event[6]
- end
- end
- until false
- end
- function continue(text,ypos)
- local maxx,maxy = term.getSize()
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if x >= math.ceil((maxx/2)-(#text/2)) and x < (math.ceil((maxx/2)-(#text/2)) + #text) and y == ypos then
- break
- end
- end
- end
- local function centerWrite(text,setY)
- local x,y = term.getSize()
- term.setCursorPos(math.ceil((x / 2) - (#text / 2)), setY)
- write(text)
- end
- local success = os.loadAPI("itemData")
- local items = (success and itemData.data) or {}
- local curItem = 1
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.red)
- centerWrite("Crimson Co. Terminal",1)
- term.setTextColor(colors.black)
- centerWrite("Crimson Co. is a company dedicated",4)
- centerWrite("to bringing you the finest and cheapest goods",5)
- centerWrite("for all your essential needs.",6)
- term.setBackgroundColor(colors.lightGray)
- centerWrite("Continue to Browser",16)
- continue("Continue to Browser",16)
- local info = window.create(term.native(),13,1,39,19)
- while true do
- local timr = os.startTimer()
- term.setBackgroundColor(colors.white)
- term.clear()
- paintutils.drawLine(12,1,12,19,colors.black)
- term.setBackgroundColor(colors.white)
- for i=-9,9 do
- term.setCursorPos(1,10+i)
- if items[curItem+i] then
- fullLimitWrite(items[curItem+i].name,11)
- end
- end
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(1,10)
- fullLimitWrite(items[curItem].name)
- term.redirect(info)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear()
- centerWrite("Name",1)
- centerWrite(items[curItem].name,2)
- centerWrite("Price",5)
- centerWrite(items[curItem].price,6)
- centerWrite("Location",9)
- centerWrite(items[curItem].location,10)
- centerWrite("Info",13)
- centerWrite(items[curItem].info,14)
- term.redirect(term.native())
- local event, button, x, y = dualPull("mouse_click","mouse_scroll","timer")
- if event == "mouse_click" then
- if x < 13 and (curItem - (10 - y)) < #items and (curItem - (10 - y)) > 0 then
- curItem = (curItem - (10 - y))
- end
- if x == 51 and y == 1 then
- break
- end
- elseif event == "mouse_scroll" then
- curItem = curItem + button
- if curItem <=0 then
- curItem = #items
- elseif curItem > #items then
- curItem = 1
- end
- sleep(0) -- Stops scroll wheel from going down/up 3 times
- elseif event == "timer" and button == timr then
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement