Jump to content




Program doesnt send anything


  • You cannot reply to this topic
9 replies to this topic

#1 FuuuAInfiniteLoop(F.A.I.L)

  • Banned
  • 435 posts
  • LocationThe left part of this post

Posted 31 March 2013 - 02:40 PM

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

#2 FuuuAInfiniteLoop(F.A.I.L)

  • Banned
  • 435 posts
  • LocationThe left part of this post

Posted 31 March 2013 - 02: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

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 March 2013 - 02:44 PM

file = fs.open(filename, "rb")

Have a read http://lua-users.org...LibraryTutorial http://www.lua.org/pil/21.2.2.html

EDIT: Whoops, wrong link.

#4 FuuuAInfiniteLoop(F.A.I.L)

  • Banned
  • 435 posts
  • LocationThe left part of this post

Posted 31 March 2013 - 02:49 PM

Now the code doesnt send anything, and the ping line is always turned on, even if the program is closed

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 March 2013 - 03:07 PM

what exactly is this program meant to be doing?

#6 Spongy141

  • Members
  • 526 posts
  • Location'Merica

Posted 31 March 2013 - 05: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.

#7 1lann

  • Members
  • 516 posts
  • LocationSeattle

Posted 31 March 2013 - 10: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.

#8 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 March 2013 - 10:39 PM

View Post1lann, on 31 March 2013 - 10:37 PM, said:

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.
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?

#9 1lann

  • Members
  • 516 posts
  • LocationSeattle

Posted 31 March 2013 - 10:43 PM

View Posttheoriginalbit, on 31 March 2013 - 10:39 PM, said:

View Post1lann, on 31 March 2013 - 10:37 PM, said:

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.
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?

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

#10 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 March 2013 - 10:49 PM

View Post1lann, on 31 March 2013 - 10:43 PM, said:

He's trying to send/receive a file through 2 redstone wires, through binary.
Ahh i see... thanks...

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...





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users