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.

[Resolved] Waiting for X time.

Status
Not open for further replies.
Hi Again, Again, Again. ;D.

I wonder, if is possible to make something Like this:

You Active some Event...and the event have an special conditional that when passed X time, is actived a Self_Switch A (for example).

Example of the Example:

The player active an event, and when the pass 4 hours the A self switch of the event will be active. (obviusly the Hours can be Frames).
___

I tried with variables, but not work.
Code:
@Time = 0
If @time = @time + 4 #the hours.

But I can't define the frame count.

Thanks.
 

khmp

Sponsor

If you are looking for some sort of in game value to calculate time. Graphics.frame_count will get you the number of times the screen has been redrawn since it was last reset. If you divide that by Graphics.frame_rate you get the total amount of seconds that have passed.
 
Hmmm...

Code:
class Game_System
  attr_accessor :self_switch_timers
  alias_method :seph_selfswitchtimers_gmsys_init, :initialize
  def initialize
    @self_switch_timers = {}
    seph_selfswitchtimers_gmsys_init
  end
end

class << Graphics
  alias_method :seph_selfswitchtimers_graphics_update, :update
  def update
    seph_selfswitchtimers_graphics_update
    return if $game_system.nil?
    $game_system.self_switch_timers.each do |key, timestate|
      timestate[0] -= 1
      if timestate[0] < 0
        $game_selfswitches[key] = timestate[1]
        $game_system.self_switch_timers.delete(key)
        $game_map.need_refresh = true
      end
    end
  end
end

OK. Here's how this works:

Code:
$game_system.self_switch_timers[[map_id, event_id, 'Letter']] = [number_of_frames, boolean]

Ok. So let's say on you want to turn off event 4 self-switch A, on the third map in 300 frames.
Code:
$game_system.self_switch_timers[[3, 4, 'A']] = [300, false]

Just use true or false in the boolean. Untested, so let me know if it doesn't work.
 
Thanks for Answer Khmp and K.Seph.

But, I get a stupid error in the Line 7, when says end.

Code:
class Game_System
  attr_accessor :self_switch_timers
  alias_method :seph_selfswitchtimers_gmsys_init, :initialize
  def initialize
    @self_switch_timers = {}
    seph_selfswitchtimers_gmsys_init
  end
end

class << Graphics
  alias_method :seph_selfswitchtimers_graphics_update, :update
  def update
    seph_selfswitchtimers_graphics_update
    return if $game_system.nil?
    $game_system.self_switch_timers.each do |key, timestate|
      timestate[0] -= 1
      if timestate[0] < 0
        $game_selfswitches[key] = timestate[1]
        $game_system.self_switch_timers.delete(key)
      end
    end
  end
end

Thanks.
 
Thanks that works perfectly, but you forgot a

Code:
$game_map.need_refresh = true

and you put a

Code:
$game_selfswitches

instead of a

Code:
$game_self_switches

So the new code is:

Code:
class Game_System
  attr_accessor :self_switch_timers
  alias_method :seph_selfswitchtimers_gmsys_init, :initialize
  def initialize
    @self_switch_timers = {}
    seph_selfswitchtimers_gmsys_init
  end
end

class << Graphics
  alias_method :seph_selfswitchtimers_graphics_update, :update
  def update
    seph_selfswitchtimers_graphics_update
    return if $game_system.nil?
    $game_system.self_switch_timers.each do |key, timestate|
      timestate[0] -= 1
      if timestate[0] < 0
        $game_self_switches[key] = timestate[1]
        $game_map.need_refresh = true
        $game_system.self_switch_timers.delete(key)
      end
    end
  end
end

I dont want to Desafiate you eh  ::)

Thanks for the code!!  :)
 
I actually did put a $game_map.need_refresh = true in there, after I edited the code. XD

But yeah, I don't have RMXP here, so I couldn't remember if it was self_switches or selfswitches. It's sad how much I have memorized and more sad all the silly mistakes I make. :(
 
Status
Not open for further replies.

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