Hi together,
I wrote sth that should work. I think you can make it nicer and maybe more accurate but i hope this helps you to get the clue.
In this code i suggest that you get the Coordinates based on a radius around the turtle like (5,-10,0)
Used some random numbers for testing on CCEmu cause im not at home :)/>
w,h = term.getSize()
diameter = 56 -- set this to radius*2
mw = w/diameter -- get the multiplier for wide
mh = h/diameter -- get the multiplier for high
centerw = w/2
centerh = h/2
term.clear()
local function drawposition(mobx, mobz,symbol)
mapx = math.floor(centerw+1 - math.floor(mobx*mw))
mapz = math.floor(centerh+1 - math.floor(mobz*mh))
term.setCursorPos( mapx, mapz )
term.write(symbol)
term.setCursorPos( centerw+1, centerh+1 ) --this can be deleted was just annoyed of the curser ending up somewhere stupid so i put him where the sensor would be :D/>/>/>
end
for i = 1,10 do
x = math.random(-28,28) --replace with "v.Position.X"
z = math.random(-28,28) --replace with "v.Position.Z"
drawposition(x, z,"0") --last parameter is the symbol that should be printed
end
Since you were so helpful, I thought I'd share the final product. This runs on any advanced computer/monitor. As described, it scans the area and displays the targets on the monitor with their names displayed. They appear is relation to the sensor location, which does work out to be just about center screen regardless of monitor stretch. I hope you find it useful and I'm certain there can be much extrapolation to this for folks down the road.
Enjoy and Thanks!
————————-
os.loadAPI("/ocs/apis/sensor")
sside = "bottom"
mside = "right"
moni = peripheral.wrap(mside)
moni.clear()
moni.setTextScale(.5)
moni.setBackgroundColor(colors.lime)
moni.setTextColor(colors.red)
w,h = moni.getSize()
diameter = 56 – set this to radius*2
mw = w/diameter – get the multiplier for wide
mh = h/diameter – get the multiplier for high
centerw = w/2
centerh = h/2
proximity = sensor.wrap(sside)
term.clear()
term.setCursorPos(1,1)
print("Scanning targets …")
local function drawposition(mobx, mobz,symbol,name)
mapx = math.floor(centerw+1 - math.floor(mobx*mw))
mapz = math.floor(centerh+1 - math.floor(mobz*mh))
moni.setTextColor(colors.red)
moni.setCursorPos( mapx, mapz )
moni.write(symbol)
moni.setTextColor(colors.black)
moni.setCursorPos(mapx,mapz-1)
moni.write(name)
moni.setCursorPos( centerw+1, centerh+1 ) –Sensor location
end
while true do
moni.clear()
targets = proximity.getTargets()
for k,v in pairs(targets) do
x = v.Position.X
z = v.Position.Z
name = v.Name
drawposition(x, z,"X",name) –last two parameters are the symbol that should be printed and above it the target name
os.sleep(.25)
end
end