[XP] Advanced Name Input

Started by cyclope, June 29, 2010, 11:15:18 pm

Previous topic - Next topic

cyclope

June 29, 2010, 11:15:18 pm Last Edit: August 03, 2010, 03:16:58 pm by Blizzard
Advanced Scene_name
Authors: Cyclope
Version: 1.0
Type: Advanced name input system
Key Term: Misc System



Introduction
The default name input of rmxp is AWFUL so I searched for a new scene_name. Sadly i didnt found one I liked, so I made one myself. This script is for anyone who wants a beter name input!!


Features
   

  • Allows you to use the keyboard whene choosing a name
  • Shows the map as background
  • Easy to configure instruction window
  • Looks good
  • Plug & Play




Screenshots



Demo
Its not needed but I can post one if someone asks for it :D


Script
Use this one ONLY if you arent ussing blizz abs or Ton od Add-ons
Spoiler: ShowHide

#==============================================================================
#  Modyfied Scene_Name
#  By Cyclope
#------------------------------------------------------------------------------
#´                            Instructions
#   Place above main
#------------------------------------------------------------------------------
#   Credit:
#   Nattmath (For making Scene_Name Leters Modification)
#   Blizzard (For making Custom Cotrols)
#   Cyclope  (For modifying Scene_Name Leters Modification and Scene_Name)            
#==============================================================================

#==============================================================================
# ** Window_Instructions
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Instruction < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor : actor
 #--------------------------------------------------------------------------
 def initialize
   super( 0, 400, 640, 80)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.name = "Arial"
   self.contents.font.size = 18
   self.contents.font.color = normal_color
   #Change this text to whatever instructions u want to have!
   self.contents.draw_text(26, 9, 500, 32, "Enter = OK")
   self.contents.draw_text(128, 9, 500, 32, "Esc/Backspace = Delete")
   self.contents.draw_text(336, 9, 500, 32, "abc... = Text")
   self.contents.draw_text(448, 9, 500, 32, "Shift = Uppercase")
 end
end
#==============================================================================
# ** Window_TextName
#------------------------------------------------------------------------------
#  super ( 224, 32, 224, 80)
#==============================================================================
class Window_TextName < Window_Base
 def initialize
   super ( 224, 32, 224, 80)
   self.contents = Bitmap.new(width - 32, height - 32)
   @actor = $game_actors[$game_temp.name_actor_id]
   refresh
 end
 def refresh
   self.contents.clear
   draw_actor_graphic(@actor, 20, 48)
   self.contents.font.name = "Arial"
   self.contents.font.size = 40
   self.contents.font.color = normal_color
   self.contents.draw_text(64, 0, 96, 32, "Name:")
 end
end

#==============================================================================
# ** Window_NameEdit
#------------------------------------------------------------------------------
#  This window is used to edit your name on the input name screen.
#==============================================================================

