Posted 16 November 2014 - 09:22 PM
For some reason computer craft keeps giving me this error
testing:58: attempt to call string every time I try to run my Rednet chat program this is my code please tell me why I am getting this error and how I can fix it
Thank you so much
testing:58: attempt to call string every time I try to run my Rednet chat program this is my code please tell me why I am getting this error and how I can fix it
done = false
local function mainLoop()
while true do
if done then
break
end
sleep(.5)
end
end
local function clear(type)
if type == 0 then
term.clear()
term.setCursorPos(1, 1)
end
if type == 1 then
term.clear()
term.setCursorPos(1, 1)
print("Rednet Chat -- Created By Heirteir")
print("For A List Of Commands Type /help")
end
if type == 2 then
x,y = term.getCursorPos()
term.clearLine()
term.setCursorPos(x, y-1)
end
end
local function inputUsername()
clear(1)
term.write("Please enter your username: ")
return read()
end
local function openRednet()
for _,side in ipairs(rs.getSides()) do
if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
rednet.open(side)
return
end
end
clear(0)
print("No wireless modem found.")
print("Please install a wireless modem on any side of the computer")
sleep(2)
clear(0)
print("Closing...")
sleep(1)
clear(0)
done = true
end
local function starting()
openRednet()
end
name = inputUsername()
clear(1)
local function listen()
while true do
id, message = rednet.receive()
print(message)
sleep(.5)
end
end
function send()
while true do
local input = read()
if (string.sub(input, 1, 1)) == "/" then
clear(2)
command(input)
if done then
clear(0)
return
end
else
message = name .. " (" .. os.getComputerID() .. ") >> " .. input
clear(2)
print("You >> " .. input)
rednet.broadcast(message)
end
sleep(.5)
end
end
starting()
parallel.waitForAny(send, listen, mainLoop)
Thank you so much