Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/lua
- --[[
- Credit to the following people on the IRC room:
- Kodos
- NotLyra
- Sandra
- As well as the following tools:
- Pastebin
- I would not be able to make this program without them. I,
- Ekoserin, am a Lua noob and I'm proud!
- I'm a Lua noob and I'm proud!
- I'm a Lua noob and I'm proud!
- --]]
- local component = require("component") -- We need components.
- local computer = require("computer") -- We need the computer, obviously.
- local text = require("text") -- We need text displaying.
- local unicode = require("unicode") -- To display text, we need Unicode.
- local term = require("term") -- We need "term" commands.
- local pin = "1234" -- The PIN is this number.
- if not component.isAvailable("gpu") then -- If GPU is not available, return.
- return
- end
- local lines = {_OSVERSION .. " (" .. math.floor(computer.totalMemory() / 1024) .. "k RAM)"}
- local maxWidth = unicode.len(lines[1])
- local f = io.open("/usr/misc/greetings2.txt") -- Open greetings2.txt
- if f then
- local greetings = {}
- pcall(function()
- for line in f:lines() do table.insert(greetings, line) end
- end)
- f:close()
- local greeting = greetings[math.random(1, #greetings)]
- if greeting then
- local width = math.max(10, component.gpu.getResolution())
- for line in text.wrappedLines(greeting, width - 4, width - 4) do
- table.insert(lines, line)
- maxWidth = math.max(maxWidth, unicode.len(line))
- end
- end
- end
- ::pin_enter::
- print("Please enter the correct PIN to unlock door.") -- Display text.
- local inputvar = text.trim(term.read())
- if inputvar == pin then -- If input is equal to the PIN, goto "correct"
- goto correct
- else
- print("Incorrect.") -- Display text.
- goto pin_enter -- Goto "pin_enter"
- end
- ::correct::
- print("Correct.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement