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

Having a little truble

Started by Spongy141, 28 April 2012 - 11:16 PM
Spongy141 #1
Posted 29 April 2012 - 01:16 AM
So if you ever look at the Programs library you'll most likely know that I'm making a chat like program to chat world wide for server, or singer player (If you want to talk to yourself) but im trying to do allow the message to send, when im on single player testing if it works it says "bios:267: Attempt to write to global" i dont get it! here is my code

print("Welcome to Chatv.2")
rednet.open("back")
print("Please write your username so people now who you are below, dont worry you dont have to type your username everytime, :TIP: Put : after your username")
local NAME = read()
print("Alright")
print("Now what would you like to say?")
local message = read()
rednet.broadcast(NAME,message)
while true do
local message = read()
rednet.broadcast(NAME,message)
end
MysticT #2
Posted 29 April 2012 - 01:36 AM
Well, I don't know why you get that error, but it's not because of this program.
There's some problems with your code: it doesn't send the message, just the name you enter; and it doesn't receive messages, and it should since it's a chat program.
rednet.broadcast() takes only one parameter, the message:

rednet.broadcast("message")
giving more parameters to it won't do anything.
For receiving there's a couple of ways. You can use the parallel API to run the sender and receiver functions at the same time, or you can handle the events yourself instead of using read().
I made a chat progam, it's on the programs forum. Take a look at it if you want to see how it works.
Spongy141 #3
Posted 29 April 2012 - 01:44 AM
Well, I don't know why you get that error, but it's not because of this program.
There's some problems with your code: it doesn't send the message, just the name you enter; and it doesn't receive messages, and it should since it's a chat program.
rednet.broadcast() takes only one parameter, the message:

rednet.broadcast("message")
giving more parameters to it won't do anything.
For receiving there's a couple of ways. You can use the parallel API to run the sender and receiver functions at the same time, or you can handle the events yourself instead of using read().
I made a chat progam, it's on the programs forum. Take a look at it if you want to see how it works.
Ok thnx