I am currently working on a multiplayer game that uses the link cable to transfer data.

I want to make an error message display if the calculator isn't connected to another calculator. How could I do this?

Thanks.
you could use a timeout function? I think but I'm not sure calcnet does this?
How would I use a timeout function? Also by the way, the information that my program transfers currently is a list.
kpa4941 wrote:
I am currently working on a multiplayer game that uses the link cable to transfer data.

I want to make an error message display if the calculator isn't connected to another calculator. How could I do this?

Thanks.
Welcome to Cemetech! I am Christopher "Kerm Martian" Cemetech, administrator and head honcho. I hope you'll Introduce Yourself in the appropriate topic. Anyway, I haven't messed around with GetCalc() in a very long while, so I can't remember if the absence of another calculator causes the variable being fetched to not change, or if it issues an actual program-breaking error message. If the former, you could set some sentinel value in L[yours](1), then check that after the GetCalc() to see if something was fetched.
oh okay sorry about that. But let's see are you could use omnicalc.
0rac343 wrote:
oh okay sorry about that. But let's see are you could use omnicalc.
I'm not sure that Omnicalc's variable transfer function offers timeout detection.

Edit: I just confirmed on WabbitEmu that GetCalc() does indeed silently time out, so my sentinel idea would work! Would you like to see some code?
hmmmm Your right Kerm, Very Happy! haha but if you could post the code I'd like to see it as well. Very Happy
Sure, I would like to see the code. Sorry for not replying, I just got back from vacation.
kpa4941 wrote:
Sure, I would like to see the code. Sorry for not replying, I just got back from vacation.
Welcome back; I hope that your vacation was enjoyable and that you had a happy Thanksgiving (if you're from the USA). Here's the kind of code I was thinking of. This is from the "receiving" calculator, and assumes that if it is present, the sending calculator is being cooperative. This example uses a Real variable, but could be very easily adapted to lists, matrices, and even Pics.


Code:
:133742->X
//This is the sentinel value
//It should be something that is never
//a valid X value
:getCalc(X)
:If X=133742
:Then
://The transfer did not succeed
:Else
://The transfer succeeded
:End
Thanks for the Happy Thanksgiving, I had a great time with relatives. Also thanks for the code example. It is similar to what I am using right now. Basically, the game that I am making has a multiplayer option that will use the calculator link cable to transfer the data file that another user has on their calculator.

When the user first starts at the multiplayer menu, the program clears the custom list that is reserved for the multiplayer user's data. Basically it fills the list with a value of 0's. The XP element of my game's list is located at element 7.

So when the calculator attempts to use the getCalc method to retrieve the 2nd calculator's data, it checks to see whether the value of the multiplayer list is still 0. If the value is still 0, the program returns a "no calculator detected" message, while if the value isn't 0, the calculator displays the list and says "data received".

So far it is working, but I need to test it out with my friends calculator at school. Since I am new to using the getCalc method, I wasn't really sure whether this would work. What do you think? I haven't tried it out yet until Monday.
Quote:
Code:
:133742->X
//This is the sentinel value
//It should be something that is never
//a valid X value
:getCalc(X)
:If X=133742
:Then
://The transfer did not succeed
:Else
://The transfer succeeded
:End

ahh okay so thats how you do it.
That's exactly what I was thinking of. When you say it checks the "value of the multiplayer list", do you mean element 7 of that list? If so, this sounds like it would work.

Edit: @0rac343: Do you see why I did it that way? Makes sense?
Yep Thanks Kerm. I understand now. Never thought about doing it that way. haha
0rac343 wrote:
Yep Thanks Kerm. I understand now. Never thought about doing it that way. haha
No problem, glad I was able to impart some knowledge, and I'm glad to see the kpa4941 was thinking along similar lines.
Yep, element 7 of the list contains the value for Experience Points in my game, and when you first start the game, that value is changed to 64(Because you start off at level 5 instead of level 0).
kpa4941 wrote:
Yep, element 7 off the list contains the value for Experience Points in my game, and when you first start the game, that value is changed to 64(Because you start off at level 5 instead of level 0).
Gotcha, that makes perfect sense. I look forward to hearing the results from your testing.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement