simple map script

Draw_map(dont know what else to call it)Version:1
By: Plague180

Introduction

This script allows u to press m on the key board(or any other letter if u want)and call a picture from your picture folder called map.png. i know this might seem over simple(or there might be a easier way), but my freind wanted me to post it for him, and i hope some one else could use this little peice of code. let me know, even if its negitive. Go navy!
Demo

http://www.megaupload.com/?d=K4MF5Q59

Script

Cybersam's input script(required)
  1. #==============================================================================
  2. # Keyboard Input Module
  3. #----------------------------------------------------------------------------
  4. # Script by Cybersam
  5. #==============================================================================
  6.  
  7. module Input
  8.   @keys = []
  9.   @pressed = []
  10.   Mouse_Left = 1
  11.   Mouse_Right = 2
  12.   Mouse_Middle = 4
  13.   Back= 8
  14.   Tab = 9
  15.   Enter = 13
  16.   Shift = 16
  17.   Ctrl = 17
  18.   Alt = 18
  19.   Esc = 27
  20.   Space = 32
  21.   Numberkeys = {}
  22.   Numberkeys[0] = 48        # => 0
  23.   Numberkeys[1] = 49        # => 1
  24.   Numberkeys[2] = 50        # => 2
  25.   Numberkeys[3] = 51        # => 3
  26.   Numberkeys[4] = 52        # => 4
  27.   Numberkeys[5] = 53        # => 5
  28.   Numberkeys[6] = 54        # => 6
  29.   Numberkeys[7] = 55        # => 7
  30.   Numberkeys[8] = 56        # => 8
  31.   Numberkeys[9] = 57        # => 9
  32.   Numberpad = {}
  33.   Numberpad[0] = 45
  34.   Numberpad[1] = 35
  35.   Numberpad[2] = 40
  36.   Numberpad[3] = 34
  37.   Numberpad[4] = 37
  38.   Numberpad[5] = 12
  39.   Numberpad[6] = 39
  40.   Numberpad[7] = 36
  41.   Numberpad[8] = 38
  42.   Numberpad[9] = 33
  43.   Letters = {}
  44.   Letters["A"] = 65
  45.   Letters["B"] = 66
  46.   Letters["C"] = 67
  47.   Letters["D"] = 68
  48.   Letters["E"] = 69
  49.   Letters["F"] = 70
  50.   Letters["G"] = 71
  51.   Letters["H"] = 72
  52.   Letters["I"] = 73
  53.   Letters["J"] = 74
  54.   Letters["K"] = 75
  55.   Letters["L"] = 76
  56.   Letters["M"] = 77
  57.   Letters["N"] = 78
  58.   Letters["O"] = 79
  59.   Letters["P"] = 80
  60.   Letters["Q"] = 81
  61.   Letters["R"] = 82
  62.   Letters["S"] = 83
  63.   Letters["T"] = 84
  64.   Letters["U"] = 85
  65.   Letters["V"] = 86
  66.   Letters["W"] = 87
  67.   Letters["X"] = 88
  68.   Letters["Y"] = 89
  69.   Letters["Z"] = 90
  70.   Fkeys = {}
  71.   Fkeys[1] = 112
  72.   Fkeys[2] = 113
  73.   Fkeys[3] = 114
  74.   Fkeys[4] = 115
  75.   Fkeys[5] = 116
  76.   Fkeys[6] = 117
  77.   Fkeys[7] = 118
  78.   Fkeys[8] = 119
  79.   Fkeys[9] = 120
  80.   Fkeys[10] = 121
  81.   Fkeys[11] = 122
  82.   Fkeys[12] = 123
  83.   Collon = 186        # => \ |
  84.   Equal = 187         # => = +
  85.   Comma = 188         # => , <
  86.   Underscore = 189    # => - _
  87.   Dot = 190           # => . >
  88.   Backslash = 191     # => / ?
  89.   Lb = 219
  90.   Rb = 221
  91.   Quote = 222         # => '"
  92.   #-------------------------------------------------------------------------------
  93.   USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle]
  94.   #-------------------------------------------------------------------------------
  95.  
  96. module_function
  97.   #--------------------------------------------------------------------------
  98.   def triggered?(key)
  99.     Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   def check(key)
  103.     Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   def pressed?(key)
  107.     return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)
  108.     return false
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   def mouse_update
  112.     @used_i = []
  113.     for i in USED_KEYS
  114.       x = check(i)
  115.       if x == true
  116.         @used_i.push(i)
  117.       end
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   def self.C
  122.     self.trigger?(C)
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   def self.B
  126.     self.trigger?(B)
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   def self.A
  130.     self.trigger?(A)
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   def self.Down
  134.     self.trigger?(DOWN)
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   def self.Up
  138.     self.trigger?(UP)
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   def self.Right
  142.     self.trigger?(RIGHT)
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   def self.Left
  146.     self.trigger?(LEFT)
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   def self.Anykey
  150.     if A or B or C or Down or Up or Right or Left
  151.       return true
  152.     else
  153.       return false
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157. end
  158.  
Expand to see the code.

