Save-Point
"Wait" in the script - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: "Wait" in the script (/thread-7659.html)

Pages: 1 2


"Wait" in the script - Whisper - 02-23-2020

Hello everyone
I've got (hopefully) simple question.
How I can put "wait" into script? I have CMS script and I made automatic animation when character is giving something away. Problem is that I would like animation to show first and message appeared after but I can't find the way. Animation and message appearing in the same moment.

Code:
if @od_text
      $game_player.animation_id = 5
      @oo_box = Window_MessageOoBox.new(x, y - 16, "   Given  ")
      @oo_box.back.opacity = 0 if $game_system.message_frame == 1
      @oo_box.z = self.z
      @od_text = nil
    end

Any simple solution to solve it?
Have a good one!


RE: "Wait" in the script - kyonides - 02-23-2020

1.times { Graphics.update }

Replace 1 with any specific number. Take into consideration that 1 second should be equal to Graphics.frame_rate which is usually 40 fps.

Well, VX or VX Ace documentation said Graphics.wait was the same as the code above so...


RE: "Wait" in the script - Whisper - 02-24-2020

(02-23-2020, 02:57 AM)kyonides Wrote: 1.times { Graphics.update }

Replace 1 with any specific number. Take into consideration that 1 second should be equal to Graphics.frame_rate which is usually 40 fps.

Unfortunately it doesn't work. It freezes the game for x frame rates and then animation and message comes simultaneously


RE: "Wait" in the script - DerVVulfman - 02-24-2020

I see. The previous solution would freeze all content when evoked. If placed before the animation ID, everything freezes before anything happens. If placed after the animation ID, it still freezes before control is returned to, what I am assuming, is the Scene_Map code before the custom message window is evoked.

The Scene_Map itself already has a wait count system, handled by the Interpreter class itself. This SHOULD sufficient as the
$game_system.map_interpreter.update
command is executed before it attempts to reach the message system code in Scene_Map's update method.

Perhaps a statement like...
$game_system.map_interpreter.wait_count = 20

It will NOT run right away. You cannot just put values into wait_count straight into the Interpreter class because the wait_count value is kinda protected. So... add the following very SIMPLE script:

Code:
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :wait_count               # Time to pause the map in frames
end

Once that is done, you should be able to use the above sample command. It works in map events Laughing + Tongue sticking out


RE: "Wait" in the script - Whisper - 02-24-2020

(02-24-2020, 01:10 AM)DerVVulfman Wrote: I see.  The previous solution would freeze all content when evoked.  If placed before the animation ID, everything freezes before anything happens.  If placed after the animation ID, it still freezes before control is returned to, what I am assuming, is the Scene_Map code before the custom message window is evoked.

The Scene_Map itself already has a wait count system, handled by the Interpreter class itself.  This SHOULD sufficient as the
$game_system.map_interpreter.update
command is executed before it attempts to reach the message system code in Scene_Map's update method.

Perhaps a statement like...
$game_system.map_interpreter.wait_count = 20

It will NOT run right away.  You cannot just put values into wait_count straight into the Interpreter class because the wait_count value is kinda protected.  So... add the following very SIMPLE script:

Code:
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================

class Interpreter
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_accessor :wait_count               # Time to pause the map in frames
end

Once that is done, you should be able to use the above sample command. It works in map events Laughing + Tongue sticking out

Closer, but still not it Confused
Animation and message still appears simultaneously. Waiting applies AFTER message (Player can't move for x time). But at least there is no graphic freeze.


RE: "Wait" in the script - DerVVulfman - 02-24-2020

The message system... does it add new content to the Scene_Map class? If that is the case, placement of a new wait counter routine may be critical.


RE: "Wait" in the script - kyonides - 02-24-2020

Mmm... well, I guess you'd need to separate animation and message update calls. Perhaps you could include an if statement where it checks out if there's an animation id not equal to 0 and then you let it update the animation but return right after that. It gotta be placed before the message update method is called.


RE: "Wait" in the script - DerVVulfman - 02-24-2020

The default wait routine in Scene Map part of the $game_system.map_interpreter.update command in the update method's main loop and runs before the default message update. So it should have worked by default. My inquiry is to know if any changes were made to Scene_Map. That would be key.

(02-24-2020, 02:05 AM)Whisper Wrote: Animation and message still appears simultaneously. Waiting applies AFTER message (Player can't move for x time). But at least there is no graphic freeze.
According to this, the message and animation show simultaneously... then waits. If the custom message system is added to the start of Scene_Map's update method, this would be the result.

Likely example.
Code:
def update
  yadda - yadda - yadda
  new message system     <-- Executes Message Immediately
  yadda - yadda - yadda
  beginning of original code
  default screen graphics  <-- Executes Animation Immediately
  default wait code          <-- NOW WAIT
  default (and unused message)
  yadda - yadda - yadda
end

So yeah, look at the script and see if there's any Scene_Map code. If so, we can always add a custom WAIT command before the message system's custom update just for you.


RE: "Wait" in the script - Whisper - 02-24-2020

Sorry guys but nothing works :(
CMS doesn't add anything in Scene_Map. Whenever I try to add any condition like "show message when timer = 0" script will freeze (unless condition is met). It's "all at the same time or nothing at all".
I'm using Scrolling Message System EX by Slipknot, edited by LiTTleDRAgo and modified by me.
Thank you for your time, guys. I don't want to bother you so much for such a minor problem. However, if you want to "dig" the topic, here are all scripts I'm using. I would send you whole game but its 2gb at this moment xD Command that trigger process I'm trying to fix is /od in message field, and main commands you will find at 811 line of "Scrolling MS EXX*"

https://send.firefox.com/download/353e583320b1108a/#yMKRNnaTyBwvPPz5Ly_D5A


RE: "Wait" in the script - kyonides - 02-24-2020

Well, if that depends on parsing the message text, it's always wait till the message window is displayed to process the request... So I seriously doubt such approach will ever work as you expected.