iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> [-System-] Time System with HUD, Includes demo
Celianna
post Mar 14 2011, 10:17 PM
Post #1



Group Icon


Type: Artist
Alignment: Chaotic Evil




Download the demo here (without RTP): http://www.mediafire.com/?6a8i1itowpjkrj6
Get your variables fix here: http://www.rpgmakervx.com/variables-fix



This is a time system complete with on-screen HUD that shows the current time, the day, the day of the week, and the season - great for Harvest Moon games. The time system runs on 4 seasons, each having 20 days.

Script used:

IceDragon's Variable Picture script (god sent to eventers like me).
Spoiler:
CODE
# Variable Pictures
# Created By IceDragon
# Date Created : 01/16/2011
# Date Modified: 01/16/2011
# Version : BETA-1

$imported = {} if $imported == nil
$imported["IEX_VarPics-BETA"] = true

module IEX
  module VariablePictures
#==============================================================================
#                           Start Primary Customization
#------------------------------------------------------------------------------
#==============================================================================
    # Hosting Location
    # 0 - Apart of the Spriteset_Map (Recommended)
    # 1 - Solo (Directly on the Scene_Map) (Not Recommended)
    HOST_MODE = 0
    # Image handling mode
    # 0 - Self
    # 1 - Game_Picture (Only Recommended, when paired with YEM Restored Functions)
    MODE = 0
    
    # If using mode 1, this is used to designate what pictures
    # should be used for this script, by giving it a start position
    # Note the number of pictures used is equal to the number of variables
    # stated in the VARIABLE_PICTURES
    START_PICTURE = 21
    
    VARIABLE_SWITCHES = {
    # Variable_ID => Switch_ID
      0 => nil,
      1 => 1,
    } # Do not Remove
    
    VARIABLE_PICTURES = {}
    # Currently this is how it works
    # VARIABLE_PICTURES[variable_id] = {
    #  variable_value => "filename"}
    
#===============================================================================
  

    #=========================#
    #Sample  remove if you wish                #
    #=========================#
    VARIABLE_PICTURES[1] = {
    0 => "",
    1 => "samplepicture",
    }


    
#==============================================================================
    # As you already know, from the help file.
    # 0 - Is for below character
    # 50 - Same as character
    # 100 - Above Character
    # Note this is only effective with mode 0
    
    VARIABLE_PRIORITY = {
      0 => nil,
      1 => 100,
    } # Do not Remove
#==============================================================================
#                           End Primary Customization
#------------------------------------------------------------------------------
#==============================================================================    
  end
end
  
