Izyees Fariz 1 Report post Posted November 2, 2014 (edited) This is my first script.... Simple Pause System Made by me, Izyees. This is the pause system, simply press "P" in map to pause.Screenshot : Demo : No need Script : Core : #============================================================================== # This is the Izy Core Script, some script may need this core script. #============================================================================== # Credit : # Cyclope for the module input # Tigurus for help me fix the error of the script # Mr. Mo for the tutorial #============================================================================== class Izy_Window < Window def initialize(x, y, width, height) super() @windowskin_name = $game_system.windowskin_name self.windowskin = RPG::Cache.windowskin(@windowskin_name) self.x = x self.y = y self.width = width self.height = height self.z = 100 end def dispose if self.contents != nil self.contents.dispose end super end def text_color(n) case n when 0 return Color.new(255, 255, 255, 255) when 1 return Color.new(128, 128, 255, 255) when 2 return Color.new(255, 128, 128, 255) when 3 return Color.new(128, 255, 128, 255) when 4 return Color.new(128, 255, 255, 255) when 5 return Color.new(255, 128, 255, 255) when 6 return Color.new(255, 255, 128, 255) when 7 return Color.new(192, 192, 192, 255) else normal_color end end def normal_color return Color.new(255, 255, 255, 255) end def disabled_color return Color.new(255, 255, 255, 128) end def system_color return Color.new(192, 224, 255, 255) end def crisis_color return Color.new(255, 255, 64, 255) end def knockout_color return Color.new(255, 64, 0) end def update super if $game_system.windowskin_name != @windowskin_name @windowskin_name = $game_system.windowskin_name self.windowskin = RPG::Cache.windowskin(@windowskin_name) end end def draw_actor_graphic(actor, x, y) bitmap = RPG::Cache.character(actor.character_name, actor.character_hue) cw = bitmap.width / 4 ch = bitmap.height / 4 src_rect = Rect.new(0, 0, cw, ch) self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect) end def draw_actor_name(actor, x, y) self.contents.font.color = normal_color self.contents.draw_text(x, y, 120, 32, actor.name) end def draw_actor_class(actor, x, y) self.contents.font.color = normal_color self.contents.draw_text(x, y, 236, 32, actor.class_name) end def draw_actor_level(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 32, 32, "Lv") self.contents.font.color = normal_color self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2) end def make_battler_state_text(battler, width, need_normal) brackets_width = self.contents.text_size("[]").width text = "" for i in battler.states if $data_states[i].rating >= 1 if text == "" text = $data_states[i].name else new_text = text + "/" + $data_states[i].name text_width = self.contents.text_size(new_text).width if text_width > width - brackets_width break end text = new_text end end end if text == "" if need_normal text = "[Normal]" end else text = "[" + text + "]" end return text end def draw_actor_state(actor, x, y, width = 120) text = make_battler_state_text(actor, width, true) self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color self.contents.draw_text(x, y, width, 32, text) end def draw_actor_exp(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 24, 32, "E") self.contents.font.color = normal_color self.contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2) self.contents.draw_text(x + 108, y, 12, 32, "/", 1) self.contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s) end def draw_actor_hp(actor, x, y, width = 144) self.contents.font.color = system_color self.contents.draw_text(x, y, 32, 32, $data_system.words.hp) if width - 32 >= 108 hp_x = x + width - 108 flag = true elsif width - 32 >= 48 hp_x = x + width - 48 flag = false end self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2) if flag self.contents.font.color = normal_color self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1) self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s) end end def draw_actor_sp(actor, x, y, width = 144) self.contents.font.color = system_color self.contents.draw_text(x, y, 32, 32, $data_system.words.sp) if width - 32 >= 108 sp_x = x + width - 108 flag = true elsif width - 32 >= 48 sp_x = x + width - 48 flag = false end self.contents.font.color = actor.sp == 0 ? knockout_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2) if flag self.contents.font.color = normal_color self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1) self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s) end end def draw_actor_parameter(actor, x, y, type) case type when 0 parameter_name = $data_system.words.atk parameter_value = actor.atk when 1 parameter_name = $data_system.words.pdef parameter_value = actor.pdef when 2 parameter_name = $data_system.words.mdef parameter_value = actor.mdef when 3 parameter_name = $data_system.words.str parameter_value = actor.str when 4 parameter_name = $data_system.words.dex parameter_value = actor.dex when 5 parameter_name = $data_system.words.agi parameter_value = actor.agi when 6 parameter_name = $data_system.words.int parameter_value = actor.int end self.contents.font.color = system_color self.contents.draw_text(x, y, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2) end def draw_item_name(item, x, y) if item == nil return end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color self.contents.draw_text(x + 28, y, 212, 32, item.name) end end #============================================================================== # module Input #============================================================================== #This Is Izy Module Input Script RGSS... #You May Use this script to active all Izy Code. module Input Key = {'A' => 65, 'B' => 66, 'C' => 67, 'D' => 68, 'E' => 69, 'F' => 70, 'G' => 71, 'H' => 72, 'I' => 73, 'J' => 74, 'K' => 75, 'L' => 76, 'M' => 77, 'N' => 78, 'O' => 79, 'P' => 80, 'Q' => 81, 'R' => 82, 'S' => 83, 'T' => 84, 'U' => 85, 'V' => 86, 'W' => 87, 'X' => 88, 'Y' => 89, 'Z' => 90, '0' => 48, '1' => 49, '2' => 50, '3' => 51, '4' => 52, '5' => 53, '6' => 54, '7' => 55, '8' => 56, '9' => 57, 'NumberPad 0' => 45, 'NumberPad 1' => 35, 'NumberPad 2' => 40, 'NumberPad 3' => 34, 'NumberPad 4' => 37, 'NumberPad 5' => 12, 'NumberPad 6' => 39, 'NumberPad 7' => 36, 'NumberPad 8' => 38, 'NumberPad 9' => 33, 'F1' => 112, 'F2' => 113, 'F3' => 114, 'F4' => 115, 'F5' => 116, 'F6' => 117, 'F7' => 118, 'F8' => 119, 'F9' => 120, 'F10' => 121, 'F11' => 122, 'F12' => 123, ';' => 186, '=' => 187, ',' => 188, '-' => 189, '.' => 190, '/' => 220, '\\' => 191, '\'' => 222, '[' => 219, ']' => 221, '`' => 192, 'Backspace' => 8, 'Tab' => 9, 'Enter' => 13, 'Shift' => 16, 'Left Shift' => 160, 'Right Shift' => 161, 'Left Ctrl' => 162, 'Right Ctrl' => 163, 'Left Alt' => 164, 'Right Alt' => 165, 'Ctrl' => 17, 'Alt' => 18, 'Esc' => 27, 'Space' => 32, 'Page Up' => 33, 'Page Down' => 34, 'End' => 35, 'Home' => 36, 'Insert' => 45, 'Delete' => 46, 'Arrow Left' => 37, 'Arrow Up' => 38, 'Arrow Right' => 39, 'Arrow Down' => 40, 'Mouse Left' => 1, 'Mouse Right' => 2, 'Mouse Middle' => 4, 'Mouse 4' => 5, 'Mouse 5' => 6} UP = [Key['Arrow Up']] LEFT = [Key['Arrow Left']] DOWN = [Key['Arrow Down']] RIGHT = [Key['Arrow Right']] A = [Key['Shift']] B = [Key['Esc'], Key['NumberPad 0'], Key['X']] C = [Key['Space'], Key['Enter'], Key['C']] X = [Key['A']] Y = [Key['S']] Z = [Key['D']] L = [Key['Q'], Key['Page Down']] R = [Key['W'], Key['Page Up']] F5 = [Key['F5']] F6 = [Key['F6']] F7 = [Key['F7']] F8 = [Key['F8']] F9 = [Key['F9']] SHIFT = [Key['Shift']] CTRL = [Key['Ctrl']] ALT = [Key['Alt']] ALL_KEYS = (0...256).to_a GetKeyboardState = Win32API.new('user32','GetKeyboardState', 'P', 'I') GetKeyboardLayout = Win32API.new('user32', 'GetKeyboardLayout','L', 'L') MapVirtualKeyEx = Win32API.new('user32', 'MapVirtualKeyEx', 'IIL', 'I') ToUnicodeEx = Win32API.new('user32', 'ToUnicodeEx', 'LLPPILL', 'L') DOWN_STATE_MASK = 0x80 DEAD_KEY_MASK = 0x80000000 @state = "\0" * 256 @triggered = Array.new(256, false) @pressed = Array.new(256, false) @released = Array.new(256, false) @repeated = Array.new(256, 0) def self.update @language_layout = GetKeyboardLayout.call(0) GetKeyboardState.call(@state) ALL_KEYS.each {|key| if @state[key] & DOWN_STATE_MASK == DOWN_STATE_MASK @released[key] = false if !@pressed[key] @pressed[key] = true @triggered[key] = true else @triggered[key] = false end @repeated[key] < 17 ? @repeated[key] += 1 : @repeated[key] = 15 elsif !@released[key] if @pressed[key] @triggered[key] = false @pressed[key] = false @repeated[key] = 0 @released[key] = true end else @released[key] = false end} end def Input.dir4 return 2 if Input.press?(DOWN) return 4 if Input.press?(LEFT) return 6 if Input.press?(RIGHT) return 8 if Input.press?(UP) return 0 end def Input.dir8 down = Input.press?(DOWN) left = Input.press?(LEFT) return 1 if down && left right = Input.press?(RIGHT) return 3 if down && right up = Input.press?(UP) return 7 if up && left return 9 if up && right return 2 if down return 4 if left return 6 if right return 8 if up return 0 end def Input.trigger?(keys) keys = [keys] unless keys.is_a?(Array) return keys.any? {|key| @triggered[key]} end def Input.press?(keys) keys = [keys] unless keys.is_a?(Array) return keys.any? {|key| @pressed[key]} end def Input.repeat?(keys) keys = [keys] unless keys.is_a?(Array) return keys.any? {|key| @repeated[key] == 1 || @repeated[key] == 16} end def Input.release?(keys) keys = [keys] unless keys.is_a?(Array) return keys.any? {|key| @released[key]} end def self.get_character(vk) c = MapVirtualKeyEx.call(vk, 2, @language_layout) return '' if c < 32 && (c & DEAD_KEY_MASK != DEAD_KEY_MASK) vsc = MapVirtualKeyEx.call(vk, 0, @language_layout) result = "\0" * 2 length = ToUnicodeEx.call(vk, vsc, @state, result, 2, 0, @language_layout) return (length == 0 ? '' : result) end def self.get_input_string result = '' ALL_KEYS.each {|key| if self.repeat?(key) c = self.get_character(key) result += c if c != '' end} return '' if result == '' return self.unicode_to_utf8(result) end def self.unicode_to_utf8(string) result = '' string.unpack('S*').each {|c| if c < 0x0080 result += c.chr elsif c < 0x0800 result += (0xC0 | (c >> 6)).chr result += (0x80 | (c & 0x3F)).chr else result += (0xE0 | (c >> 12)).chr result += (0x80 | ((c >> 12) & 0x3F)).chr result += (0x80 | (c & 0x3F)).chr end} return result end end Pause Script : #============================================================================== # Izyees Pause System Version 1.0 #============================================================================== #============================================================================== # # This is Pause System made by me... # This is for pausing your game while playing. # You can easily press "P" in game to pause. # Please credit me if you use this script. # This script is free for commercial and free game. # # This script not work with any HUD system # This script not work with PIE Menu System # Not test in SDK #============================================================================== # Credit : # Izyees for making this script. #============================================================================== #===========# # Warning ! # #===========#===========# # Izy Core Script need ! #=======================# # To edit the "Pause" window, go to Pause_Window class. # If you want to call the pause use "$scene = Pause.new" # This script will automatically add pause when you pressing P in game play. #============================================================================== # Pause_Window #============================================================================== # This is the pause window class. # You can change, modify and edit this section. #============================================================================== class Pause_Window < Izy_Window # Call the class # this is the pause window def initialize super(0, 0, 100,50) self.contents = Bitmap.new(width-32, height-32) self.contents.font.name = "Arial" # Font name self.contents.font.size = 24 self.contents.draw_text(0, -10, 100, 40, "Pause") # Position and text end end # Scene to call. class Pause def main @window_pause = Pause_Window.new @window_pause.back_opacity = 140 @spriteset = Spriteset_Map.new Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @window_pause.dispose end def update @window_pause.update # This is the button to close the pause window # Change 'P' to 'F12' or something, button to close the window. # To set the "Open" pause window, go to line 218 if Input.trigger?(Input::Key['P']) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end end end #============================================================================== # ** Scene_Map #------------------------------------------------------------------------------ # This class performs map screen processing. #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Make sprite set @spriteset = Spriteset_Map.new # Make message window @message_window = Window_Message.new # Transition run Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of sprite set @spriteset.dispose # Dispose of message window @message_window.dispose # If switching to title screen if $scene.is_a?(Scene_Title) # Fade out screen Graphics.transition Graphics.freeze end end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Loop loop do # Update map, interpreter, and player order # (this update order is important for when conditions are fulfilled # to run any event, and the player isn't provided the opportunity to # move in an instant) $game_map.update $game_system.map_interpreter.update $game_player.update # Update system (timer), screen $game_system.update $game_screen.update # Abort loop if player isn't place moving unless $game_temp.player_transferring break end # Run place move transfer_player # Abort loop if transition processing if $game_temp.transition_processing break end end # Update sprite set @spriteset.update # Update message window @message_window.update # If game over if $game_temp.gameover # Switch to game over screen $scene = Scene_Gameover.new return end # If returning to title screen if $game_temp.to_title # Change to title screen $scene = Scene_Title.new return end # If transition processing if $game_temp.transition_processing # Clear transition processing flag $game_temp.transition_processing = false # Execute transition if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # If showing message window if $game_temp.message_window_showing return end # If encounter list isn't empty, and encounter count is 0 if $game_player.encounter_count == 0 and $game_map.encounter_list != [] # If event is running or encounter is not forbidden unless $game_system.map_interpreter.running? or $game_system.encounter_disabled # Confirm troop n = rand($game_map.encounter_list.size) troop_id = $game_map.encounter_list[n] # If troop is valid if $data_troops[troop_id] != nil # Set battle calling flag $game_temp.battle_calling = true $game_temp.battle_troop_id = troop_id $game_temp.battle_can_escape = true $game_temp.battle_can_lose = false $game_temp.battle_proc = nil end end end # If B button was pressed if Input.trigger?(Input::Key['Esc']) # If event is running, or menu is not forbidden unless $game_system.map_interpreter.running? or $game_system.menu_disabled # Set menu calling flag or beep flag $game_temp.menu_calling = true $game_temp.menu_beep = true end end # If debug mode is ON and F9 key was pressed if $DEBUG and Input.press?(Input::F9) # Set debug calling flag $game_temp.debug_calling = true end # This is where the pause window call, by pressing "P" if Input.trigger?(Input::Key['P']) $scene = Pause.new end # If player is not moving unless $game_player.moving? # Run calling of each screen if $game_temp.battle_calling call_battle elsif $game_temp.shop_calling call_shop elsif $game_temp.name_calling call_name elsif $game_temp.menu_calling call_menu elsif $game_temp.save_calling call_save elsif $game_temp.debug_calling call_debug end end end #-------------------------------------------------------------------------- # * Battle Call #-------------------------------------------------------------------------- def call_battle # Clear battle calling flag $game_temp.battle_calling = false # Clear menu calling flag $game_temp.menu_calling = false $game_temp.menu_beep = false # Make encounter count $game_player.make_encounter_count # Memorize map BGM and stop BGM $game_temp.map_bgm = $game_system.playing_bgm $game_system.bgm_stop # Play battle start SE $game_system.se_play($data_system.battle_start_se) # Play battle BGM $game_system.bgm_play($game_system.battle_bgm) # Straighten player position $game_player.straighten # Switch to battle screen $scene = Scene_Battle.new end #-------------------------------------------------------------------------- # * Shop Call #-------------------------------------------------------------------------- def call_shop # Clear shop call flag $game_temp.shop_calling = false # Straighten player position $game_player.straighten # Switch to shop screen $scene = Scene_Shop.new end #-------------------------------------------------------------------------- # * Name Input Call #-------------------------------------------------------------------------- def call_name # Clear name input call flag $game_temp.name_calling = false # Straighten player position $game_player.straighten # Switch to name input screen $scene = Scene_Name.new end #-------------------------------------------------------------------------- # * Menu Call #-------------------------------------------------------------------------- def call_menu # Clear menu call flag $game_temp.menu_calling = false # If menu beep flag is set if $game_temp.menu_beep # Play decision SE $game_system.se_play($data_system.decision_se) # Clear menu beep flag $game_temp.menu_beep = false end # Straighten player position $game_player.straighten # Switch to menu screen $scene = Scene_Menu.new end #-------------------------------------------------------------------------- # * Save Call #-------------------------------------------------------------------------- def call_save # Straighten player position $game_player.straighten # Switch to save screen $scene = Scene_Save.new end #-------------------------------------------------------------------------- # * Debug Call #-------------------------------------------------------------------------- def call_debug # Clear debug call flag $game_temp.debug_calling = false # Play decision SE $game_system.se_play($data_system.decision_se) # Straighten player position $game_player.straighten # Switch to debug screen $scene = Scene_Debug.new end #-------------------------------------------------------------------------- # * Player Place Move #-------------------------------------------------------------------------- def transfer_player # Clear player place move call flag $game_temp.player_transferring = false # If move destination is different than current map if $game_map.map_id != $game_temp.player_new_map_id # Set up a new map $game_map.setup($game_temp.player_new_map_id) end # Set up player position $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y) # Set player direction case $game_temp.player_new_direction when 2 # down $game_player.turn_down when 4 # left $game_player.turn_left when 6 # right $game_player.turn_right when 8 # up $game_player.turn_up end # Straighten player position $game_player.straighten # Update map (run parallel process event) $game_map.update # Remake sprite set @spriteset.dispose @spriteset = Spriteset_Map.new # If processing transition if $game_temp.transition_processing # Clear transition processing flag $game_temp.transition_processing = false # Execute transition Graphics.transition(20) end # Run automatic change for BGM and BGS set on the map $game_map.autoplay # Frame reset Graphics.frame_reset Input.update end end #end of script How to use ? put the core script above all of script, don't worry it not effect anything. the pause script put above Main script. Edited November 2, 2014 by Izyees Fariz Share this post Link to post Share on other sites
Marked 197 Report post Posted November 3, 2014 What is the purpose of the core script? Is it like a framework for future Izzy scripts? As this is your first script, I'll post this here for your learning http://www.gdunlimited.net/forums/topic/2645-f12-pause-with-image-script/ I don't know much about RGSS except for the scripts I wrote in my youth (it is 10 years old+ these days), but the author was a masterful scripter and his script is considerably shorter than yours. Share this post Link to post Share on other sites
Izyees Fariz 1 Report post Posted November 3, 2014 (edited) The core script for the module input and Window_Base. Only that, I want my own core script too. EDIT: Izzy ? what ??? It's Izy... Edited December 29, 2014 by Izyees Fariz Share this post Link to post Share on other sites