This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MayContainVennom's profile picture

Writing A Line A Code Within Another Code

Started by MayContainVennom, 23 July 2013 - 07:29 PM
MayContainVennom #1
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:
Spoiler–V.5
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.
Zudo #2
Posted 24 July 2013 - 01:20 AM
SpoilerI would put the function definitions before you call them.

Check the fs.open page
MayContainVennom #3
Posted 24 July 2013 - 12:51 PM
SpoilerI would put the function definitions before you call them.
Check the fs.open page


Yeah thats what I need thanks.