#==============================================================================
# ** Spriteset_VarPic
#------------------------------------------------------------------------------
#==============================================================================
class Spriteset_VarPic
  
  include IEX::VariablePictures
  
  attr_accessor :sprites
  
  def initialize(viewport = nil)
    @viewport = viewport
    case MODE
    when 0
      @sprites      = {} # The key is the variable ID, the value is a sprite
      @last_values  = {} # The key is the variable ID, the value is the variable's value
      count = 0
      for key in VARIABLE_PICTURES.keys
        @sprites[key] = Sprite.new(@viewport)
        @sprites[key].bitmap = Bitmap.new(24, 24)
        az = 1+count; az = VARIABLE_PRIORITY[key] if VARIABLE_PRIORITY.has_key?(key)
        @sprites[key].z = az
        count += 1
      end
    when 1
      @used_pictures = {} # The key is the variable ID, the value is the Picture ID
      @last_values   = {} # The key is the variable ID, the value is the variable's value
      pid = START_PICTURE
      for key in VARIABLE_PICTURES.keys
        @used_pictures[key] = pid
        pid += 1
      end  
    end  
    update
  end
  
  def dispose
    case MODE
    when 0
      for key in @sprites.keys
        next if @sprites[key].nil?
        @sprites[key].dispose
        @sprites[key] = nil
      end
    when 1
      for key in @used_pictures.keys
        pid = @used_pictures[key]
        $game_map.screen.pictures[pid].erase
      end  
    end  
  end
  
  def update
    case MODE
    when 0 # Self Mode
      for key in @sprites.keys
        vis = true
        if VARIABLE_SWITCHES.has_key?(key)
          vis = $game_switches[VARIABLE_SWITCHES[key]] if !VARIABLE_SWITCHES[key].nil?
        else
          vis = $game_switches[VARIABLE_SWITCHES[0]] if !VARIABLE_SWITCHES[0].nil?
        end
        @sprites[key].visible = vis
        next unless @sprites[key].visible
        if VARIABLE_PICTURES.has_key?(key)
          if @last_values[key] != $game_variables[key]
            @sprites[key].bitmap.dispose
            nam = VARIABLE_PICTURES[key][$game_variables[key]]
            if nam.to_s != ""
              @sprites[key].bitmap = Cache.picture(nam)
            end  
            @last_values[key] = $game_variables[key]
          end
        end  
        @sprites[key].update
      end
    when 1
      for key in @used_pictures.keys
        pid = @used_pictures[key]
        vis = true
        if VARIABLE_SWITCHES.has_key?(key)
          vis = $game_switches[VARIABLE_SWITCHES[key]] if !VARIABLE_SWITCHES[key].nil?
        else
          vis = $game_switches[VARIABLE_SWITCHES[0]] if !VARIABLE_SWITCHES[0].nil?
        end
        if vis
          if VARIABLE_PICTURES.has_key?(key)
            if @last_values[key] != $game_variables[key]
              $game_map.screen.pictures[pid].erase
              x = 0
              y = 0
              nam = VARIABLE_PICTURES[key][$game_variables[key]]
              $game_map.screen.pictures[pid].show(nam.to_s,
              # Origin, x, y, zoomx, zoomy, opacity, blend_type
              0, x, y, 100, 100, 255, 0)
              @last_values[key] = $game_variables[key]
            end
          end
        else
          if $game_map.screen.pictures[pid].name != ""
            $game_map.screen.pictures[pid].erase
            @last_values[key].clear
          end  
        end # End if vis
      end # End for  
    end # End case
  end
  
end  

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#==============================================================================
class Spriteset_Map
  
  attr_accessor :varpic_spriteset
  
  alias iex_varpic_spmp_initialize initialize unless $@
  def initialize
    iex_varpic_spmp_initialize
    @varpic_spriteset = Spriteset_VarPic.new(@viewport1)
  end
  
  alias iex_varpic_spmp_dispose dispose unless $@
  def dispose
    iex_varpic_spmp_dispose
    @varpic_spriteset.dispose unless @varpic_spriteset.nil?
  end
  
  alias iex_varpic_spmp_update update unless $@
  def update
    iex_varpic_spmp_update
    @varpic_spriteset.update unless @varpic_spriteset.nil?
  end
  
end  

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#==============================================================================
class Scene_Map < Scene_Base
  
  alias iex_varpic_scmp_start start unless $@
  def start
    iex_varpic_scmp_start
    @varpic_spriteset = Spriteset_VarPic.new if IEX::VariablePictures::HOST_MODE == 0
  end
  
  alias iex_varpic_scmp_terminate terminate unless $@
  def terminate
    iex_varpic_scmp_terminate
    @varpic_spriteset.dispose unless @varpic_spriteset.nil?
  end
  
  alias iex_varpic_scmp_update update unless $@
  def update
    iex_varpic_scmp_update
    @varpic_spriteset.update if @varpic_spriteset != nil
  end
  
  def varpic_spriteset
    case IEX::VariablePictures::HOST_MODE
    when 0; return @varpic_spriteset
    when 1; return @spriteset.varpic_spriteset
    else; return nil
    end  
  end
  
end


Variables used:
@ HUD_base
@ AM/PM
@ Minute
@ Hour
@ Day
@ Week
@ Season
@ Year


Switches used:
@ Time
@ HUD


