Posted 16 April 2017 - 06:51 AM
So, i have a password door lock, i have clients and server. Im trying to make the server print a log.
I have tried many many many different things, and i just cant seem to work out why. If you have an easier way of doing it, please share :)/>
It is printing
Log: 0
————————-
And blank for the rest of the page.
Code is as follows
I have tried many many many different things, and i just cant seem to work out why. If you have an easier way of doing it, please share :)/>
It is printing
Log: 0
————————-
And blank for the rest of the page.
Code is as follows
term.clear()
term.setCursorPos(1,1)
printer = peripheral.wrap("right")
ready = true
log = 0
lines = 0
active = false
function newLine (line)
local x, y = printer.getCursorPos()
printer.setCursorPos(x,lines+1)
printer.write(line)
lines = lines + 1
if lines == 21 then
printPage()
end
end
function newPrint ()
printer.newPage()
printer.setCursorPos(1,1)
printer.setPageTitle("Password Server 1")
printer.write("Log: " ..log)
printer.setCursorPos(1,2)
printer.write("-------------------------")
lines = lines + 2
ready = false
active = true
end
function printPage ()
printer.endPage()
log = log + 1
lines = 0
active = false
ready = true
end
print("Password Server 1")
rednet.open("top")
while true do
local sender, pass = rednet.receive()
if ready then
newPrint()
end
if pass == "w1ll" then
print("[" ..sender.. "] Got code: 0.")
rednet.send(sender,"0")
if active then
write = "["..sender.."] Got code: 0."
newLine(write)
end
else
print("[" ..sender.. "] Got code: 1.")
rednet.send(sender,"1")
if active then
write = "["..sender.."] Got code: 1."
newLine(write)
end
end
end
Edited on 16 April 2017 - 04:54 AM