42 posts
Posted 25 August 2014 - 12:22 AM
I want to make a Radar but right now my problem is that I need to put the addText into a loop cause I need it for every player
but then it would also mean I would put it into the while loop (line 11) which is causing the Text to overlap (Also don't know why cause it print an empty string).
When I use the bridge.clear at line 12 the problem is that it deletes so fast that it doesn't even display it.
Code:
http://pastebin.com/6gChcHEq
3057 posts
Location
United States of America
Posted 25 August 2014 - 01:37 AM
Add in a sleep before it. 0.1 should be short enough.
7083 posts
Location
Tasmania (AU)
Posted 25 August 2014 - 02:55 AM
Personally I'd go for at least a second.
It'd also pay to move the clear call down a bit. You want as little gap between that and when you start re-rendering as possible - any non-rendering work you do in the meantime will only contribute to a flickering effect. You could slot it in under the loop that ends on line 23.
I've not used the bridge myself, but I've got a vague memory it's possible to change existing text fields. If so then that may be a bit faster/easier than constantly clearing and recreating them.
7508 posts
Location
Australia
Posted 25 August 2014 - 02:59 AM
I've not used the bridge myself, but I've got a vague memory it's possible to change existing text fields. If so then that may be a bit faster/easier than constantly clearing and recreating them.
most definitely. Clearing and recreating objects uses more network bandwidth, as well as causes flicker. Just store the objects from the calls and update.
example code that randomly moves a box around every second, as opposed to deleting and recreating a new one
local bridge = peripheral.wrap('left')
local someBox = bridge.addBox(1,1,100,100,0xFFFFFF)
while true do
sleep(1)
someBox.setX(math.random(1,50))
someBox.setY(math.random(1,50))
end
42 posts
Posted 25 August 2014 - 10:04 AM
I've not used the bridge myself, but I've got a vague memory it's possible to change existing text fields. If so then that may be a bit faster/easier than constantly clearing and recreating them.
most definitely. Clearing and recreating objects uses more network bandwidth, as well as causes flicker. Just store the objects from the calls and update.
example code that randomly moves a box around every second, as opposed to deleting and recreating a new one
local bridge = peripheral.wrap('left')
local someBox = bridge.addBox(1,1,100,100,0xFFFFFF)
while true do
sleep(1)
someBox.setX(math.random(1,50))
someBox.setY(math.random(1,50))
end
My problem is that I can't do this cause I need to scan people inside the while loop and then set the number of setText to how many people there are
7508 posts
Location
Australia
Posted 25 August 2014 - 10:59 AM
What you want to do definitely changes nothing with my example. Set the text initially to 'counting users…' Or something and then update it in the loop whenever you wanted to.