Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sPictureFolder = "valentines"
- t_heartFiles = { {fileName = "heartSmall", pastebin_url = "LTGTvHTU"}, {fileName = "heartMedium", pastebin_url = "mMtPd9Xc"}, {fileName = "heartBig", pastebin_url = "U81i0r34"}}
- nHeartAnimationDelay = 0.1
- screenX, screenY = term.getSize()
- start = false
- function centerW(text, yPos, col)
- term.setCursorPos(math.floor((screenX-#text)/2), yPos)
- term.setTextColour(col)
- write(text)
- term.setTextColour(colours.black)
- end
- function animateHearts()
- heartTimer = os.startTimer(nHeartAnimationDelay)
- for times = 1, 6 do
- term.clear()
- for i = 1, #t_heartFiles do
- heart = paintutils.loadImage(sPictureFolder .. "/" .. t_heartFiles[i].fileName)
- xPos = screenX/2 - (2^i)
- yPos = screenY/2 - (2*i-1)
- paintutils.drawImage(heart, xPos, yPos)
- repeat _, timer = os.pullEvent("timer") until timer == heartTimer
- heartTimer = os.startTimer(nHeartAnimationDelay)
- end
- end
- end
- function ask(method)
- term.clear()
- if method == "cart" then
- t_Options = { {text = "Yes", xPos = 14, colour = colours.yellow}, {text = "No", xPos = 34, colour = colours.red}}
- centerW(not start and "Are you in the cart?" or "Are you in the cart yet? :)", 3, colours.yellow)
- for i = 1, #t_Options do
- term.setCursorPos(t_Options[i].xPos, 5)
- term.setTextColour(t_Options[i].colour)
- write(t_Options[i].text)
- end
- while true do
- _, b, x, y = os.pullEvent("mouse_click")
- if b == 1 then -- left click
- for i = 1, #t_Options do
- if x >= t_Options[i].xPos and x < (t_Options[i].xPos + #t_Options[i].text) and y == 5 then
- return t_Options[i].text
- end
- end
- end
- end
- elseif method == "answer" then
- while true do
- centerW("What is the answer?", 5, colours.yellow)
- term.setCursorPos((screenX-4)/2, 6)
- term.setTextColour(colours.lightBlue)
- answer = read()
- if answer == "42" then -- For when it's correct
- term.clear()
- centerW("Yay!", 5, colours.red)
- rs.setOutput("right", true) -- this code triggers the redstone signal to the right of the computer
- while true do sleep(10) end
- else
- term.clear()
- centerW(":(", 5, colours.red) -- This will write each time he gets the answer wrong
- sleep(3)
- end
- end
- end
- end
- function download(sCode, sPath)
- local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode ) )
- if response then
- file = fs.open( sPath, "w" )
- file.write( response.readAll() )
- file.close()
- response.close()
- end
- end
- if not fs.isDir(sPictureFolder) then fs.makeDir(sPictureFolder) end
- for i = 1, #t_heartFiles do
- if not fs.exists(sPictureFolder .. "/" .. t_heartFiles[i].fileName) then
- download(t_heartFiles[i].pastebin_url, sPictureFolder .. "/" .. t_heartFiles[i].fileName)
- end
- end
- while true do
- option = ask("cart")
- if not start then start = not start end
- if option == "Yes" then
- animateHearts()
- ask("answer")
- break
- elseif option == "No" then
- term.clear()
- centerW("Ok :(", 4, colours.red)
- centerW("Please get in the", 5, colours.yellow)
- centerW("cart when you can :)", 6, colours.yellow)
- sleep(3)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment