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

Help plotting entity positions using OCS

Started by ZagKalidor, 18 June 2013 - 11:04 AM
ZagKalidor #1
Posted 18 June 2013 - 01:04 PM
Hello friends,

i really would like to get back to the core of this question, because it's (roughly-alike) the problem in my case, it just has another reason. I'm permanently actualising the screen output and the screen "flickers" due to term.clear() or term.clearLine(). I brought the data of the OCS-Proximity-Sensor to the screen, based on the Targets x- and z position. The Name of the Targets are shown. The Screen is cleared and the Targets are shown again at (maybe) their new position.

Expressed simplified:

while loop
within a "for - in pairs - do" loop
targets are shown on x, z, based on (target.Position.X), (target.Position.Z)
end
screen is cleared
end

How do I have to manage my "Output", without the need of cleaning the whole screen or the targets line. Maybe I just don't know how to put the targets into an object and then show object - clear object ??!!??
When the for loop ends and runs a new pass, x and z are containing of course new data and its logical, that i can't erase the old position with their new data and when i erase the target in the actual pass (with my limited knowledge), it brings up a flicker.

How do i have to erase the targets-display at the old position or maybe just before the new position becomes actual?

Greez
Lyqyd #2
Posted 18 June 2013 - 01:50 PM
I've split this into a new topic for you, since it's different enough to call for it.

What you're going to want to do is structure your main loop a little differently:


while true
  declare local table
  for each target
    add target position and name to table
  end
  clear screen
  for each entry in local table
    draw to screen
  end
end

This restructuring gets around the time-consuming target information lookups. The flicker you're experiencing is because you clear the screen before you start the loop again, and then it takes some time to gather all of the information on the entities in range. If you separate out the information gathering and the actual drawing, you can leave the last known information in the screen right up until you have got all of the new information and are ready to draw it to the screen.
ZagKalidor #3
Posted 18 June 2013 - 02:58 PM
Wow, thank you man,

you really take me further, this really has more than one learning objective. Well, i think it takes some time for me to realize that but i prefer learning by doing.

Btw, I'm the founder and first member of the Lyqyd-Fan Club. I'm drinking a beer on you, cheers.
MudkipTheEpic #4
Posted 18 June 2013 - 05:22 PM
Can I be the coowner?
ZagKalidor #5
Posted 19 June 2013 - 12:15 AM
Member first class and co-president