[LUA][Question]Making 2 PC's read/write from same path?
Started by remiX, Oct 09 2012 06:29 PM
7 replies to this topic
#1
Posted 09 October 2012 - 06:29 PM
I'm using two computers to control a 'garage' door for my multiplayer server but they are reading and writing to their own ID folders. So when I open the door from the outside computer, it will update and make the status open whilst the computer inside will still have the closed status.
So how to I make both of these computers read and write to the same designated path?
So how to I make both of these computers read and write to the same designated path?
#2
Posted 09 October 2012 - 06:32 PM
You can't, without some rednet file teleportation magic. The easier solution is to simply have whichever computer just opened or shut the door tell the other one what it just did (via rednet) and for that computer to update its file accordingly.
#3
Posted 09 October 2012 - 06:44 PM
Lyqyd, on 09 October 2012 - 06:32 PM, said:
You can't, without some rednet file teleportation magic. The easier solution is to simply have whichever computer just opened or shut the door tell the other one what it just did (via rednet) and for that computer to update its file accordingly.
Damn. that just sucks :S
I've never used rednet before. How would I go about using rednet? Would I make it that if I recieve a signal from which ever side, it would change the status of the door to the opposite? hmm seems easy?
#4
Posted 09 October 2012 - 06:49 PM
sidekick_, on 09 October 2012 - 06:44 PM, said:
Lyqyd, on 09 October 2012 - 06:32 PM, said:
You can't, without some rednet file teleportation magic. The easier solution is to simply have whichever computer just opened or shut the door tell the other one what it just did (via rednet) and for that computer to update its file accordingly.
Damn. that just sucks :S
Is this why you've been trying to write to the rom? Really, a simple rednet file server with an fs/io API modification can get you the single-path read-write functionality you're looking for. LyqydNet has this, though you may wish to implement your own.
Edit: To reply to your edit, you might want to check out the rednet tutorials in the tutorials section of the forums. All you really need is send an "open" or "closed" signal and receive it on the other end. If the computers are close enough, you could even send these through bundled cable or plain redstone, though not as rednet signals in the case of plain redstone.
#5
Posted 09 October 2012 - 08:10 PM
You could use the HTTP api and make the pc's check for changes and then download it, or use rednet
#6
Posted 09 October 2012 - 08:23 PM
There is, in fact, a simpler solution. Since I assume both machines are feeding into the same redstone line (please correct me if I'm wrong), you could always just have them both watch for the redstone to fire, then update that way. Of course, if there are any repeaters in the way, then you will need to make a two-way repeater, which is neither fun nor easy, but can be done.
#7
Posted 10 October 2012 - 12:31 PM
Lyqyd, on 09 October 2012 - 06:49 PM, said:
sidekick_, on 09 October 2012 - 06:44 PM, said:
Lyqyd, on 09 October 2012 - 06:32 PM, said:
You can't, without some rednet file teleportation magic. The easier solution is to simply have whichever computer just opened or shut the door tell the other one what it just did (via rednet) and for that computer to update its file accordingly.
Damn. that just sucks :S
Is this why you've been trying to write to the rom? Really, a simple rednet file server with an fs/io API modification can get you the single-path read-write functionality you're looking for. LyqydNet has this, though you may wish to implement your own.
Edit: To reply to your edit, you might want to check out the rednet tutorials in the tutorials section of the forums. All you really need is send an "open" or "closed" signal and receive it on the other end. If the computers are close enough, you could even send these through bundled cable or plain redstone, though not as rednet signals in the case of plain redstone.
Yeah, thats the reason I've been trying to write to rom this whole time. I actually did use a code that uses simple plain redstone but I had come to a stop because of a problem: Obviously both PC's run off the same program, but this program requires you to enter a password which pauses the whole code (if im not correct? well thats where my problem comes in). When it asks for the user to supply a password it pauses it until the correct password is correct? I made mine do this:
while true do
if rs.getInput("right") then
UpdateStatus()
print("Attempting to update status")
sleep(5)
else
if fs.exists(sRoot.."SFGarageDoorStatus") then
file = fs.open(sRoot.."SFGarageDoorStatus.txt", "r")
if file then
sDoorStatus = file.readLine()
file.close()
print("Read status: "..sDoorStatus)
else
print("Failed to read status")
end
else
fs.makeDir(".savedVars")
end
CheckStatus()
end
end
Where is it has
print("Attempting to update status") I used this to check if it works when getting a signal and it does but when I destroy that signal from it then goes into the part where it needs a password and when I give it a signal again it does nothing because it requires a password. And the computers have only a block of space inbetween them.I'm going to learn about rednet and all that stuff. Could I maybe take a look at your LyqydNet code? So I have some idea of how to put it all together.
Snakybo, on 09 October 2012 - 08:10 PM, said:
You could use the HTTP api and make the pc's check for changes and then download it, or use rednet
I might also use my server for just LAN where no internet connection is available.
OmegaVest, on 09 October 2012 - 08:23 PM, said:
There is, in fact, a simpler solution. Since I assume both machines are feeding into the same redstone line (please correct me if I'm wrong), you could always just have them both watch for the redstone to fire, then update that way. Of course, if there are any repeaters in the way, then you will need to make a two-way repeater, which is neither fun nor easy, but can be done.
Yeah, they're feeding into the same redstone line to the door. Like I said to Lyqyd, I have a problem with the updating when getting a redstone signal.
#8
Posted 10 October 2012 - 07:42 PM
ROM = Read Only Memory, and good luck writing to that... just saying xD
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