class Window_NameEdit < Window_Base

 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor    : actor
 #     max_char : maximum number of characters
 #--------------------------------------------------------------------------
 def initialize(actor, max_char)
   super(16, 128, 608, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   @actor = actor
   @name = actor.name
   @max_char = max_char
   # Fit name within maximum number of characters
   name_array = @name.split(//)[0...@max_char]
   @name = ""
   for i in 0...name_array.size
     @name += name_array[i]
   end
   @default_name = @name
   @index = name_array.size
   refresh
   update_cursor_rect
 end
 #--------------------------------------------------------------------------
 # * Return to Default Name
 #--------------------------------------------------------------------------
 def restore_default
   @name = @default_name
   @index = @name.split(//).size
   refresh
   update_cursor_rect
 end
 #--------------------------------------------------------------------------
 # * Add Character
 #     character : text character to be added
 #--------------------------------------------------------------------------
 def add(character)
   if @index < @max_char and character != ""
     @name += character
     @index += 1
     refresh
     update_cursor_rect
   end
 end
 #--------------------------------------------------------------------------
 # * Delete Character
 #--------------------------------------------------------------------------
 def back
   if @index > 0
     # Delete 1 text character
     name_array = @name.split(//)
     @name = ""
     for i in 0...name_array.size-1
       @name += name_array[i]
     end
     @index -= 1
     refresh
     update_cursor_rect
   end
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh  
   self.contents.clear
   # Draw name
   self.contents.font.size = 42
   name_array = @name.split(//)
   for i in 0...@max_char
     c = name_array[i]
     if c == nil
       c = "_"
     end
     x = 304 - @max_char * 14 + i * 26
     self.contents.draw_text(x, 15, 28, 42, c, 1)
   end
 end
 #--------------------------------------------------------------------------
 # * Cursor Rectangle Update
 #--------------------------------------------------------------------------
 def update_cursor_rect
   x = 304 - @max_char * 14 + @index * 26
   self.cursor_rect.set(x, 55, 20, 5)
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
  super
  update_cursor_rect
end
end


#==============================================================================
# ** Window_NameInput
#------------------------------------------------------------------------------
#  This window is used to select text characters on the input name screen.
#==============================================================================

class Window_NameInput < Window_Base
 CHARACTER_TABLE =
 [    
   "", ""
   
 ]
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 128, 640, 0)
   self.contents = Bitmap.new(width - 32, height - 32)
   @index = 0
   refresh
 end
 #--------------------------------------------------------------------------
 # * Text Character Acquisition
 #--------------------------------------------------------------------------
 def character
   return CHARACTER_TABLE[@index]
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
 end

 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   super
 end
end
#==============================================================================
# ** Scene_Name
#------------------------------------------------------------------------------
#  This class performs name input screen processing.
#==============================================================================

class Scene_Name
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Get actor
   @actor = $game_actors[$game_temp.name_actor_id]
   # Make windows
   @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
   @edit_window.back_opacity = 160
   @input_window = Window_NameInput.new
   @inst_window = Window_Instruction.new
   @inst_window.back_opacity = 160
   @nametext_window = Window_TextName.new
   @nametext_window.back_opacity = 160
   @spriteset = Spriteset_Map.new
   # Execute transition
   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 windows
   @edit_window.dispose
   @input_window.dispose
   @inst_window.dispose
   @nametext_window.dispose
   @spriteset.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @edit_window.update
   @input_window.update
   @nametext_window.update
   @inst_window.update
   # If C button was pressed
   if Input.trigger?(Input::C)
     # If cursor position is at [OK]
     if @input_window.character == nil
       # If name is empty
       if @edit_window.name == ""
         # If name is empty
         if @edit_window.name == ""
           # Play buzzer SE
           $game_system.se_play($data_system.buzzer_se)
           return
         end
         # Play decision SE
         $game_system.se_play($data_system.decision_se)
         return
       end
       # Change actor name
       @actor.name = @edit_window.name
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to map screen
       $scene = Scene_Map.new
       return
     end
     # If cursor position is at maximum
     if @edit_window.index == $game_temp.name_max_char
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # If text character is empty
     if @input_window.character == ""
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # Play decision SE
     $game_system.se_play($data_system.decision_se)
     # Add text character
     @edit_window.add(@input_window.character)
     return
   end
 end
end

#==============================================================================
# module Input
#==============================================================================

module Input
 
 #----------------------------------------------------------------------------
 # Simple ASCII table
 #----------------------------------------------------------------------------
 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}
 # default button configuration
 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
 ALL_KEYS = (0...256).to_a
 # Win32 API calls
 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')
 # some other constants
 DOWN_STATE_MASK = 0x80
 DEAD_KEY_MASK = 0x80000000
 # data
 @state = "\0" * 256
 @triggered = Array.new(256, false)
 @pressed = Array.new(256, false)
 @released = Array.new(256, false)
 @repeated = Array.new(256, 0)
 #----------------------------------------------------------------------------
 # update
 #  Updates input.
 #----------------------------------------------------------------------------
 def self.update
   # get current language layout
   @language_layout = GetKeyboardLayout.call(0)
   # get new keyboard state
   GetKeyboardState.call(@state)
   # for each key
   ALL_KEYS.each {|key|
       # if pressed state
       if @state[key] & DOWN_STATE_MASK == DOWN_STATE_MASK
         # not released anymore
         @released[key] = false
         # if not pressed yet
         if !@pressed[key]
           # pressed and triggered
           @pressed[key] = true
           @triggered[key] = true
         else
           # not triggered anymore
           @triggered[key] = false
         end
         # update of repeat counter
         @repeated[key] < 17 ? @repeated[key] += 1 : @repeated[key] = 15
       # not released yet
       elsif !@released[key]
         # if still pressed
         if @pressed[key]
           # not triggered, pressed or repeated, but released
           @triggered[key] = false
           @pressed[key] = false
           @repeated[key] = 0
           @released[key] = true
         end
       else
         # not released anymore
         @released[key] = false
       end}
 end
 #----------------------------------------------------------------------------
 # dir4
 #  4 direction check.
 #----------------------------------------------------------------------------
 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
 #----------------------------------------------------------------------------
 # dir8
 #  8 direction check.
 #----------------------------------------------------------------------------
 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
 #----------------------------------------------------------------------------
 # trigger?
 #  Test if key was triggered once.
 #----------------------------------------------------------------------------
 def Input.trigger?(keys)
   keys = [keys] unless keys.is_a?(Array)
   return keys.any? {|key| @triggered[key]}
 end
 #----------------------------------------------------------------------------
 # press?
 #  Test if key is being pressed.
 #----------------------------------------------------------------------------
 def Input.press?(keys)
   keys = [keys] unless keys.is_a?(Array)
   return keys.any? {|key| @pressed[key]}
 end
 #----------------------------------------------------------------------------
 # repeat?
 #  Test if key is being pressed for repeating.
 #----------------------------------------------------------------------------
 def Input.repeat?(keys)
   keys = [keys] unless keys.is_a?(Array)
   return keys.any? {|key| @repeated[key] == 1 || @repeated[key] == 16}
 end
 #----------------------------------------------------------------------------
 # release?
 #  Test if key was released.
 #----------------------------------------------------------------------------
 def Input.release?(keys)
   keys = [keys] unless keys.is_a?(Array)
   return keys.any? {|key| @released[key]}
 end
 #----------------------------------------------------------------------------
 # get_character
 #  vk - virtual key
 #  Gets the character from keyboard input using the input locale identifier
 #  (formerly called keyboard layout handles).
 #----------------------------------------------------------------------------
 def self.get_character(vk)
   # get corresponding character from virtual key
   c = MapVirtualKeyEx.call(vk, 2, @language_layout)
   # stop if character is non-printable and not a dead key
   return '' if c < 32 && (c & DEAD_KEY_MASK != DEAD_KEY_MASK)
   # get scan code
   vsc = MapVirtualKeyEx.call(vk, 0, @language_layout)
   # result string is never longer than 2 bytes (Unicode)
   result = "\0" * 2
   # get input string from Win32 API
   length = ToUnicodeEx.call(vk, vsc, @state, result, 2, 0, @language_layout)
   return (length == 0 ? '' : result)
 end
 #----------------------------------------------------------------------------
 # get_input_string
 #  Gets the string that was entered using the keyboard over the input locale
 #  identifier (formerly called keyboard layout handles).
 #----------------------------------------------------------------------------
 def self.get_input_string
   result = ''
   # check every key
   ALL_KEYS.each {|key|
       # if repeated
       if self.repeat?(key)
         # get character from keyboard state
         c = self.get_character(key)
         # add character if there is a character
         result += c if c != ''
       end}
   # empty if result is empty
   return '' if result == ''
   # convert string from Unicode to UTF-8
   return self.unicode_to_utf8(result)
 end
 #----------------------------------------------------------------------------
 # get_input_string
 #  string - string in Unicode format
 #  Converts a string from Unicode format to UTF-8 format as RGSS does not
 #  support Unicode.
 #----------------------------------------------------------------------------
 def self.unicode_to_utf8(string)
   result = ''
   string.unpack('S*').each {|c|
       # characters under 0x80 are 1 byte characters
       if c < 0x0080
         result += c.chr
       # other characters under 0x800 are 2 byte characters
       elsif c < 0x0800
         result += (0xC0 | (c >> 6)).chr
         result += (0x80 | (c & 0x3F)).chr
       # the rest are 3 byte characters
       else
         result += (0xE0 | (c >> 12)).chr
         result += (0x80 | ((c >> 12) & 0x3F)).chr
         result += (0x80 | (c & 0x3F)).chr
       end}
   return result
 end
 
end

#==============================================================================
# ** Scene_Name Leters Modification Made By Nattmath and Improved Cyclope
#------------------------------------------------------------------------------
#  Makes you imput stuf with the keyboard
#==============================================================================
class Scene_Name
 
 alias name_input_update update
 def update
   (65...91).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     let = let.downcase unless Input.press?(Input::Key['Shift'])
     @edit_window.add(let)
   end}
   (48...58).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     @edit_window.add(let)
   end}
   (186...192).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     @edit_window.add(let)
   end}
   (219...222).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     @edit_window.add(let)
   end}
   if Input.trigger?(Input::Key['Backspace'])
     @edit_window.back
   end
   if Input.trigger?(Input::Key['Arrow Left'])
     @edit_window.back
   end
   if Input.trigger?(Input::Key['Enter'])
       # If name is empty
       if @edit_window.name == ""
         # Return to default name
         @edit_window.restore_default
         # If name is empty
         if @edit_window.name == ""
           # Play buzzer SE
           $game_system.se_play($data_system.buzzer_se)
           return
         end
         # Play decision SE
         $game_system.se_play($data_system.decision_se)
         return
       end
       # Change actor name
       @actor.name = @edit_window.name
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to map screen
       $scene = Scene_Map.new
   end
   if Input.trigger?(Input::Key['Space'])
     @actor.name = @edit_window.name
     $game_system.se_play($data_system.decision_se)
     @edit_window.add(" ")
   end
   name_input_update
 end
