Announcement
Announcement
| 2nd Quarter Contest Announcement posted! See the Community Announcements section. |
New threads (complete scripts) here will go into a moderation queue. You will not see your thread appear when you create it. A moderator will decide if it will be approved or denied.
![]() ![]() |
Aug 20 2008, 11:36 PM
Post
#1
|
|
![]() ![]() Type: Undisclosed |
Timer Rewrite
Introduction This script allows you to turn your timer display on/off, it allows you to change the opacity of the timer, it allows you to used fixed positioning e.g. Top Left, Bottom Right etc and it also allows you to set an exact position on the screen for it to appear along with being able to change your font size and type for the timer. Features TIMER DISPLAY SWITCH To use the visibility switch, just change the number in the [] to the number of your timer switch:- CODE $game_switches[numberhere] == false FIXED POSITIONING As for the position, just call script and call one of the following, dependant on where you want to place it:- CODE #TOP LEFT $game_system.timer_position = 0 CODE #TOP RIGHT $game_system.timer_position = 1 CODE #BOTTOM LEFT $game_system.timer_position = 2 CODE #BOTTOM RIGHT $game_system.timer_position = 3 UNIVERSAL POSITIONING For an exact position you must call this code:- CODE $game_system.timer_position = 4 $game_system.timer_posx = # $game_system.timer_posy = # Remember to replace the #'s for real numbers. OPACITY CONTROL Replace the '#' with the opacity you want it to be, 255 being solid, 0 being invisible. CODE $game_system.timer_opacity = # CHANGE FONT SIZE & TYPE Replace the # and "font here" to what size and font type you want it to be. CODE $game_system.timer_fontsize = # $game_system.timer_fontsize = "fonthere" Script Add this script above Main. CODE #============================================================================== # ** Game_System #------------------------------------------------------------------------------ # This class handles system-related data. Also manages vehicles and BGM, etc. # The instance of this class is referenced by $game_system. #============================================================================== class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :timer # timer attr_accessor :timer_working # timer working flag attr_accessor :timer_position # timer screen position attr_accessor :timer_posx # timer position x axis attr_accessor :timer_posy # timer position y axis attr_accessor :timer_opacity # timer opacity attr_accessor :timer_fonttype # timer font type attr_accessor :timer_fontsize # timer font size attr_accessor :save_disabled # save forbidden attr_accessor :menu_disabled # menu forbidden attr_accessor :encounter_disabled # encounter forbidden attr_accessor :save_count # save count attr_accessor :version_id # game version ID #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize @timer = 0 @timer_working = false @timer_position = 1 @timer_opacity = 255 @timer_posx = 0 @timer_posy = 0 @timer_fonttype = "Arial" @timer_fontsize = 32 @save_disabled = false @menu_disabled = false @encounter_disabled = false @save_count = 0 @version_id = 0 end #-------------------------------------------------------------------------- # * Get Battle BGM #-------------------------------------------------------------------------- def battle_bgm if @battle_bgm == nil return $data_system.battle_bgm else return @battle_bgm end end #-------------------------------------------------------------------------- # * Set Battle BGM # battle_bgm : new battle BGM #-------------------------------------------------------------------------- def battle_bgm=(battle_bgm) @battle_bgm = battle_bgm end #-------------------------------------------------------------------------- # * Get Battle End ME #-------------------------------------------------------------------------- def battle_end_me if @battle_end_me == nil return $data_system.battle_end_me else return @battle_end_me end end #-------------------------------------------------------------------------- # * Set Battle End ME # battle_end_me : new battle end ME #-------------------------------------------------------------------------- def battle_end_me=(battle_end_me) @battle_end_me = battle_end_me end #-------------------------------------------------------------------------- # * Get Position of Timer #-------------------------------------------------------------------------- def timer_position return @timer_position end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update if @timer_working and @timer > 0 @timer -= 1 if @timer == 0 and $game_temp.in_battle # If the timer 0 in battle $game_temp.next_scene = "map" # interrupt the battle end end end end #============================================================================== # ** Sprite_Timer #------------------------------------------------------------------------------ # This sprite is used to display the timer. It observes the $game_system # and automatically changes sprite conditions. #============================================================================== class Sprite_Timer < Sprite #-------------------------------------------------------------------------- # * Object Initialization # viewport : viewport #-------------------------------------------------------------------------- def initialize(viewport) super(viewport) self.bitmap = Bitmap.new(88, 48) self.bitmap.font.name = $game_system.timer_fonttype self.bitmap.font.size = $game_system.timer_fontsize @timer_position = $game_system.timer_position self.x = 544 self.y = 0 self.z = 200 update end #-------------------------------------------------------------------------- # * Dispose #-------------------------------------------------------------------------- def dispose self.bitmap.dispose super end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update case @timer_position when 0 # Top Left self.x = 85 - self.bitmap.width self.y = 0 when 1 # Top Right self.x = 544 - self.bitmap.width self.y = 0 when 2 # Bottom Left self.x = 85 - self.bitmap.width self.y = 370 when 3 # Bottom Right self.x = 544 - self.bitmap.width self.y = 370 when 4 # Custom self.x = $game_system.timer_posx self.y = $game_system.timer_posy end super self.visible = $game_system.timer_working self.bitmap.font.name = $game_system.timer_fonttype self.bitmap.font.size = $game_system.timer_fontsize if $game_switches[1] == false self.opacity = $game_system.timer_opacity else self.opacity = 0 end if $game_system.timer / Graphics.frame_rate != @total_sec self.bitmap.clear @timer_position = $game_system.timer_position @total_sec = $game_system.timer / Graphics.frame_rate min = @total_sec / 60 sec = @total_sec % 60 text = sprintf("%02d:%02d", min, sec) self.bitmap.font.color.set(255, 255, 255) self.bitmap.draw_text(self.bitmap.rect, text, 1) end end end Credits Kurisu aka Slipper for helping me point out my mistake -------------------- |
|
|
|
Aug 24 2008, 03:52 AM
Post
#2
|
|
![]() |
it just sits their and stays at 0 and does it count up or down cause i need it to count up?
-------------------- -The only way to break free is to break the mold
My website for my game not much but its their :D Sonic Total Chaos <a href="http://www.pokeplushies.com/feed/668391"><img src="http://www.pokeplushies.com/images/adoptables/668391.gif" border="0"><br>Click here to feed me a Rare Candy!</a><br><a href="http://www.pokeplushies.com">Get your own at PokePlushies!</a> |
|
|
|
Aug 24 2008, 09:34 AM
Post
#3
|
|
![]() ![]() Type: Undisclosed |
You need to call the timer and define it first, through the choices in VX.
These features, have to be called via Call Script. The timer counts down. -------------------- |
|
|
|
Mar 1 2010, 09:52 PM
Post
#4
|
|
![]() Type: Designer |
Can you set several timers at once?
For instance, I want an event to trigger a timer for a Farm Plot and if, and when, the timer reaches a certain time, it will trigger the Event to end, but I want several Farm Plots with separate timers going at the same time? Is this possible? |
|
|
|
Mar 2 2010, 01:34 AM
Post
#5
|
|
![]() Type: Writer Alignment: Chaotic Neutral |
Holy Tap Dancing Christ. Check the date before you post.
-------------------- Trailer for It Came From Yesterday: Click Me
This was made by a dear friend of mine. Any support is appreciated! Also, Like the Facebook page while you're at it: It Came From Yesterday New and improved official site: ICFY Swagbucks referral link: http://www.swagbucks.com/refer/jbart321 |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 19th May 2013 - 04:29 AM |
|
|