Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Adding a Thread to a window

If YOU don't know what a Thread is, I think you can't help me and can quit this Topic :)

I want to add a Thread to a window so it runs all the time and not only when the RGSS-Player is selected. (it's something with Kernel, I suppose)
I tried it using the WinAPI but I am too nooby(?) for the only Function I found (CreateThread)

Hope somebody can help ^_^
 
Wouldn't it be

Code:
 

def initialize

  t = Thread.new { loop { @count += 1 } }

end

def update

  if @count > 35

    Thread.kill(t)

  end

end

 

something like that, right?
 

Zeriab

Sponsor

To reformulate the problem here is to create and possible also control a native thread. Ruby (the version used in RMXP) only have support for green threads and Graphics.update pauses the virtual machine.
To solve this problem I would suggest writing a DLL file which provides an API for creating the thread as well as providing the functionality for the thread.
 

Zeriab

Sponsor

The idea behind getting a thread to run even when the RPG Maker window is not running is simple that you can have code running when the RPG Maker window is not running. Your way can be used in the thread to tell whether or not the RGSS Player window is selected which is useful if you want different behavior depending on whether the RGSS Player is selected or not.
 
Hmmm, try using a ruby thread with an update loop
make that loop call an API-call which focus the window or something.
Don't flame me I'm not very good with win32..

But a Thread is done like that:

Thread.new {
loop do
sleep(0.3f)
# enter your api calls here..
end
}
 

Zeriab

Sponsor

The problem with that approach is that the ruby thread is paused if you remove focus for the RGSS Player. If it happens during the API call then it may work, but not if it happens while the thread sleeps.

@Neo-Bahamut:
Good luck ^_^
I believe that most programming languages which can be compiled to native binary code can be compiled into a DLL, but don't hang me up on it.

*hugs*
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top