Jump to content




Redstone and Rednet Server Using Files (Direwolf20 1.7)

help networking utility

3 replies to this topic

#1 QuiveringT

  • New Members
  • 2 posts

Posted 20 June 2016 - 01:43 AM

I am building a server that interprets redstone and rednet signal from two computers and
then returns a redstone/rednet signal to these computers. I am using Bundled Cables as
well as Wireless Redstone, but they are not directly necessary.

There are two files named 'initLeft' and 'initRight' in the server that are used to store the value of the redstone or rednet signal coming from the left or right computers respectively. For some reason the functions pertaining to the right side of the system writes the text 'true' into 'initRight' when being sent 'whiteon' or by typing the text directly into the file, and therefore produces the 'text sucks.' message. I need the file to have either 'whiteon' or 'whiteoff' written in it in order for the rest of the system to work and be read by the functions.

Note 1: This is intended to be running many more functions similar to these at all times, so I can control machines that are l located in my house, from a far away location (including different dimensions).

Note 2: This also functions as a file initialization system which counteracts the fact that computers turn off and forget their redstone signal when the Minecraft Server or singleplayer world is shutdown. This is essential to my build.

Thanks in advance.

Spoiler


Code for Left Computer
Spoiler

The code for the right computer is a simple rednet message sender, sending either 'whiteon' or 'whiteoff'.

Edited by QuiveringT, 20 June 2016 - 05:43 AM.


#2 Incinirate

  • Members
  • 216 posts
  • LocationDanktown, Memeland

Posted 20 June 2016 - 02:15 AM

Can you please post the code for the left/right computers. Also, put your code in spoilers please.
Do spoilers like so
[spoiler]
--Your Code Here
[/spoiler]


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 June 2016 - 07:40 AM

I still don't see any code here which sends the text "whiteon" via rednet.

Your receiveLeft() / setLeft() functions are going to end up writing to and checking "/initRight", as your receiveRight() / setRight() are assigning that value to an unlocalised "dir" variable. Take a look into scope.

There's no obvious reason not to merge your set functions into your receive functions. Sure, write to disk whenever redstone input changes; but don't bother reading it back unless the script has just restarted!

Your use of sleep(0) in your receive functions may prevent you from detecting all redstone state changes / rednet messages. Ditch it.

rs.getBundledOutput() only requires one argument, and ignores any extras you choose to add.

#4 QuiveringT

  • New Members
  • 2 posts

Posted 21 June 2016 - 06:40 AM

View PostBomb Bloke, on 20 June 2016 - 07:40 AM, said:

I still don't see any code here which sends the text "whiteon" via rednet.

Your receiveLeft() / setLeft() functions are going to end up writing to and checking "/initRight", as your receiveRight() / setRight() are assigning that value to an unlocalised "dir" variable. Take a look into scope.

There's no obvious reason not to merge your set functions into your receive functions. Sure, write to disk whenever redstone input changes; but don't bother reading it back unless the script has just restarted!

Your use of sleep(0) in your receive functions may prevent you from detecting all redstone state changes / rednet messages. Ditch it.

rs.getBundledOutput() only requires one argument, and ignores any extras you choose to add.

Turns out it was my unlocalised variables that were the issue. I've written a few CC programs but never had to use them before, thanks. I might have some more problems as I develop the system but I appreciate the help so far.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users