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

When I use my menu(left side of the screen), the stas(right side of the screen disappears than reappears. How do I fix this?

Started by n1ghtk1ng, 13 December 2012 - 04:13 AM
n1ghtk1ng #1
Posted 13 December 2012 - 05:13 AM
I hope the title explained my problem right. What the program does is on one side display an input/stats(currently just have Solar Panels)
and on the left side is my menu that I can scroll through and enable/disable with enter which outputs things. Whenever I press enter (or the up/down arrow to scroll) the right(input/stats) side disappears, then reappears in about 1 second. How can I make this not do that?

Code : http://pastebin.com/Re6GKQxQ
nO_OnE #2
Posted 13 December 2012 - 05:15 AM
Having your code whould make fixing it a whole lot easier…
anonimo182 #3
Posted 13 December 2012 - 10:00 AM
Hi again! I already gave you a solution, what happened?
n1ghtk1ng #4
Posted 13 December 2012 - 12:08 PM
Having your code whould make fixing it a whole lot easier…
Sorry! I copy/pasted on my phone and I thought the pastebin link was there, I'll edit it in now!
n1ghtk1ng #5
Posted 13 December 2012 - 12:10 PM
Hi again! I already gave you a solution, what happened?
If you looked at the post again, I replied to you, but you never responded. What I said to you:

Hi again! I already gave you a solution, what happened?
Sorry, I don't quite get what you mean. Can you place it in my code so that I can understand it better?

EDIT: I understand how to use the timer, but I don't understand how to use it in my code.
EDIT2: Nevermind! I reread it a little bit later and I understand it now. Thanks!
EDIT3: Tested, it doesn't even print the right side of the screen anymore when I do your timer suggestion. Anyother ideas?

function PrintFinalStats()
local tTimer = os.startTimer(3)
local event, param = os.pullEvent()
if event == "timer" then
  CheckTime()
  printDisplay()
  ReceiveStats()
end
end
anonimo182 #6
Posted 13 December 2012 - 03:50 PM
Hi again! I already gave you a solution, what happened?
If you looked at the post again, I replied to you, but you never responded. What I said to you:

Hi again! I already gave you a solution, what happened?
Sorry, I don't quite get what you mean. Can you place it in my code so that I can understand it better?

EDIT: I understand how to use the timer, but I don't understand how to use it in my code.
EDIT2: Nevermind! I reread it a little bit later and I understand it now. Thanks!
EDIT3: Tested, it doesn't even print the right side of the screen anymore when I do your timer suggestion. Anyother ideas?

function PrintFinalStats()
local tTimer = os.startTimer(3)
local event, param = os.pullEvent()
if event == "timer" then
  CheckTime()
  printDisplay()
  ReceiveStats()
end
end
Sorry, I didn't checked :3

Make it so at every second(?) it updates, but get the line of "if event == "timer" then", just leave the functions there, so every event can update it, and if there are any events, the timer will do it

After all, you encase the function in a loop, so it always be processed, in this case:

while true do
printFinalStats()
end
theoriginalbit #7
Posted 14 December 2012 - 02:26 AM
Hi again! I already gave you a solution, what happened?
If you looked at the post again, I replied to you, but you never responded. What I said to you:

Hi again! I already gave you a solution, what happened?
Sorry, I don't quite get what you mean. Can you place it in my code so that I can understand it better?

EDIT: I understand how to use the timer, but I don't understand how to use it in my code.
EDIT2: Nevermind! I reread it a little bit later and I understand it now. Thanks!
EDIT3: Tested, it doesn't even print the right side of the screen anymore when I do your timer suggestion. Anyother ideas?

function PrintFinalStats()
local tTimer = os.startTimer(3)
local event, param = os.pullEvent()
if event == "timer" then
  CheckTime()
  printDisplay()
  ReceiveStats()
end
end
Sorry, I didn't checked :3

Make it so at every second(?) it updates, but get the line of "if event == "timer" then", just leave the functions there, so every event can update it, and if there are any events, the timer will do it

After all, you encase the function in a loop, so it always be processed, in this case:

while true do
printFinalStats()
end

Can I make a suggestion here though. Given that you say parallel.waitForAny(……) using this code:


function PrintFinalStats()
	    while true do
	    CheckTime()
	    printDisplay()
	    ReceiveStats()
	    end
end

will most likely cause the program to terminate saying something about yielding. so put like a sleep(0.5) or something to make the program sleep for 0.5 seconds and not quit due to lack of "yield"