end

Use this one if you ARE ussing Blizz ABS, RMXOS or Ton of Add-ons(If you are ussing Ton of Add-ons be sure to have Custum controls by blizzard on)
Spoiler: ShowHide

#==============================================================================
#  Modyfied Scene_Name
#  By Cyclope
#------------------------------------------------------------------------------
#´                            Instructions
#   Place above main
#------------------------------------------------------------------------------
#   Credit:
#   Nattmath (For making Scene_Name Leters Modification)
#   Blizzard (For making Custom Cotrols)
#   Cyclope  (For modifying Scene_Name Leters Modification and Scene_Name)            
#==============================================================================

#==============================================================================
# ** Window_Instructions
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Instruction < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor : actor
 #--------------------------------------------------------------------------
 def initialize
   super( 0, 400, 640, 80)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.name = "Arial"
   self.contents.font.size = 18
   self.contents.font.color = normal_color
   #Change this text to whatever instructions u want to have!
   self.contents.draw_text(26, 9, 500, 32, "Enter = OK")
   self.contents.draw_text(128, 9, 500, 32, "Esc/Backspace = Delete")
   self.contents.draw_text(336, 9, 500, 32, "abc... = Text")
   self.contents.draw_text(448, 9, 500, 32, "Shift = Uppercase")
 end
