Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local compX, compY = 51, 19
- local page = 1
- -- Tables
- local buttons = {}
- -- Design Code
- function centered(str, height)
- term.setCursorPos(x / 2 - #str / 2, height)
- term.write(str)
- end
- function indented(str, indent, height)
- term.setCursorPos(indent, height)
- term.write(str)
- end
- function left(str, height)
- term.setCursorPos(1, height)
- term.write(str)
- end
- function right(str, height)
- term.setCursorPos(compX - #str, height)
- term.write(str)
- end
- function clearLine(colour, height)
- term.setCursorPos(1, height)
- term.setBackgroundColour(colours[colour])
- term.clearLine()
- end
- function drawBorder(xMin, yMin, xMax, yMax, colour)
- paintutils.drawBox(xMin, yMin, xMax, yMax, colours[colour])
- end
- function drawBox(xMin, yMin, xMax, yMax, colour)
- paintutils.drawFilledBox(xMin, yMin, xMax, yMax, colours[colour])
- end
- function enableButton(buttonName)
- for k,v in pairs(buttons) do
- if v["buttonName"] == buttonName then
- buttons[k]["Enabled"] = true
- return true
- end
- end
- return false
- end
- function disableButton(buttonName)
- for k,v in pairs(buttons) do
- if v["buttonName"] == buttonName then
- buttons[k]["Enabled"] = false
- return true
- end
- end
- return false
- end
- function buttonNameToNumber(buttonName)
- for k,v in pairs(buttons) do
- if v["buttonName"] == buttonName then
- return k
- end
- end
- return false
- end
- function removeButton(buttonName)
- table.remove(buttons, buttonNameToNumber(buttonName))
- end
- function drawButton(xPos,yPos,bgColor,txtColor,length,txt,buttonName,functionName)
- term.setBackgroundColour(colours[bgColor])
- term.setTextColour(colours[txtColor])
- local X = xPos + math.floor((length/2)-(string.len(txt)/2))
- if not buttonName then
- buttonName = "Test"..tostring(#buttons+1)
- end
- for i = yPos,yPos+2 do
- if i ~= yPos+1 then
- term.setCursorPos(xPos,i)
- term.write(string.rep(" ", length))
- else
- term.setCursorPos(xPos,i)
- term.write(string.rep(" ", length))
- term.setCursorPos(X,i)
- buttons[#buttons+1] = {["Function"] = functionName, ["buttonName"] = buttonName, ["xPosStart"] = xPos, ["xPosStop"] = xPos+length-1, ["yPos"] = yPos, ["Enabled"] = true}
- term.write(txt)
- end
- end
- end
- -- Main Code
- function header()
- term.setTextColour(colours.white)
- clearLine("blue", 1)
- clearLine("blue", 2)
- clearLine("blue", 3)
- indented("smigger.22", 2, 2)
- right("My blog! ", 2)
- end
- -- Computer Code
- function checkButtonClick()
- while true do
- event, button, xPos, yPos = os.pullEvent("mouse_click")
- if event == "mouse_click" then
- for k,v in pairs(buttons) do
- if xPos >= v["xPosStart"] and xPos <= v["xPosStop"] and yPos >= v["yPos"] and yPos <= v["yPos"]+2 and v["Enabled"] == true then
- if v["Function"] then
- if v["Function"] == "info" and page == 1 then
- page = 2
- pageLayout()
- elseif v["Function"] == "exit" and page == 1 then
- return
- elseif v["Function"] == "contact" and page == 1 then
- page = 3
- pageLayout()
- elseif v["Function"] == "otherWeb" and page == 1 then
- page = 4
- pageLayout()
- elseif v["Function"] == "backAbout" and page == 2 then
- page = 1
- pageLayout()
- elseif v["Function"] == "backContact" and page == 3 then
- page = 1
- pageLayout()
- elseif v["Function"] == "backWebsites" and page == 4 then
- page = 1
- pageLayout()
- end
- end
- end
- end
- end
- end
- end
- function pageLayout()
- term.setBackgroundColour(colours.cyan)
- term.clear()
- header()
- if page == 1 then
- term.setBackgroundColour(colours.cyan)
- drawButton(3, 5, "blue", "lightBlue", 10, "About me", "info", "info")
- drawButton(14, 5, "blue", "lightBlue", 9, "Contact", "contact", "contact")
- drawButton(24, 5, "blue", "lightBlue", 16, "Other Websites", "otherWeb", "otherWeb")
- drawButton(3, 12, "blue", "lightBlue", 6, "Exit", "exit", "exit")
- checkButtonClick()
- elseif page == 2 then
- term.setBackgroundColour(colours.cyan)
- left("I am a video gamer and a blogger as you can see.", 6)
- left("Currently, I am working in a company called EpicCo, ", 7)
- left("a company that designs games and software that all", 8)
- left("can use with ease. I also help with the development", 9)
- left("of the offical LuaLand website, created by me and ", 10)
- left("robbiesymonds.", 11)
- drawButton(43, 12, "blue", "lightBlue", 6, "Back", "backAbout", "backAbout")
- checkButtonClick()
- elseif page == 3 then
- term.setBackgroundColour(colours.cyan)
- left("You can contact me in various ways. The easiest way", 6)
- left("would be to message me or tweet to me on Twitter!", 7)
- left("Twitter: www.twitter.com/smigger22", 9)
- left("Youtube: www.youtube.com/smigger22", 10)
- left("Instagram: www.instagram.com/smigger22", 11)
- left("Email: ryans810@hotmail.co.uk", 12)
- drawButton(43, 12, "blue", "lightBlue", 6, "Back", "backContact", "backContact")
- checkButtonClick()
- elseif page == 4 then
- term.setBackgroundColour(colours.cyan)
- left("Here are some cool websites, all hosted by CWC, a", 6)
- left("Great hosting company with 90% uptime!", 7)
- left("rod.net thepiratebay.se machine.net wiggle.it", 9)
- left("CWC.com quest.dia green.com wagon.com", 10)
- left("MicroCorp.net.cc", 11)
- drawButton(43, 12, "blue", "lightBlue", 6, "Back", "backWebsites", "backWebsites")
- checkButtonClick()
- end
- end
- function begin()
- parallel.waitForAll(pageLayout, checkButtonClick)
- end
- -- Start
- term.clear()
- begin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement