Jump to content


oberjarlerak9039's Content

There have been 2 items by oberjarlerak9039 (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#32063 [Question] Using ccSensors for tracking players in SMP

Posted by oberjarlerak9039 on 15 September 2012 - 06:25 PM in Ask a Pro

I have a SSP only version that also stops in SMP

for the computer with controller:
--load APIs
os.unloadAPI("sensors")
os.loadAPI("rom/apis/sensors")
-- wireless
rednet.open("top")
--declare constants
scontrol = sensors.getController()
print("Attaching Sensor Controller on "..scontrol.." side")
avSensors = sensors.getSensors(scontrol)
    --get sensors
sUseSensor = avSensors[1]
avProbes = sensors.getProbes(scontrol, sUseSensor)
    --get probes
sPlayer = avProbes[4]
-- end --
   
while true do
for i,val in ipairs(sensors.getAvailableTargetsforProbe(scontrol,sUseSensor,"LivingEntities")) do
what,x,y,z=string.match(val,"([a-z]+),(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)")
x,y,z=tonumber(x),tonumber(y),tonumber(z)
if (what=="vq") then
rednet.broadcast(""..x..","..y..","..z)
end
end
sleep(0.1)
end
the sleeping is neccesary or it will overload if in a loop

for console on right side of monitor(s):
rednet.open("top")
mon = peripheral.wrap("left")
while true do
a,b,c = rednet.receive()
x = 0
y = 0
z = 0
for d, e, f in string.gmatch(b, "(%w+),(%w+),(%w+)")do
x = d
y = e
z = f
end
mon.setCursorPos(1,1)
mon.clear()
mon.write("x: "..x)
mon.setCursorPos(1,2)
mon.write("y: "..y)
mon.setCursorPos(1,3)
mon.write("z: "..z)
end
i also used part of 11lol's code so thanks to him



#32055 [Question] Using ccSensors for tracking players in SMP

Posted by oberjarlerak9039 on 15 September 2012 - 04:05 PM in Ask a Pro

Hi, in the past i've used getReading2(), which requires more parameters and it might work, but i have little experience with this mod

in the api it says

function getReading2(side,sensor,probe,target,...)
result = {peripheral.call( side, "getSensorReading2",sensor,probe,target,...)}
return tabtodict(result)
end