Make rednet functions throw an error if rednet isn't open.
#1
Posted 03 October 2012 - 11:05 PM
Errors are annoying, but at the same time, they're probably one of the best things in programming. They tell you exactly where and how you've screwed up. It would be monumentally helpful if the computers simply stopped the program and told you to open rednet, instead of doing nothing. It's like someone screaming at you constantly, without telling you why.
#2
Posted 03 October 2012 - 11:20 PM
#4
Posted 03 October 2012 - 11:33 PM
#5
Posted 03 October 2012 - 11:48 PM
#6
Posted 03 October 2012 - 11:54 PM
#7
Posted 04 October 2012 - 12:04 AM
Cloudy, on 03 October 2012 - 11:54 PM, said:
#8
Posted 04 October 2012 - 12:20 AM
Cloudy, on 03 October 2012 - 11:54 PM, said:
So instead of returning false, would it be possible to instead simply give an error?
In fact I could do some edits and make it so that it errors myself, just by storing the function as a local function and redefining the global one to error if the result of the stored local function is false.
#9
Posted 04 October 2012 - 01:48 AM
Cloudy, on 03 October 2012 - 11:54 PM, said:
Throwing the error could break existing programs though.
#10
Posted 04 October 2012 - 01:51 AM
I know you're not going for realism here, but that's just something I'd imagine a program would do - throw an error if there's no medium through which to send rednet signals.
#11
Posted 04 October 2012 - 01:55 AM
Kingdaro, on 04 October 2012 - 01:51 AM, said:
I know you're not going for realism here, but that's just something I'd imagine a program would do - throw an error if there's no medium through which to send rednet signals.
Actually, depending on the scenario, lots of communication systems send data regardless of connected media. They do throw an error though, when no data is coming back. (This is implemented in multiple layers of the ISO OSI model). You could go for that approach...
#12
Posted 04 October 2012 - 03:13 AM
#13
Posted 04 October 2012 - 11:25 AM
ElvishJerricco, on 04 October 2012 - 03:13 AM, said:
This is not really good comparison.
1. Chrome would throw an error if there is no network
2. Rednet IS reliable, there is always a network. Why would rednet opening/closing be unreliable?
#14
Posted 04 October 2012 - 02:21 PM
#15
Posted 04 October 2012 - 03:32 PM
Kingdaro, on 04 October 2012 - 12:20 AM, said:
So instead of returning false, would it be possible to instead simply give an error?
Use some assertion wrapping for yourself. No need to demand it for all.
#16
Posted 04 October 2012 - 09:41 PM
If you aren't familiar with it, there is an error command in the APIs somewhere. Using that, I have prepared a noob code fragment for you.
if not rednet.send(id, msg) then
if rednet.isOpen() then
print("ID or message Invaild")
else
error("No network detected")
end
else
print("Message Sent, awaiting response.")
end
And I just pressed control thinking I was typing in minecraft. >.<
#18
Posted 04 October 2012 - 10:50 PM
ardera, on 04 October 2012 - 02:21 PM, said:
Sebra, on 04 October 2012 - 03:32 PM, said:
Use some assertion wrapping for yourself. No need to demand it for all.
By the time I've already written checks to see if the modem is there, I can already see if it's there because I have eyes, so there would be no point in doing so.
Also, I'm not "demanding", I'm making a request, but with stronger wording. I've proved in a tumblr post that periods make sentences more serious than if they were without periods, sorry for the misconception.
#19
Posted 04 October 2012 - 10:58 PM
#20
Posted 04 October 2012 - 11:01 PM
Fatal_Exception, on 04 October 2012 - 10:58 PM, said:
Otherwise there shouldn't be a problem.
Or perhaps, if you, for some reason, wanted to send rednet signals without the modem open, you could just pass an argument like 1 to the function to prevent it from erroring?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


This topic is locked









