Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

taoshi

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by taoshi

  1. On 12/9/2021 at 7:23 AM, contomman said:

    Is it possible to access the return value of a function used in a thread? The below code works, but I like my functions to explicitly return values rather than abuse the "everything is global" feature of lua.

    
    
    thread = require "thread"
    
    function foo()
    	bar = 1
    	return bar --How to access this?
    end
    
    t = thread.create(foo)
    thread.waitForAll({t}) --Wait for thread to end before obtaining return value
    print(bar) -- 1

     

    Somewhat related, Right now I am using threads to achieve a non-blocking io.read(), so I can receive inputs while my timer events still run. Is this good practice or is there a better way to achieve non-blocking io.read() that I have missed.

    Thanks for your help and advice!

    Quote

    return event.push('foo',bar)

    And

    Quote

    event.listen('foo', my_handler_function)

    In 'my_handler_function' write

    Quote

    function my_handler_function(arg1)

      <any code>

    end

    Its work.

    Or use global variables.

     

  2. Hi.

    First, you nee know about this:

    https://ocdoc.cil.li/component:gpu#video_ram_buffers

    after, you need to use the video buffer of the card to build the image.

    and finally use commands of gpu 'bind' and 'bitblt' to copy the image to the monitors.

    P.S.: if You want not only the image on the monitors, but also to interact with them, then you will have to use events  ('event.pull' at the simplest) to find out what the user has touched on the screen. 'event.pull' will return the touch event and the address of the device where the event happened.

    Good luck, and have bit of fun with this work :-)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.