Jump to content




parallel api

api

10 replies to this topic

#1 flo00297

  • Members
  • 6 posts

Posted 14 January 2017 - 09:55 AM

I'm a bad english speaker/writer so please don't blame me :)
I have a problem with the parallel API. Starting the Programm does nothing and i can't terminate it anymore. I have to disconnect the monitors so that the computer doesn't find the peripherals, then i can use the computer again. Here is the code: http://pastebin.com/pH7K8UxK

Another proble is using the paintutils API. If i run "clear" on a monitor with a graphic the used color become the backgroundcolor and i can't clear it anymore to black. That's why i draw a black Pixel at 0,0 and clear so the color became black again... Is that normal? I'm playing FTB Direwolf20 1.7.10. Pls help.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 January 2017 - 12:09 PM

You're attempting to start functions through the parallel API before you've defined those functions. Assuming that doesn't just crash, that'd mean you've got old copies of those functions floating around in the global scope from an older version of your script. Rebooting the computer would probably lead the script to error instead.

So yeah, move those function definitions above the point where you try to actually use them.

term.clear() sets the entire terminal to its current background colour. Do term.setBackgroundColour(colours.black) if you want to be sure the background colour is black.

#3 flo00297

  • Members
  • 6 posts

Posted 14 January 2017 - 05:11 PM

Thank you for your answer but it still does not work...
I've created a new paste because it was uploaded by a computer. Link here: http://pastebin.com/GDthxATY

If I try to chance the background color nothing happens. and i can see, that the monitors are connected because everything else works. Maybe it's something with FTB because in FTB Ultimate 1.4.7 it's not a problem to change Background colors. For information: Direwolf20 1.10.0, Minecraft 1.7.10, Computercraft 1.75.

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 15 January 2017 - 02:38 AM

I see you've added a term.setBackgroundColor(colors.red) AFTER a term.clear()... if you wanted to paint the screen red, you might have better luck setting the background colour before the clear.

The idea is that setting the background colour doesn't change the display right away: it affects any writes you make to the screen afterwards.

parallel.waitForAny() converts multiple functions into coroutines, executes them, then stops all of them as soon as any complete. Your draw_reactor_off() function will complete nearly as soon as it's first started (it doesn't loop or anything), so your output() function will never even begin.

You probably don't want to be using the parallel API with this script.

#5 flo00297

  • Members
  • 6 posts

Posted 15 January 2017 - 08:05 PM

Thank you very much but how can I run the "output" function near the hole program so that the poweroutput is always displayed and updated?

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 16 January 2017 - 01:18 AM

Personally, I'd replace your parallel API call with the content of your output function, and call draw_reactor_on/off() from within that loop.

#7 flo00297

  • Members
  • 6 posts

Posted 16 January 2017 - 07:59 PM

Could you please give me an example?

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 17 January 2017 - 09:51 AM

Something along these lines may be better:

Spoiler


#9 flo00297

  • Members
  • 6 posts

Posted 17 January 2017 - 12:29 PM

Thank you very much for your help :)

#10 flo00297

  • Members
  • 6 posts

Posted 21 January 2017 - 11:06 PM

I have another question about your Programm. I ´paste it to my Computer but after the slowprint nothing happens. Is that because of the timer or what?

#11 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 21 January 2017 - 11:30 PM

Sort of - the timer actually needs to be set after your sleep() / slowPrint() calls. Try moving that line down.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users