Posted 25 March 2015 - 10:54 PM
text = {"test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7"}
rednet.open("top")
function pass()
msg, id = rednet.receive()
if msg == "kittens" then
print("Hello!")
else
parallel.waitForAny(swag(),pass())
end
end
function swag()
mon.clear()
mon.setCursorPos(1,1)
mon.setBackgroundColor(colors.black)
mon.setTextColor(colors.lime)
mon.setTextScale(3)
for i = 1,5 do
mon.setCursorPos(1,i)
mon.write(text[i])
end
sleep(3)
for i = 2,6 do
mon.setCursorPos(1,i-1)
mon.write(text[i])
end
sleep(3)
end
mon = peripheral.wrap("back")
parallel.waitForAny(swag(),pass())
--Password program, in a another comp
rednet.open("top")
function password(pass)
term.clear()
term.setCursorPos(1,1)
term.write("Hello, this computer is locked by ")
term.setTextColor(colors.purple)
term.write("Apple")
term.setTextColor(colors.white)
term.write(".")
term.setCursorPos(1,2)
term.write("Please enter the password: ")
local input = read("*")
if input ~= pass then
term.setCursorPos(1,3)
term.setTextColor(colors.red)
term.write("WRONG!")
sleep(3)
password("theoneandonly")
else
term.setCursorPos(1,3)
term.setTextColor(colors.lime)
term.write("Welcome!")
rednet.broadcast("kittens")
end
end
password("theoneandonly")
Last I checked the parallel API was for making 2 or more things work at once, but from what I can tell it only makes 1 thing work at once and that 1 thing depends on whatever you put in first, for example, it's currently "parallel.waitForAny(swag(),pass())" and at the moment it'll run swag() and that only, but before I had pass() before it and it only ran pass(), how do I get both of these functions to work at the same time? It's for a server, and I don't want anyone terminating the program and messing with the computer, but at the same time I don't wanna use
os.getEvent = os.getEventRaw
to stop the terminating unless I have a reliable password program, in case I want to make changes to the program later,