Posted 05 December 2012 - 04:26 AM
Hello, I already know that my chat program works, and has no errors, but I do not like were I have to wait to send a message for someone to reply first, someone on a CC server I play said you needed to do something like.
os.pullEvent
and I admit, I am not the good with some Lua in CC, like os, but here's my chat programs code. All i really want to know is were to put it, and what to put, because Im not good with os. thanks.
function top()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.purple)
print("Welcome to Chatv")
term.setTextColor(colors.gray)
print("====================================================")
end
function detectDevice(DeviceName)
DeviceSide="none"
for k,v in pairs(redstone.getSides()) do
if peripheral.getType(v)==DeviceName then
DeviceSide = v
break
end
end
return(DeviceSide)
end
top()
ModemSide=detectDevice("modem")
rednet.open(ModemSide)
term.setTextColor(colors.green)
write("Username: ")
term.setTextColor(colors.white)
local user = read()
term.clear()
term.setCursorPos(1,1)
top()
while true do
term.setTextColor(colors.lime)
write("Message: ")
term.setTextColor(colors.white)
local a = read()
rednet.broadcast(user.. ": " ..a)
id, msg = rednet.receive()
print(id.. ": is sending a message")
print(msg)
end