The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Abigaila on May 27, 2014, 06:30:01 PM

Title: Help with Win32API
Post by: Abigaila on May 27, 2014, 06:30:01 PM
I have the following code:


@do_move = Win32API.new("ChessEngine.dll", "do_move", ['I','I'], "I")
@best_move = Win32API.new("ChessEngine.dll", "best_move", "", "L")

...

# Player move
@do_move.call(@from, @cursor)
refresh
         
# Computer move
@best_move.call()
refresh


@best_move is a function that can take quite long to execute, but @do_move is instant. I want the board to be redrawn after @do_move, before @best_move is called, but instead refresh doesn't seem to be run until after both Win32APIs are called.

Title: Re: Help with Win32API
Post by: TDS on May 27, 2014, 10:17:48 PM
From the looks of your code it would seem everything is called in a single frame which means that everything updates at once.

If you want a pause between @do_move and @before_best you need to add it in between.


@do_move = Win32API.new("ChessEngine.dll", "do_move", ['I','I'], "I")
@best_move = Win32API.new("ChessEngine.dll", "best_move", "", "L")

...

# Player move
@do_move.call(@from, @cursor)
refresh

# Wait 60 frames (Only the Graphics module is updated)
Graphics.wait(60)
         
# Computer move
@best_move.call()
refresh


Graphics.wait is not probably what you want, but you can visibly see a pause after @do_move. You will probably want to add your own wait method if things are moving or being animated on screen.
Title: Re: Help with Win32API
Post by: Abigaila on May 27, 2014, 10:26:25 PM
Quote from: TDS on May 27, 2014, 10:17:48 PM
From the looks of your code it would seem everything is called in a single frame which means that everything updates at once.

If you want a pause between @do_move and @before_best you need to add it in between.


@do_move = Win32API.new("ChessEngine.dll", "do_move", ['I','I'], "I")
@best_move = Win32API.new("ChessEngine.dll", "best_move", "", "L")

...

# Player move
@do_move.call(@from, @cursor)
refresh

# Wait 60 frames (Only the Graphics module is updated)
Graphics.wait(60)
         
# Computer move
@best_move.call()
refresh


Graphics.wait is not probably what you want, but you can visibly see a pause after @do_move. You will probably want to add your own wait method if things are moving or being animated on screen.

Ah, you're right.

I tried simply putting a Graphics.update between them and that worked. :D