line = "back"
ping = "front"
binary = ""
function wait()
while true do
timer = os.startTimer(1)
evt, timera = os.pullEvent("timer")
if timer==timera then
fr = "timer"
end
if timer==timera then break end
end
return
end
function redstone()
while true do
os.pullEvent("redstone")
if rs.getOutput(ping) then
if rs.getOutput(line) then
fr = "1"
else
fr = "0"
end
end
end
end
function send(filename)
file = fs.open(filename, "b")
while true do
a = file.read()
if not a then break end
binary = binary..a
end
for i = 1, #binary do
local c = binary:sub(i,i)
sleep(0)
if c=="1" then
rs.setOutput(line, true)
rs.setOutput(ping, true)
else
rs.setOutput(line, false)
rs.setOutput(ping, true)
end
end
end
function receive(filename)
while true do
parallel.waitForAny(wait, redstone)
if fr=="timer" then break end
binary = binary..fr
end
file = fs.open(filename, "wb")
file.write(binary)
file.close()
end
args = {...}
if args[1] == "-send" then
send(args[2])
else
receive(args[2])
end
it says test:27 unssoported mode
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Program doesnt send anything
Started by FuuuAInfiniteLoop(F.A.I.L), 31 March 2013 - 01:40 PMPosted 31 March 2013 - 03:40 PM
Posted 31 March 2013 - 03:44 PM
if can help, im using computercraft 1.52 in minecraft 1.5.1 with the last forge (7.7.1) and i have installed NEI, galacticraft and rei minimap on windows 8 x64
Posted 31 March 2013 - 03:44 PM
file = fs.open(filename, "rb")
Have a read
EDIT: Whoops, wrong link.
Posted 31 March 2013 - 03:49 PM
Now the code doesnt send anything, and the ping line is always turned on, even if the program is closed
Posted 31 March 2013 - 04:07 PM
what exactly is this program meant to be doing?
Posted 31 March 2013 - 06:54 PM
It would be easier to read this if you could space a little better, not trying to be rude, but it would help if you were to space this better, it would let us read your code better and help you faster.
Posted 31 March 2013 - 11:37 PM
Has does sleep(0) allow redstone to do anything… I told you this in IRC. It has to be (I believe) at least 0.2 seconds.
Posted 31 March 2013 - 11:39 PM
0.1 actually… thats a single tick, which is the fastest a rs signal can be on. So do you know, what is the purpose of this code? and why does it need to be open in binary mode?Has does sleep(0) allow redstone to do anything… I told you this in IRC. It has to be (I believe) at least 0.2 seconds.
Posted 31 March 2013 - 11:43 PM
0.1 actually… thats a single tick, which is the fastest a rs signal can be on. So do you know, what is the purpose of this code? and why does it need to be open in binary mode?Has does sleep(0) allow redstone to do anything… I told you this in IRC. It has to be (I believe) at least 0.2 seconds.
He's trying to send/receive a file through 2 redstone wires, through binary.
Also the reason why the ping line is always on is because you never then turn it off -_-/> Redstone outputs are not pulses, unless you make them pulses by alternating between setoutput true and setoutput false
Posted 31 March 2013 - 11:49 PM
Ahh i see… thanks…He's trying to send/receive a file through 2 redstone wires, through binary.
well… you will encounter a problem when attempting to write the string out to the file when it is opened in binary mode. you will need to get 8 pulses (bits) and then encode them into a byte and write it to the file. also how does it know when the file is finished copying across? You need to setup some kind of bit count at the start of the stream, or you need to setup some kind of terminating byte that is sent across so it knows when it is the end…