Jump to content




OS help

lua help

  • You cannot reply to this topic
10 replies to this topic

#1 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 03 September 2012 - 07:04 AM

Could you guys maybe help me out here, I am making a moving border around the file browser for my OS, it works perfectly but when you run a program the border keeps scrolling and gets in the way, I found a way around it with the running variable in the code but when I edit something it stops working, please test it and see if you can find where I am going wrong, you will need the program to launch (the OS) and my latest menu api

OS:
http://pastebin.com/2P2pjvJu
Spoiler

Menu API:
http://pastebin.com/X9cC2MS3
Spoiler

EDIT: in case that was unclear: the border stops generating after you edit a file from the browser

Edited by KaoS, 04 September 2012 - 10:36 AM.


#2 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 03 September 2012 - 03:03 PM

'cmon guys, no ideas?

#3 BigSHinyToys

  • Members
  • 1,001 posts

Posted 04 September 2012 - 11:04 AM

This is the problem line
co1=coroutine.create(function() local a=0 while true do a=a+1 drawborder() cyclingborder(a) cyclingborder(a+1) cyclingborder(a+2) cyclingborder(a+3) sleep(0.1) end end)

the sleep(0.1) is causing the program to not run correctly. This is because it is waiting for a specific timer to go off that never will. because you haven't given it that event .

You need a custom sleep you can manually unfreeze.

This should do it.
http://pastebin.com/BhWtD800

as you can see I copied sleep from the BIOS added another way to break it other than the timer event. then i make that event happen after the shell.run() has ended with os.qeueEvent()

#4 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 04 September 2012 - 11:15 AM

I see!!! thanks man, couldn't I just queue the timer event on resume?

#5 BigSHinyToys

  • Members
  • 1,001 posts

Posted 04 September 2012 - 11:21 AM

you need to call it only when you have lost the previous timer event. I mean when it happened but your program was not waiting for it.
calling it all the time will cause a lot of lag not recommended.

#6 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 04 September 2012 - 11:36 AM

yeah I mean when I set running to 1 I should queue it once

#7 BigSHinyToys

  • Members
  • 1,001 posts

Posted 04 September 2012 - 11:43 AM

yes that is when my misunderstanding sorry

#8 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 04 September 2012 - 11:44 AM

thanks for the help, you are truly a life saver

#9 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 04 September 2012 - 12:44 PM

thought I'd add that os.queueEvent('timer') did not solve the issue, had to use:

running=0 local events={os.pullEvent('timer')} shell.run("edit",input) os.queueEvent(unpack(events)) running=1
because the table reference of the second parameter must be the correct one (the queueEvent function returns an empty table because that generates a unique reference number that you can then use to make sure you get the right one)

if {}=={} then
print('true')
end
will never print true

#10 BigSHinyToys

  • Members
  • 1,001 posts

Posted 04 September 2012 - 12:52 PM

and now you know why I made a copy of the sleep function with a way to manually unstuck the loop.
os.queueEvent('timer') will not work but copying the events you did works too. I used that method to keep the returned data from turtle.forward() so when i restart my mining program it doesn't hang.

#11 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 04 September 2012 - 12:55 PM

indeed, I am going to take a more in depth look at pausing and resuming different threads without issue as well as the native commands as these may prove incredibly useful





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users