Posted 08 June 2013 - 01:19 PM
Hey, im new to the CC forums and i just joined because im having some troubles making one of my scripts for LAN Chat using Modems.
I cannot make the script user to enter his own message, frequency and reply frequency…
It goes to the confirm message (Printing the choosen stuff) and for some reason when i get to the transmit code, i have the "Exected Number" Error…
I made a default message as a debug (You will be able to see in the script) to check it with the default variables given, without passing trough any change..
Here's the script:
(Pastebin: TJtkFXjX )
I cannot make the script user to enter his own message, frequency and reply frequency…
It goes to the confirm message (Printing the choosen stuff) and for some reason when i get to the transmit code, i have the "Exected Number" Error…
I made a default message as a debug (You will be able to see in the script) to check it with the default variables given, without passing trough any change..
Here's the script:
(Pastebin: TJtkFXjX )
--NOT TO COPY BELOW THIS
--Setting up
sides = {
"front",
"back",
"left",
"right",
"top",
"bottom"
}
function PrintCentered(text, y)
local w, h = term.getSize()
x = math.ceil(math.ceil((w / 2) - (#text / 2)), 0)+1
term.setCursorPos(x, y)
print(text)
end
function clearConsole()
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1,1)
end
function Terminate()
clearConsole()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
error("Terminated by Script")
end
--Done
local modem = peripheral.wrap('top')
--ONLY COPY BELOW THIS
--Default Variables
num1 = 1
num2 = 2
msg = Default
clearConsole()
write("Message: ")
local msg = read()
if msg == "default" then
clearConsole()
print("The message is: "..msg.." ")
print("It will be sent to the frequency: "..num1.." ")
print("The requested reply frequency is: "..num2.." ")
sleep(3)
clearConsole()
print("Sending the DEFAULT message..")
sleep(1)
modem.transmit(num1,num2,msg) -- Here its perfectly working.. With the default variables given above
clearConsole()
print("Sucefully sent the Default message. Terminating..")
sleep(2)
Terminate()
end
write("Send frequency: ")
local num1 = read()
write("Reply frequency: ")
local num2 = read()
print("The message is: "..msg.." ") -- All good in here
print("It will be sent to the frequency: "..num1.." ") -- All good in here too. It's an Int value
print("The requested reply frequency is: "..num2.." ") -- Int value too
sleep(2)
write("Write SEND to send this message: ")
local input = read()
if input == "SEND" then
clearConsole()
print("Sending the message..")
sleep(1)
modem.transmit(num1,num2,msg) -- Here, the same code, it's not working.. I cant make this to accept the read() function so i could change the frequency to whatever i want. Given error: Expected Number
else
print("Message canceled by the client.")
print("Terminating...")
sleep(2)
Terminate()
end
Edited by