Jump to content




Rednet IDS


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

#1 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

Posted 11 December 2013 - 04:11 PM

I hope this doesn't sound malicious, but I need to fake an ID.
What I want to do is "change" my computers ID in a quick "chat program" I wrote.
Code of the fist computers startup:
os.getComputerId = function()
fakeId = 9
return fakeId
end
Chat program code:
First computer:
rednet.open("top")
local input = read()
rednet.send(1, input)
Second computer chat code:
while true do
id, message = rednet.receive()
print(id..":"..message)
end
But it just prints the real ID. Any help?

Edited by mrpoopy345, 11 December 2013 - 04:12 PM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 11 December 2013 - 04:37 PM

Capital D in getComputerID.

That said, you're trying to twist the rednet API to do something it just isn't intended to do... I recommend the modem API:

First computer:

modem = peripheral.wrap("top")
local input = read()
modem.transmit(1,9,input)

Second computer chat code:

modem = peripheral.wrap("top")
modem.open(1)
while true do
event, side, targetChannel, senderChannel, message, distanceTravelled = os.pullEvent("modem_message")
print(senderChannel..":"..message)
end

As you can see, the syntax is nearly the same - you just get a few more parameters back when retrieving the message, and get total control over which ports to send on and which to listen on. Plus it's fully compatible with rednet API transmissions, because the rednet API uses the modem API anyway.

#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 12 December 2013 - 10:14 AM

Here's a topic with the same question, There's a lot of useful answers there to if you want to check it out.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users