The RPG Maker Resource Kit

Other Game Creation => Program Troubleshooting => Topic started by: kathis on November 11, 2007, 11:47:26 PM

Title: help with script [xp] (making a varible from time.now)
Post by: kathis on November 11, 2007, 11:47:26 PM
This is just confusing me mostly. I think I have everything correct but saddly I am not sure. It doesn't seem to work and I have no idea why the devil not.

I took this code and pasted it above Main

[spoiler]
class Game_System
   
   attr_accessor :time
   
   alias init_time_system initialize
   def initialize
     init_time_system
     @time = Time.now
   end
   
   def update_time
     @time = Time.now
    $game_variables[101] = @time.min if $game_variables != nil
     $game_variables[102] = @time.hour if $game_variables != nil
     $game_variables[103] = @time.mday if $game_variables != nil
      $game_variables[104] = @time.wday if $game_variables != nil
      $game_variables[105] = @time.mon if $game_variables != nil
       $game_variables[106]= @time.year if $game_variables != nil
      end
 
end
[/spoiler]

yes I have tried smaller varibles like " $game_variables[1] "

I tried removing @time and replacing it to something like

$game_variables[101] = Time.now.min

I even tried removing  " if $game_variables != nil " however this one liked giving me some errors.

so if anyone know what is incorrect please help me figure it out. Thank you


Btw I did look up in the search bar, unable to find anything that would help with "Time.now" "time , varibles"

- Kathis
Title: Re: help with script [xp] (making a varible from time.now)
Post by: tSwitch on November 12, 2007, 01:41:00 AM

class Game_System
  alias init_time_system initialize
  def initialize
   init_time_system
   @time = Time.now
  end
  def update_time
    @time = Time.now
    if $game_variables != nil
      $game_variables[101] = @time.min
      $game_variables[102] = @time.hour
      $game_variables[103] = @time.mday
      $game_variables[104] = @time.wday
      $game_variables[105] = @time.mon
      $game_variables[106]= @time.year
    end
  end
end
class Scene_Map
  alias update_old update
  def update
    $game_system.update_time
    update_old
  end
end


that'll update the time constantly on the map
should work the way you want it to

all I did was have it call update_time every time the map refreshed