Jump to content




Problem| Rednet, send redstone pulses via masseges


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

#1 alontraitel

  • New Members
  • 6 posts

Posted 20 December 2012 - 11:10 PM

hello :D
i have a problem in my CC creataion
i'm trying to send a redstone pulse via rednet, frim some reason it dosn't work..
here is my coeds:

sender:
Posted Image

and the if command goes on from 0 to 9.


receiver:
Posted Image


the problem is in the receiver, it doesn't reconize the input.
in the sender i see no problem..

plz help me :D

#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 20 December 2012 - 11:57 PM

rednet.receive() needs returns 3 values, senderID, message and distance. Change it to:
senderID, number = rednet.receive()


#3 alontraitel

  • New Members
  • 6 posts

Posted 21 December 2012 - 12:07 AM

ok, but i dont know the ID of my sender, how can i get it ?

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 December 2012 - 12:10 AM

snip. sorry read it wrong.

Edit: Will it always be the same computer? or different ones?

#5 alontraitel

  • New Members
  • 6 posts

Posted 21 December 2012 - 12:13 AM

i have a main computer that send numbers to 9 computers that send a redstone signal.
in the main computer i enter the number and then i need that the computer with the number i entered will send a redstone pulse..
for exmple: if i enter in the main computer the number 5 then the fifth computer will send a redstone pulse :D

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 December 2012 - 12:14 AM

ok so the computer number that you enter for the signal to send to, is it the computer id or is it just a number you have given to it?

#7 alontraitel

  • New Members
  • 6 posts

Posted 21 December 2012 - 12:17 AM

it is just a number i have given to it, i have no idea what is the IDs of the computers because i have more comuters machines beside this creation .

#8 JoshhT

  • New Members
  • 64 posts
  • LocationAustralia

Posted 21 December 2012 - 12:18 AM

Here's what you need, just the very bare and basics of it.
Obviously you still need to open the rednet signal and all that jazz.

Sender code.
while true do
  local x = read()

  rednet.broadcast(x)
  sleep(2)
end

Receiver code.
while true do
  local sender, msg = rednet.receive()

  if msg == "4" then
    rs.setOutput("back", true)
    sleep(5)
    rs.setOutput("back", false)
  end
  sleep(1)
end


#9 JoshhT

  • New Members
  • 64 posts
  • LocationAustralia

Posted 21 December 2012 - 12:19 AM

Or you could go one better, and actually send a message to individual computers, instead of just broadcasting?

#10 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 December 2012 - 12:22 AM

View PostJoshhT, on 21 December 2012 - 12:19 AM, said:

Or you could go one better, and actually send a message to individual computers, instead of just broadcasting?

To do this he would need to know their id, which means he would need to broadcast a request message, analyse the response and then store their ids in a table, then look at the table later to send it back. Or he could just use the simple broadcast you suggested if it wont effect any other builds :)

#11 alontraitel

  • New Members
  • 6 posts

Posted 21 December 2012 - 12:25 AM

View PostJoshhT, on 21 December 2012 - 12:18 AM, said:

Here's what you need, just the very bare and basics of it.
Obviously you still need to open the rednet signal and all that jazz.

Sender code.
while true do
  local x = read()

  rednet.broadcast(x)
  sleep(2)
end

Receiver code.
while true do
  local sender, msg = rednet.receive()

  if msg == "4" then
	rs.setOutput("back", true)
	sleep(5)
	rs.setOutput("back", false)
  end
  sleep(1)
end


thank you very very very much !!!
it work LOL :D

#12 JoshhT

  • New Members
  • 64 posts
  • LocationAustralia

Posted 21 December 2012 - 12:30 AM

Here's a simple little thing I put together, to further explain my second suggestion.
With this code, it will only send the message to one specific computer you want, but you still only have to type in numbers 1 - 9 or whatever.
OP should use this if broadcasting interferes with other programs.

--Sender code.
local comps = { 4, 7, 11, 12, 13, 16, 19, 20 }

local x = read()

rednet.send(comps[x], "pulse bitch")

--Receiver code.
local senderID, msg = rednet.receive()

if msg == "pulse bitch" then
  rs.setOutput("back", true)
  sleep(5)
  rs.setOutput("back", false)
end


#13 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 December 2012 - 12:32 AM

View PostJoshhT, on 21 December 2012 - 12:30 AM, said:

Here's a simple little thing I put together, to further explain my second suggestion.
With this code, it will only send the message to one specific computer you want, but you still only have to type in numbers 1 - 9 or whatever.
OP should use this if broadcasting interferes with other programs.

--Sender code.
local comps = { 4, 7, 11, 12, 13, 16, 19, 20 }

local x = read()

rednet.send(comps[x], "pulse bitch")

--Receiver code.
local senderID, msg = rednet.receive()

if msg == "pulse bitch" then
  rs.setOutput("back", true)
  sleep(5)
  rs.setOutput("back", false)
end

the receiver code at the very least should be in a while true do loop.

#14 JoshhT

  • New Members
  • 64 posts
  • LocationAustralia

Posted 21 December 2012 - 12:36 AM

View PostTheOriginalBIT, on 21 December 2012 - 12:32 AM, said:

the receiver code at the very least should be in a while true do loop.

Yes well of course. I just couldn't be bothered typing it out. Hahha.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users