This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
luckystrike2021's profile picture

Help with wireless modems

Started by luckystrike2021, 29 July 2013 - 01:07 PM
luckystrike2021 #1
Posted 29 July 2013 - 03:07 PM
I'm having an issue using the wireless modems in 1.5 using channels.

here is my code: http://pastebin.com/a2Ld28zg

basically, everything works by sending a floor number to the elevator channel which is 10, each computer checks if the floor number is less than or equalto/greater than its own floor number. if its less than it activates the railcraft elevator track, otherwise it deactivates it.

everything works, except that when a computer receives a floor number that is directly above it, it will not send. it is not recognizing that 4 < 5 for example.
albrat #2
Posted 29 July 2013 - 07:14 PM
I am guessing you have a computer on every level that says "I'm floor #" so my guess would be that the floor and level are out of sync.. or change it to eg. 4 <= 5 (this might work or might not.)

Could you post the code for the floor computers. the ones that call the lift.

either that or it could be the >= on the next if statements… as it will always move the lift even if it matches the floor.

Think I just figured it out… The movement. if the lift is called on the same floor as it is on… it will move … Down.


		if destination < thisFloor then
				activaterail()
		elseif destination >= thisFloor then
				shutoffrail()
		end
because the code only has one floor matching choice. You need to add a line of if around the entire thing…

  if destination ~= thisFloor then
		if destination < thisFloor then
				activaterail()
		elseif destination > thisFloor then   -- removed the = from this
				shutoffrail()
		end
  end
from near the bottom…

		elseif event == "modem_message" then
			 if message ~= thisFloor then
				if message < thisFloor then
						activaterail()
				elseif message > thisFloor then  -- removed = also
						shutoffrail()
				end
			 end
		end

What this is doing is handling weather or not the lift is on the floor of the destination. If it matches the destination floor it stops moving.
Cozzimoto #3
Posted 29 July 2013 - 10:48 PM
when dealing with rednet i always have a computer with a giant monitor printing out to the screen the incoming channel, the reply channel and the msg over all the chanels you are using for the development stage of programs and rednet.

a sample would be

modem = peripheral.wrap(SIDE)

while true do
  local ev = { os.pullEvent("modem_message") }
  local incomingC = ev[3]
  local replyC = ev[4]
  local msg = ev[5]

  print("incoming: "..incomingC)
  print("reply to: "..replyC)
  print("data: "..msg)
end

i use something like this always when im dealing with rednet stuff so i can see what is being sent to what channel