end
#==============================================================================
# ** Window_TextName
#------------------------------------------------------------------------------
#  super ( 224, 32, 224, 80)
#==============================================================================
class Window_TextName < Window_Base
 def initialize
   super ( 224, 32, 224, 80)
   self.contents = Bitmap.new(width - 32, height - 32)
   @actor = $game_actors[$game_temp.name_actor_id]
   refresh
 end
 def refresh
   self.contents.clear
   draw_actor_graphic(@actor, 20, 48)
   self.contents.font.name = "Arial"
   self.contents.font.size = 40
   self.contents.font.color = normal_color
   self.contents.draw_text(64, 0, 96, 32, "Name:")
 end
end

#==============================================================================
# ** Window_NameEdit
#------------------------------------------------------------------------------
#  This window is used to edit your name on the input name screen.
#==============================================================================

class Window_NameEdit < Window_Base

 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor    : actor
 #     max_char : maximum number of characters
 #--------------------------------------------------------------------------
 def initialize(actor, max_char)
   super(16, 128, 608, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   @actor = actor
   @name = actor.name
   @max_char = max_char
   # Fit name within maximum number of characters
   name_array = @name.split(//)[0...@max_char]
   @name = ""
   for i in 0...name_array.size
     @name += name_array[i]
   end
   @default_name = @name
   @index = name_array.size
   refresh
   update_cursor_rect
 end
 #--------------------------------------------------------------------------
 # * Return to Default Name
 #--------------------------------------------------------------------------
 def restore_default
   @name = @default_name
   @index = @name.split(//).size
   refresh
   update_cursor_rect
 end
 #--------------------------------------------------------------------------
 # * Add Character
 #     character : text character to be added
 #--------------------------------------------------------------------------
 def add(character)
   if @index < @max_char and character != ""
     @name += character
     @index += 1
     refresh
     update_cursor_rect
   end
 end
 #--------------------------------------------------------------------------
 # * Delete Character
 #--------------------------------------------------------------------------
 def back
   if @index > 0
     # Delete 1 text character
     name_array = @name.split(//)
     @name = ""
     for i in 0...name_array.size-1
       @name += name_array[i]
     end
     @index -= 1
     refresh
     update_cursor_rect
   end
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh  
   self.contents.clear
   # Draw name
   self.contents.font.size = 42
   name_array = @name.split(//)
   for i in 0...@max_char
     c = name_array[i]
     if c == nil
       c = "_"
     end
     x = 304 - @max_char * 14 + i * 26
     self.contents.draw_text(x, 15, 28, 42, c, 1)
   end
 end
 #--------------------------------------------------------------------------
 # * Cursor Rectangle Update
 #--------------------------------------------------------------------------
 def update_cursor_rect
   x = 320 - @max_char * 14 + @index * 26
   self.cursor_rect.set(x, 55, 20, 5)
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
  super
  update_cursor_rect
end
end


#==============================================================================
# ** Window_NameInput
#------------------------------------------------------------------------------
#  This window is used to select text characters on the input name screen.
#==============================================================================

class Window_NameInput < Window_Base
 CHARACTER_TABLE =
 [    
   "", ""
   
 ]
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 128, 640, 0)
   self.contents = Bitmap.new(width - 32, height - 32)
   @index = 0
   refresh
 end
 #--------------------------------------------------------------------------
 # * Text Character Acquisition
 #--------------------------------------------------------------------------
 def character
   return CHARACTER_TABLE[@index]
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
 end

 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   super
 end
end
#==============================================================================
# ** Scene_Name
#------------------------------------------------------------------------------
#  This class performs name input screen processing.
#==============================================================================

class Scene_Name
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Get actor
   @actor = $game_actors[$game_temp.name_actor_id]
   # Make windows
   @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
   @edit_window.back_opacity = 160
   @input_window = Window_NameInput.new
   @inst_window = Window_Instruction.new
   @inst_window.back_opacity = 160
   @nametext_window = Window_TextName.new
   @nametext_window.back_opacity = 160
   @spriteset = Spriteset_Map.new
   # Execute transition
   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 windows
   @edit_window.dispose
   @input_window.dispose
   @inst_window.dispose
   @nametext_window.dispose
   @spriteset.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @edit_window.update
   @input_window.update
   @nametext_window.update
   @inst_window.update
   # If C button was pressed
   if Input.trigger?(Input::C)
     # If cursor position is at [OK]
     if @input_window.character == nil
       # If name is empty
       if @edit_window.name == ""
         # If name is empty
         if @edit_window.name == ""
           # Play buzzer SE
           $game_system.se_play($data_system.buzzer_se)
           return
         end
         # Play decision SE
         $game_system.se_play($data_system.decision_se)
         return
       end
       # Change actor name
       @actor.name = @edit_window.name
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to map screen
       $scene = Scene_Map.new
       return
     end
     # If cursor position is at maximum
     if @edit_window.index == $game_temp.name_max_char
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # If text character is empty
     if @input_window.character == ""
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # Play decision SE
     $game_system.se_play($data_system.decision_se)
     # Add text character
     @edit_window.add(@input_window.character)
     return
   end
 end
end
#==============================================================================
# ** Scene_Name Leters Modification Made By Nattmath and Improved Cyclope
#------------------------------------------------------------------------------
#  Makes you imput stuf with the keyboard
#==============================================================================
class Scene_Name
 
 alias name_input_update update
 def update
   (65...91).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     let = let.downcase unless Input.press?(Input::Key['Shift'])
     @edit_window.add(let)
   end}
   (48...58).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     @edit_window.add(let)
   end}
   (186...192).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     @edit_window.add(let)
   end}
   (219...222).each{|i|
   if Input.trigger?(i)
     $game_system.se_play($data_system.decision_se)
     let = Input::Key.index(i)
     @edit_window.add(let)
   end}
   if Input.trigger?(Input::Key['Backspace'])
     @edit_window.back
   end
   if Input.trigger?(Input::Key['Arrow Left'])
     @edit_window.back
   end
   if Input.trigger?(Input::Key['Enter'])
       # If name is empty
       if @edit_window.name == ""
         # Return to default name
         @edit_window.restore_default
         # If name is empty
         if @edit_window.name == ""
           # Play buzzer SE
           $game_system.se_play($data_system.buzzer_se)
           return
         end
         # Play decision SE
         $game_system.se_play($data_system.decision_se)
         return
       end
       # Change actor name
       @actor.name = @edit_window.name
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to map screen
       $scene = Scene_Map.new
   end
   if Input.trigger?(Input::Key['Space'])
     @actor.name = @edit_window.name
     $game_system.se_play($data_system.decision_se)
     @edit_window.add(" ")
   end
   name_input_update
 end
end



Instructions
Just place above main  :)


