Posted 23 July 2013 - 09:29 PM
Hello guys,
I am writing a code that will allow me and four other people and me to add a message to a computer screen simply by typing it into the chat( Using the misc peripheral Chat Box). I have this code working just that when the server is restarted we loose all the messages on the screen). The only way I can see is if we save all the message to file within that code and have it read it again from that file. I can't find any documentation on this but some post on here that I tried but to no effect. if there is any other solutions or if you could help me do this I would be grateful.
The code:
cb = peripheral.wrap("top")
m = peripheral.wrap("left")
m.setBackgroundColour(colours.black)
m.setTextScale(2)
m.setTextColour(colours.white)
m.clear()
pos = 0
function main()
a, b, c = os.pullEvent("chat")
if b == "MayContainVennom" or b == "Omnibare" or b == "DuckDastardly" or b == "reeceurnot" then
cb.say("Tell me what you want to be added "..b,10)
stepTwo()
else
main()
end
end
function stepTwo()
if string.find(c,"(add)") ~= nil then
printing()
else
main()
end
end
function printing()
d, e, f = os.pullEvent("chat")
if e == b then
pos = pos+1
m.setCursorPos(1,pos)
m.write(pos..". "..f)
main()
else
printing()
end
end
Thanks
Vennom.
I am writing a code that will allow me and four other people and me to add a message to a computer screen simply by typing it into the chat( Using the misc peripheral Chat Box). I have this code working just that when the server is restarted we loose all the messages on the screen). The only way I can see is if we save all the message to file within that code and have it read it again from that file. I can't find any documentation on this but some post on here that I tried but to no effect. if there is any other solutions or if you could help me do this I would be grateful.
The code:
Spoiler
–V.5cb = peripheral.wrap("top")
m = peripheral.wrap("left")
m.setBackgroundColour(colours.black)
m.setTextScale(2)
m.setTextColour(colours.white)
m.clear()
pos = 0
function main()
a, b, c = os.pullEvent("chat")
if b == "MayContainVennom" or b == "Omnibare" or b == "DuckDastardly" or b == "reeceurnot" then
cb.say("Tell me what you want to be added "..b,10)
stepTwo()
else
main()
end
end
function stepTwo()
if string.find(c,"(add)") ~= nil then
printing()
else
main()
end
end
function printing()
d, e, f = os.pullEvent("chat")
if e == b then
pos = pos+1
m.setCursorPos(1,pos)
m.write(pos..". "..f)
main()
else
printing()
end
end
Thanks
Vennom.