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

Rednet IDS

Started by mrpoopy345, 11 December 2013 - 03:11 PM
mrpoopy345 #1
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 on 11 December 2013 - 03:12 PM
Bomb Bloke #2
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.
TheOddByte #3
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.