Compatibility
Not tested with SDK


Credits and Thanks


  • Cyclope(for creating the script
  • Nattmath(for making the keyboard imput script)
  • Blizzard (for making Custom Controlls script)



Author's Notes
This is my first script! If you find any bug or have a suggestion please let me know :^_^':
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

Silentknight72

*LVLsUP!* thanks!, but can you move while doing that?
Sigs: ShowHide






cyclope

You cant move while doing it, it just shows the map as backgroung for it to look beter :D
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

Blizzard

I was about to ask if it handles language locale identifier modified input when I realized that you were using my input module. xD Nice job. :)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Lethal-Yarn

Very awesome.  I really like this!

nathmatt

@Blizzard the fact that you put all the keys in a hash helped to .index
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


stripe103

I guess you could have worked on the placement of the text a bit more but I really like it! :D

cyclope

July 02, 2010, 10:15:18 pm #7 Last Edit: July 02, 2010, 11:04:36 pm by cyclope
Quote from: stripe103 on July 01, 2010, 01:17:08 pm
I guess you could have worked on the placement of the text a bit more but I really like it! :D

Do you mean in the placement of the text of the instructions or the place where the text apear when you type it?
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

stripe103

July 03, 2010, 05:16:21 am #8 Last Edit: July 03, 2010, 05:20:16 am by stripe103
Both. To me it seems as the top window have the text a bit lower than the middle, and the lower window have different space between the text rows.