Scene_Map Edit
  1. #==============================================================================
  2. # ** Scene_Map
  3. #------------------------------------------------------------------------------
  4. #  This class performs map screen processing.
  5. #==============================================================================
  6.  
  7. class Scene_Map
  8.   CALL_KEY = Input::Letters["M"]#used to choose which key calls the map
  9.   def update
  10.     # Loop
  11.     loop do
  12.       # Update map, interpreter, and player order
  13.       # (this update order is important for when conditions are fulfilled
  14.       # to run any event, and the player isn't provided the opportunity to
  15.       # move in an instant)
  16.       $game_map.update
  17.       $game_system.map_interpreter.update
  18.       $game_player.update
  19.       # Update system (timer), screen
  20.       $game_system.update
  21.       $game_screen.update
  22.       # Abort loop if player isn't place moving
  23.       unless $game_temp.player_transferring
  24.         break
  25.       end
  26.       # Run place move
  27.       transfer_player
  28.       # Abort loop if transition processing
  29.       if $game_temp.transition_processing
  30.         break
  31.       end
  32.     end
  33.     # Update sprite set
  34.     @spriteset.update
  35.     # Update message window
  36.     @message_window.update
  37.     # If game over
  38.     if $game_temp.gameover
  39.       # Switch to game over screen
  40.       $scene = Scene_Gameover.new
  41.       return
  42.     end
  43.     # If returning to title screen
  44.     if $game_temp.to_title
  45.       # Change to title screen
  46.       $scene = Scene_Title.new
  47.       return
  48.     end
  49.     # If transition processing
  50.     if $game_temp.transition_processing
  51.       # Clear transition processing flag
  52.       $game_temp.transition_processing = false
  53.       # Execute transition
  54.       if $game_temp.transition_name == ""
  55.         Graphics.transition(20)
  56.       else
  57.         Graphics.transition(40, "Graphics/Transitions/" +
  58.           $game_temp.transition_name)
  59.       end
  60.     end
  61.     # If showing message window
  62.     if $game_temp.message_window_showing
  63.       return
  64.     end
  65.     # If encounter list isn't empty, and encounter count is 0
  66.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  67.       # If event is running or encounter is not forbidden
  68.       unless $game_system.map_interpreter.running? or
  69.              $game_system.encounter_disabled
  70.         # Confirm troop
  71.         n = rand($game_map.encounter_list.size)
  72.         troop_id = $game_map.encounter_list[n]
  73.         # If troop is valid
  74.         if $data_troops[troop_id] != nil
  75.           # Set battle calling flag
  76.           $game_temp.battle_calling = true
  77.           $game_temp.battle_troop_id = troop_id
  78.           $game_temp.battle_can_escape = true
  79.           $game_temp.battle_can_lose = false
  80.           $game_temp.battle_proc = nil
  81.         end
  82.       end
  83.     end
  84.     # If B button was pressed
  85.     if Input.trigger?(Input::B)
  86.       # If event is running, or menu is not forbidden
  87.       unless $game_system.map_interpreter.running? or
  88.              $game_system.menu_disabled
  89.         # Set menu calling flag or beep flag
  90.         $game_temp.menu_calling = true
  91.         $game_temp.menu_beep = true
  92.       end
  93.     end
  94.     # If debug mode is ON and F9 key was pressed
  95.     if $DEBUG and Input.press?(Input::F9)
  96.       # Set debug calling flag
  97.       $game_temp.debug_calling = true
  98.     end
  99.     # If player is not moving
  100.     unless $game_player.moving?
  101.       # Run calling of each screen
  102.       if $game_temp.battle_calling
  103.         call_battle
  104.       elsif $game_temp.shop_calling
  105.         call_shop
  106.       elsif $game_temp.name_calling
  107.         call_name
  108.       elsif $game_temp.menu_calling
  109.         call_menu
  110.       elsif $game_temp.save_calling
  111.         call_save
  112.       elsif $game_temp.debug_calling
  113.         call_debug
  114.       end
  115.     end
  116.     if Input.pressed?(CALL_KEY)     #draws the map
  117.       $scene = Scene_Draw_Map.new("map.png")
  118.     end
  119.   end
  120. end  
Expand to see the code.

Scene_Draw_Map
  1. class Scene_Draw_Map
  2.   def initialize(name)
  3.     name = name.to_s
  4.     @sprite = Sprite.new
  5.        @sprite.bitmap = RPG::Cache.picture(name)
  6.   end
  7.   #--------------------------------------------------------------------------
  8.   # * Main Processing
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     # Execute transition
  12.     Graphics.transition
  13.     # Main loop
  14.     loop do
  15.       # Update game screen
  16.       Graphics.update
  17.       # Update input information
  18.       Input.update
  19.       # Frame update
  20.       update
  21.       # Abort loop if screen is changed
  22.       if $scene != self
  23.         break
  24.       end
  25.     end
  26.     # Prepare for transition
  27.     Graphics.freeze
  28.   end
  29.   def update
  30.     # If B button was pressed
  31.     if Input.trigger?(Input::B)
  32.       # Play cancel SE
  33.       $game_system.se_play($data_system.cancel_se)
  34.       # Switch to menu screen
  35.       $scene = Scene_Map.new
  36.       return
  37.     end
  38.   end
  39. end
  40.  
Expand to see the code.




Instructions

plug and play :) just put the scripts in order(input, Scene_map, Scene_Draw_Map) above main and under Scene_map(original)


Compatibility

i have not had any probelms with it, but i think it may have issues with some custom menus.

since i change the update for scene map i guess it could cause problems, but i dont think it will because all i did was make it check for the letter "m" being pressed

Credits and Thanks

Cybersam for the input script

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=67558