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

clock running while in a program

Started by vyse, 08 October 2014 - 10:19 PM
vyse #1
Posted 09 October 2014 - 12:19 AM
So lately my friend has been working on making a whole internet system with MPS and a update sever and so on. And i was given the job to make a browser, so far i have gotten all that i want it to look like done.
But the only problem i have now is getting a clock to run with out messing any of it up.
For exp i have 3 colors at all times, on the screen top line is white middle is blue then bottom line is white and that is to have as the boarder.
What i want to do is have the clock at the bottom of the boarder running while your in the browser looking at websites etc ..

The problem i am having now is getting the clock to always be updating while still be able to use the full operations of the browser.

Also i can't use term.clear() when i do it either turns the screen white or nothing works, and its in a loop which makes it so i cant run the actual program.
Bomb Bloke #2
Posted 09 October 2014 - 01:16 AM
Have a read through this thread plus the articles I linked there, then see how you go.
vyse #3
Posted 10 October 2014 - 03:06 AM
i still don't understand.. im running a loop but still want to run that loop while continuing to the rest of the program.. what you gave me was waiting parallel loops for rednet.
Dragon53535 #4
Posted 10 October 2014 - 03:54 AM
What code are you using, and what are you trying to acomplish?
vyse #5
Posted 10 October 2014 - 04:34 AM

function t()
while true do
term.setCursorPos(1,19)
write(textutils.formatTime(os.time()))
sleep(.2)
term.clear()
end
end
-- other code etc
so after the loop i want to be able to continue down the list of code that i have set.
so like for exp. it asks questions. but still able to keep the time updating.
and and while having the code run it will not affect the background colors.
Edited on 10 October 2014 - 02:37 AM
Bomb Bloke #6
Posted 10 October 2014 - 04:58 AM
Stick the rest of your code into a different function, then sic the parallel API on them both. Otherwise, set up an event listener loop along the lines of that in this thread.

In regards to changing backgrounds in one area of the display without affecting another, the window API allows you to divy up your display into separate "screens".
Hobby_Crafter #7
Posted 10 October 2014 - 08:23 PM
Yes, I had this same problem once and my solution was the parallel API. When you use
parallel.waitForAny(function1,function2) or parallel.waitForAll(function1,function2)
you can run two functions at the same time.

I hope I could help ;D
vyse #8
Posted 10 October 2014 - 09:50 PM
ok ill try it out.
vyse #9
Posted 10 October 2014 - 10:06 PM
ok so a problem with window Api i get what its apose to do but for some reason i get nil value or expected )

local y = colors.white
x = colors.blue
p = "			 "
test = yes
win = window.create(term.current(),11,30,30,17)
win.BackgroundColor(x)
term.clear
end
-- more code
KingofGamesYami #10
Posted 10 October 2014 - 10:19 PM
win.BackgroundColor( x ) will error Attempt to call nil.

you are looking for
win.setBackgroundColor( x )
vyse #11
Posted 10 October 2014 - 10:22 PM
lol stupid mistake.. but now i still get attempt to index ?
Edited on 10 October 2014 - 08:24 PM
Bomb Bloke #12
Posted 11 October 2014 - 03:21 AM
You'll also get a line number with that error. Which specific line does that point to?

Your use of term.clear will also error, due to your lack of brackets to indicate you wish to call it as a function.
vyse #13
Posted 12 October 2014 - 05:13 AM
lol ok i figured out that i had the wrong version i was running on 1.5 when this came out on 1.6 so i have it fixed now. but it seems it still gets messed up when i run term.clear() etc.. but i figured that if i did middle.clear() left.clear()
it only clears that section of the screen so that works sorta. now time for the clock..