Something like this:
It is the one with Blizz-ABS, RMX-OS or Tons of Addons
Script: ShowHide
#==============================================================================
#  Modyfied Scene_Name
#  By Cyclope
#------------------------------------------------------------------------------
#´                            Instructions
#   Place above main
#------------------------------------------------------------------------------
#   Credit:
#   Nattmath (For making Scene_Name Leters Modification)
#   Blizzard (For making Custom Cotrols)
#   Cyclope  (For modifying Scene_Name Leters Modification and Scene_Name)           
#==============================================================================

#==============================================================================
# ** Window_Instructions
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Instruction < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(80, 250, 400, 168)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.name = "Arial"
    self.contents.font.size = 31
    self.contents.font.color = normal_color
    #Change this text to whatever instructions u want to have!
    self.contents.draw_text(10, 0, 500, 32, "Enter = OK")
    self.contents.draw_text(10, 32, 500, 32, "Esc or Backspace = Delete")
    self.contents.draw_text(10, 64, 500, 32, "abc... = Text")
    self.contents.draw_text(10, 96, 500, 32, "Shift = Uppercase")
  end
end

#==============================================================================
# ** Window_NameEdit
#------------------------------------------------------------------------------
#  This window is used to edit your name on the input name screen.
#==============================================================================

class Window_NameEdit < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :name                     # name
  attr_reader   :index                    # cursor position
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor    : actor
  #     max_char : maximum number of characters
  #--------------------------------------------------------------------------
  def initialize(actor, max_char)
    super(10, 100, 620,100)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    @name = actor.name
    @max_char = max_char
    # Fit name within maximum number of characters
    name_array = @name.split(//)[0...@max_char]
    @name = ""
    for i in 0...name_array.size
      @name += name_array[i]
    end
    @default_name = @name
    @index = name_array.size
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Return to Default Name
  #--------------------------------------------------------------------------
  def restore_default
    @name = @default_name
    @index = @name.split(//).size
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Add Character
  #     character : text character to be added
  #--------------------------------------------------------------------------
  def add(character)
    if @index < @max_char and character != ""
      @name += character
      @index += 1
      refresh
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  # * Delete Character
  #--------------------------------------------------------------------------
  def back
    if @index > 0
      # Delete 1 text character
      name_array = @name.split(//)
      @name = ""
      for i in 0...name_array.size-1
        @name += name_array[i]
      end
      @index -= 1
      refresh
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh   
    self.contents.clear
    # Draw name
    self.contents.font.size = 42
    name_array = @name.split(//)
    for i in 0...@max_char
      c = name_array[i]
      if c == nil
        c = "_"
      end
      x = 320 - @max_char * 12 + i * 20
      self.contents.draw_text(x, 15, 28, 42, c, 1)
    end
    # Draw text
    self.contents.draw_text(30, 15, 100, 42, "Name:")
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    x = 320 - @max_char * 12 + @index * 20
    self.cursor_rect.set(x, 55, 20, 5)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
   super
   update_cursor_rect
end
end


#==============================================================================
# ** Window_NameInput
#------------------------------------------------------------------------------
#  This window is used to select text characters on the input name screen.
#==============================================================================

class Window_NameInput < Window_Base
  CHARACTER_TABLE =
  [   
    "", ""
   
  ]
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 128, 640, 0)
    self.contents = Bitmap.new(width - 32, height - 32)
    @index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Text Character Acquisition
  #--------------------------------------------------------------------------
  def character
    return CHARACTER_TABLE[@index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
  end

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
  end
end
#==============================================================================
# ** Scene_Name
#------------------------------------------------------------------------------
#  This class performs name input screen processing.
#==============================================================================

class Scene_Name
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_actors[$game_temp.name_actor_id]
    # Make windows
    @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
    @edit_window.back_opacity = 160
    @input_window = Window_NameInput.new
    @inst_window = Window_Instruction.new
    @inst_window.back_opacity = 160
    @spriteset = Spriteset_Map.new
    # Execute transition
    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 windows
    @edit_window.dispose
    @input_window.dispose
    @inst_window.dispose
    @spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @edit_window.update
    @input_window.update
    @inst_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If cursor position is at [OK]
      if @input_window.character == nil
        # If name is empty
        if @edit_window.name == ""
          # Return to default name
          @edit_window.restore_default
          # If name is empty
          if @edit_window.name == ""
            # Play buzzer SE
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          return
        end
        # Change actor name
        @actor.name = @edit_window.name
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
      # If cursor position is at maximum
      if @edit_window.index == $game_temp.name_max_char
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If text character is empty
      if @input_window.character == ""
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Add text character
      @edit_window.add(@input_window.character)
      return
    end
  end
end
#==============================================================================
# ** Scene_Name Leters Modification Made By Nattmath and Improved Cyclope
#------------------------------------------------------------------------------
#  Makes you imput stuf with the keyboard
#==============================================================================
class Scene_Name
 
  alias name_input_update update
  def update
    (65...91).each{|i|
    if Input.trigger?(i)
      $game_system.se_play($data_system.decision_se)
      let = Input::Key.index(i)
      let = let.downcase unless Input.press?(Input::Key['Shift'])
      @edit_window.add(let)
    end}
    (48...58).each{|i|
    if Input.trigger?(i)
      $game_system.se_play($data_system.decision_se)
      let = Input::Key.index(i)
      @edit_window.add(let)
    end}
    (186...192).each{|i|
    if Input.trigger?(i)
      $game_system.se_play($data_system.decision_se)
      let = Input::Key.index(i)
      @edit_window.add(let)
    end}
    (219...222).each{|i|
    if Input.trigger?(i)
      $game_system.se_play($data_system.decision_se)
      let = Input::Key.index(i)
      @edit_window.add(let)
    end}
    if Input.trigger?(Input::Key['Backspace'])
      @edit_window.back
    end
    if Input.trigger?(Input::Key['Enter'])
      @actor.name = @edit_window.name
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Switch to map screen
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::Key['Space'])
      @actor.name = @edit_window.name
      $game_system.se_play($data_system.decision_se)
      @edit_window.add(" ")
    end
    name_input_update
  end
end

cyclope

edit: changed the position af instruction window and make some small modifications : :haha:
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

stripe103

That was a really nice improvement. Like it!

cyclope

 :???:  ¿¿¿¿¿¿Does any one have any suggestion????? :???:
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

cyclope

Since no one found any bug or has a suggestion now its ver.1
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

mattfriends

Whoa...  I will use that in the future. That's so great!!!

cyclope

Thanks, just dont forget to give credit
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

mattfriends

I would say it's very simple and very good in the same time.  :haha:

cyclope

yey! finally moved to the database!!!! :dance:
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

Shalaren

hhh lol, good scripit :P it'll be very usful for my game

WhiteRose

This is a good script, but it would make it even better if you added compatibility with facesets from Tons of Addons, which would probably be fairly simple.

cyclope

does it hav incompability issues with it?????
Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?