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

rednet error

Started by TR1T0N_, 14 December 2013 - 06:45 PM
TR1T0N_ #1
Posted 14 December 2013 - 07:45 PM
hello. im getting the error "rednet: 43: No open sides"
The code is for a firewall that i am using for my bank system.

realid = 5
function spoof(nID)
print("start spoof")
  local func = loadstring("return "..nID)
	os.getComputerID = func
  os.computerID = func
end
function unspoof()
print("end spoof")
  spoof(5)
end
--firewall start
rednet.open("top")
print("1")
while true do
var1, var2, var3 = rednet.receive()
print("id = "..var1)
print("msg = "..var2)
print("distance = "..var3)
print("2")
if var1 == 9  then
print("3")
rednet.open("back")
print("4")
spoof(var1)
print("5")
rednet.send(4, var2)
print("6")
else
rednet.send(var1, "deny")
print("7")
end
end
but for some reason it will not work and keeps giving me the same error and sorry for my horrible formatting. Any help would be much appreciated.
TheOddByte #2
Posted 14 December 2013 - 07:47 PM
You haven't opened a modem

rednet.open("<side>") -- back, front, left, right, top, bottom

Also, Why are you using loadstring? Here's an easier method

local getID = os.getComputerID -- Backing up the old function
os.getComputerID = function(nID) -- Overriding it
    return nID or getID() -- Returning the fake id or the regular computer ID
end
Edited on 14 December 2013 - 06:53 PM
TR1T0N_ #3
Posted 14 December 2013 - 07:50 PM
Both modems have been opened on lines 15 and 25.
TheOddByte #4
Posted 14 December 2013 - 08:03 PM
Oh, Lol.. Missed that xD
Try to just use one modem
Edited on 14 December 2013 - 07:03 PM
Bomb Bloke #5
Posted 14 December 2013 - 09:43 PM
If I'm not mistaken, shouldn't "os.computerID" be a number, not a function?

The rednet API isn't built for this sort of thing. Instead of jumping through all these hoops, you may be better off using the modem API directly - this simply hands you control over which channels to listen/send through, rather then trying to limit you to whatever your computer ID happens to be. And since the rednet API gets the modem API to do much of its work anyway, transmissions are compatible between the two.

Eg:

Spoiler
--firewall start
topModem = peripheral.wrap("top")
rearModem = peripheral.wrap("back")

topModem.open(5)  -- We need to actually choose a port to listen on, but it doesn't have to be our ID.
                  -- We can also open multiple ports at once if we so wish.
while true do
  event, side, targetPort, senderPort, message, distance = os.pullEvent("modem_message")  -- Notice we can detect which modem got the message, and on which port.
  print("id = "..senderPort)
  print("msg = "..message)
  print("distance = "..distance)

  if senderPort == 9  then
    rearModem.transmit(4, senderPort, message)
  else
    topModem.transmit(senderPort, targetPort, "deny")
  end
end
Edited on 14 December 2013 - 08:43 PM
Lyqyd #6
Posted 15 December 2013 - 03:13 AM
It's a function that returns a number, just like os.getComputerID.
theoriginalbit #7
Posted 15 December 2013 - 03:15 AM
Yeh stupid naming convention really. os.getComputerID === os.computerID and os.getComputerLabel === os.computerLabel
TR1T0N_ #8
Posted 15 December 2013 - 11:22 AM
Thanks for the help everyone it was the id spoofing causing the error. and i think it will need a bit of a rewrite using os.pullevent() as it is not very efficient at the moment.