Some notes:
- The HUD relies on IceDragon's script to be displayed, it can show any amount of pictures on the screen using only variables, so the script is perfect for this.
- Use switch Time to stop time, but not erase the HUD. Turn both switch Time and HUD off to erase the HUD and stop time.
- Time passes every 10 minutes. It's a game, it doesn't need to show every little minute on the screen.
- Days are limited to 20 days (I think that's pretty reasonable for a game).
- There are 4 months, each is a season (spring, summer, fall and winter).
- And then there are years which go on forever
- Because everything is stored into variables you can easily event a lot of things with it (screen tinting for example, or closing shops after 5 PM).
- When your game starts, you have to define a few variables already (for example, day 0 doesn't exist, only day 1).
- Use 'Time Instant' common event when you go to bed, or are changing the dates abruptly and need the HUD to update right away.

Part 1
Spoiler:
Before we can event our nice time system, you need to make sure you have all the graphics ready! Let me sum up which graphics you need:

- The base of the HUD. Everything else will get displayed on top of the HUD.
- An image for each week day (Mon, Tue, Wed, Thu, Fri, Sat and Sun).
- An image for each day (since we have 20 days, you'll need to make 20 images of these numbers).
- An image for each hour (which are only 12 pictures).
- An image for each minute (since time skips every 10 minutes, you only need 5 images for this).
- An image for both PM and AM

All of these images need to be in place already - IceDragon's script doesn't allow you to choose coordinates for the pictures that are displayed on the screen, so you're going to have to position them yourself in a blank 544x416 image. This takes off a lot of work load!

Anyways, got the images? If you don't want to make your own, you can use mine instead that are included with the demo.


Part 2
Spoiler:
Make a new common event, call it Time whatever, and follow the instructions:

Small note: when using a conditional branch for the seasons, I accidentally made it 'greater than 5', but it should be 'greater than 4'. The demo has the fixed version.



Part 3
Spoiler:
Part 3 deals with the script of the time system. You have now finished the graphics and the events, but you still have to input them into the script. Please read the instructions of the script and go to the editable region. If you're still confused, check out the demo where everything is nicely organized.

Each variable needs a switch tied to it (in our case switch 100) so that it can be displayed on the screen. If the switch is off, the pictures disappear.

CODE
    VARIABLE_SWITCHES = {
    # Variable_ID => Switch_ID
      0 => nil,
      93 => 99,
      94 => 99,
      95 => 99,
      96 => 99,
      97 => 99,
      98 => 99,
      99 => 99,
    } # Do not Remove


Then you need to define each value of the variable to let the script know which picture to display on the screen. An example:

CODE
    #=========================#
    # HUD Hour                #
    #=========================#
    VARIABLE_PICTURES[96] = {
      0 => "hud_hour_00",
      1 => "hud_hour_01",
      2 => "hud_hour_02",
      3 => "hud_hour_03",
      4 => "hud_hour_04",
      5 => "hud_hour_05",
      6 => "hud_hour_06",
      7 => "hud_hour_07",
      8 => "hud_hour_08",
      9 => "hud_hour_09",
      10 => "hud_hour_10",
      11 => "hud_hour_11",
      12 => "hud_hour_12",
    }


And the last thing you need to do is define the priority of these images. The base HUD needs to be below all the other images, so leave it at 99. Everything else can be at 100.

CODE
    VARIABLE_PRIORITY = {
      0 => nil,
      93 => 99,
      94 => 100,
      95 => 100,
      96 => 100,
      97 => 100,
      98 => 100,
      99 => 100,
      
    }


You have now finished your time system! Have fun incorporating it into your game.
Go to the top of the page
 
+Quote Post
   
new
post Mar 14 2011, 11:22 PM
Post #2



Group Icon


Type: Designer
Alignment: Chaotic Evil




it does look pretty good, just really effort making all the images.


--------------------
download here
(Ask before using a bar from someone's sig -Touchfuzzy)
Go to the top of the page
 
+Quote Post
   
WilliamJConn
post Mar 15 2011, 10:49 AM
Post #3


Lesser-known Grammarian and Wordsmith
Group Icon


Type: Writer
Alignment: Chaotic Evil




It's like you know what I need and make it just for me, Cel! smile.gif

This is amazing!


--------------------

Current Projects:
N/A :(
Go to the top of the page
 
+Quote Post
   
Guth
post Mar 15 2011, 11:46 PM
Post #4


Stranger than a kitten in a shoe store.
Group Icon


Type: Undisclosed
Alignment: Chaotic Neutral




This will be very helpful biggrin.gif I was in need of a time system, the one I was working on had problem after problem. This one has just what I need, Time, Day of the Week, and Season!

This post has been edited by Guth: Mar 15 2011, 11:47 PM


--------------------

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Go to the top of the page
 
+Quote Post
   
Celianna
post Mar 16 2011, 02:07 AM
Post #5



Group Icon


Type: Artist
Alignment: Chaotic Evil




Updated the demo with the fixed version. The old one had the seasons not changing after winter passed.
Go to the top of the page
 
+Quote Post
   
Zetu
post Mar 16 2011, 02:12 AM
Post #6


Has broken out of Staby Rehab!
Group Icon


Type: Undisclosed
Alignment: Chaotic Evil




You probably should have made a script to replace that common event :/
Other than that, it's pretty cool.


--------------------
My Scripts:

Best. Error. Evah!!!
Spoiler:


Team JIFZ: Jet, Ice, Fenix, Zetu

A stabbing Gesture is a friendly Gesture
Go to the top of the page
 
+Quote Post
   
Celianna
post Mar 16 2011, 02:51 AM
Post #7



Group Icon


Type: Artist
Alignment: Chaotic Evil




... What?

Have you totally and completely ignored that this is the Eventing forum? To make a script out of this completely defies its initial purpose of being evented. We all know you love to turn everything into scripts Zetu, but there's absolutely no reason for this to be scripted.
Go to the top of the page
 
+Quote Post
   
Zetu
post Mar 16 2011, 03:02 AM
Post #8


Has broken out of Staby Rehab!
Group Icon


Type: Undisclosed
Alignment: Chaotic Evil




Oh... didn't even realize what forum this was on *facepalm*
Nevermind, carry on.


--------------------
My Scripts:

Best. Error. Evah!!!
Spoiler:


Team JIFZ: Jet, Ice, Fenix, Zetu

A stabbing Gesture is a friendly Gesture
Go to the top of the page
 
+Quote Post
   
Sh1n3
post Mar 16 2011, 12:30 PM
Post #9



Group Icon


Type: Musician
Alignment: Chaotic Evil




OMG...I've been Googling for days and yet It was right under my nose!!!! Although now I need to draw myself a HUD...I was inspired by Fable type Time of Day dial! Nice Work smile.gif


--------------------
It is the most simplest things that are most complicated!
Go to the top of the page
 
+Quote Post
   
new
post Mar 29 2011, 02:10 PM
Post #10



Group Icon


Type: Designer
Alignment: Chaotic Evil




you could use STR27_Textpicture v1.2 in STR_Scripts v1.0, saves anybody from making so many images.


--------------------
download here
(Ask before using a bar from someone's sig -Touchfuzzy)
Go to the top of the page
 
+Quote Post
   
Kaptain J
post Mar 29 2011, 04:33 PM
Post #11


Death says "Hi"
Group Icon


Type: Writer
Alignment: Lawful Evil




I completely missed this thread. You, my dear, are making me strongly consider making a Harvest Moon game. Seriously, what Harvest Moon aspect hasn't been done yet?


--------------------


Come join Team Smash today!


Other stuffz:
Spoiler:






RPGMakerVX.net Awards:
Spoiler:




Check out my tutorial and articles:
How to Write a Story
The Kaptain's Article Dump

Go to the top of the page
 
+Quote Post
   
theundreamer
post Mar 29 2011, 09:51 PM
Post #12


Lord of the Underworld
Group Icon


Type: Designer
Alignment: Lawful Evil




QUOTE
(god sent to eventers like me).


Well its like god sent you to us, lol


--------------------
"Mindrape is just like violence or pizza, if it doesn't solve a problem, you just don't have enough of it going on"-FinalJustice(Giantip forums)

Support plz ^_^

Current Progress(|||||) 19%

I Support:

Go to the top of the page
 
+Quote Post
   
marlon667
post Apr 16 2011, 03:59 AM
Post #13



Group Icon


Type: Coder
Alignment: Lawful Good




Nice work, Cel!
Can I just point out one thing? When you sleep on the bed, the date changes, but the actual day doesn't. Is it ment to be like that? and how come when yo change the day on the signpost, the week changes every time instead of just at the end of the week? (Sorry if i'm missing something here...)

This post has been edited by marlon667: Apr 16 2011, 04:04 AM


--------------------
I thought i was more of a Mudkip or a Riolu... *sigh*
Go to the top of the page
 
+Quote Post
   
Celianna
post Apr 16 2011, 09:05 PM
Post #14



Group Icon


Type: Artist
Alignment: Chaotic Evil




Uploaded a fixed version, as well as added a common event that is called when you go to bed to update the HUD instantly.

Also, the 'week' changes because it's the 'day of the week'. If a day passes, guess what - it's the next day of the week!
Go to the top of the page
 
+Quote Post
   
Lady Loren
post May 22 2011, 08:00 PM
Post #15



Group Icon


Type: Undisclosed




have several files in your folder, which is the file that corresponds to this system?
Go to the top of the page
 
+Quote Post
   
fantasyheart
post May 23 2011, 02:29 PM
Post #16



Group Icon


Type: Designer
Alignment: Neutral Good




http://www.mediafire.com/?6a8i1itowpjkrj6
there she put the wrong link heres the right one!


--------------------


Go to the top of the page
 
+Quote Post
   
Celianna
post May 23 2011, 02:32 PM
Post #17



Group Icon


Type: Artist
Alignment: Chaotic Evil




Thanks for pointing out fantasyheart, I already updated the link in the OP, I somehow redirected it to a different folder (no clue how that even happened).
Go to the top of the page
 
+Quote Post
   
Jaide
post Nov 8 2011, 09:48 PM
Post #18


ಠ_ಠ
Group Icon


Type: Writer
Alignment: Chaotic Good




I apologize for necroposting, but I thought you would want to know, Celianna, that one of the HUD pictures appears to be missing from the demo. hud_hour_08. It crashes the game when it can't find the picture. An easy fix, but I thought you'd want to know about it so the demo works properly. smile.gif

Actually, upon further inspection, it's not missing, it's just named incorrectly.

This post has been edited by Jaide: Nov 8 2011, 09:50 PM
Go to the top of the page
 
+Quote Post
   
Celianna
post Nov 9 2011, 12:19 AM
Post #19



Group Icon


Type: Artist
Alignment: Chaotic Evil




Ah, a silly mistake.

Just rename picture 'hud_08' to 'hud_hour_08' and everything should be fine smile.gif
Go to the top of the page
 
+Quote Post
   
ShounenAi22
post Aug 9 2012, 01:22 AM
Post #20



Group Icon


Type: Writer
Alignment: Lawful Good




Thank you ever so much for posting this! It has helped me a lot! Though I have a question to ask, I hope it isn't a repetitive one you've gotten before, but do you know exactly where to place in the night effects? I've tried everything I could think of for the pass two weeks and I keep getting error after error, it is driving me insane. So I hoped you could tell me if when making night time should it be an event or common event? I was able to get it to go to night and return to morning at 6am. I planned for night to start at 7pm. So once it hits 7am, it suddenly turns back to 7pm and nighttime again. Ugh, it's such a pain. I really hope this isn't a bothersome question.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 30th September 2014 - 10:57 AM

RPGMakerVX.net is an Privacy Policy, Legal.