61 posts
Location
Pontefract, West Yorkshire, England
Posted 17 March 2012 - 10:58 AM
This is my code so far for my beta
print("Starting CraftOs Server Program By Alex_")
rednet.open("right")
while true do
from,message = rednet.recieve
if message=="admin" then
print("username admin Logged")
rednet.broadcast("accept")
elseif message=="guest" then
print("Guest Logged")
rednet.broadcast("accept")
else
rednet.broadcast("er1")
end
end
after some loops i get the error
rednet:369: Too long without yielding
Can someone help me fix this because i don't understand this.
411 posts
Posted 17 March 2012 - 11:08 AM
If you dont yield a program every 10 seconds it will throw that error, your could simply do sleep(.1) and it would prevent the error (inside the loop of course)
724 posts
Posted 17 March 2012 - 04:34 PM
No, no. He tryes to get rednet message:
from,message = rednet.recieve
but it should have timeout like
from,message = rednet.recieve(1)
this chould solve problem without sleep
38 posts
Posted 19 March 2012 - 06:11 PM
Wouldn't he be better served to use…
while true do
local event, sender, message = os.pullEvent()
if event == "rednet_message" then
--Do what ever you needed...
end
--Probably want a break condition to... but hey... :|
end
This way his program is waiting on an event rather than just thread spinning.
378 posts
Location
In the TARDIS
Posted 19 March 2012 - 06:23 PM
print("Starting CraftOs Server Program By Alex_")
rednet.open("right")
while true do
sleep(0)
from,message = rednet.recieve
if message=="admin" then
print("username admin Logged")
rednet.broadcast("accept")
elseif message=="guest" then
print("Guest Logged")
rednet.broadcast("accept")
else
rednet.broadcast("er1")
end
end
That worked for me. Just added the sleep(0)
715 posts
Posted 19 March 2012 - 08:24 PM
print("Starting CraftOs Server Program By Alex_")
rednet.open("right")
while true do
sleep(0)
from,message = rednet.recieve
if message=="admin" then
print("username admin Logged")
rednet.broadcast("accept")
elseif message=="guest" then
print("Guest Logged")
rednet.broadcast("accept")
else
rednet.broadcast("er1")
end
end
That worked for me. Just added the sleep(0)
I highly doubt that it has worked for you with the code you posted here, because there is no
rednet.recieve and there are no brackets at the end of the function call. :D/>/>
378 posts
Location
In the TARDIS
Posted 19 March 2012 - 11:04 PM
print("Starting CraftOs Server Program By Alex_")
rednet.open("right")
while true do
sleep(0)
from,message = rednet.recieve
if message=="admin" then
print("username admin Logged")
rednet.broadcast("accept")
elseif message=="guest" then
print("Guest Logged")
rednet.broadcast("accept")
else
rednet.broadcast("er1")
end
end
That worked for me. Just added the sleep(0)
I highly doubt that it has worked for you with the code you posted here, because there is no
rednet.recieve and there are no brackets at the end of the function call. :D/>/>
Lol yeah I wrote it by hand in my PC and copied it here in the thread :)/>/>