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

OpenMods Advanced Sensor Turtle

Started by deathbyshe3p, 31 January 2015 - 02:50 AM
deathbyshe3p #1
Posted 31 January 2015 - 03:50 AM
Okay i have this Advanced Wireless Sensor Turtle that im going to (eventually) get to follow me a scan for nearby enemy player. Problem is that when i use this code.

rednet.open("right")

radar = peripheral.wrap("right")

while true do
user = radar.getPlayers()
if user ~= ("deathbysh33p") then
rednet.send(3,"Detected")
else
end

1.I see one problem is that since its following me it will always detect me which means it will always say there is noone near me.

2. It returns a table and for the life of me i cannot just get it to scan for usernames and use those instead of the table.

help?

I am playing on 1.7.10.
Cycomantis #2
Posted 31 January 2015 - 05:18 AM
I'm not familiar with OpenMods but if radar.getPlayers() returns a table you would want to check the results like this:


while true do
  tUsers = radar.getPlayers()
  for _,playerName in pairs(tUsers) do
	if playerName ~= "deathbysh33p" then
	  rednet.send(3,"Detected")
	end --do not need an else unless you want to do something if playerName == "deathbysh33p"
  end
end
Edited on 31 January 2015 - 04:19 AM
Dog #3
Posted 31 January 2015 - 06:14 AM
One thing I noticed is that you're opening the modem and wrapping the sensor on the same side ("right"). If the sensor is actually working, then the modem is on the left.
deathbyshe3p #4
Posted 31 January 2015 - 09:03 PM
Thank you guys for helping me i think i got the radar working lol