02-12-2007, 01:00 PM
CNS (Custom Name System)
by samo
Feb 12 2007
INSTRUCTIONS:
-------------
Enjoy the script and give me the credit. Replies please! What do you think of this?
Samo, the thief.
by samo
Feb 12 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
CODE
Code:
#==============================================================================
#
# CNS (Custom Name System) by Samo, the thief
# v1.0
#
#-Place this script above Main
#-Before calling a Input Name, put this in a new call script:
#
# $gender = "GENDER"
#
# GENDER must be in quotes and can be MALE or FEMALE.
#
# ###################
# #######################----------------############################
# #~~~~~~~~~~~~~~~~~~~~~#..::OPTIONAL::..#~~~~~~~~~~~~~~~~~~~~~~~~~~#
# #######################----------------############################
# ###################
# Search the lines @MALE_NAME and @FEMALE_NAME and you will see too many names.
# Put the names you want there. The script will take at random one of those names.
#
#
#
# <FEATURES>
#
#<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
#
# -Animations of Windows and map background.
# -Random Name Feature when pressing SHIFT. a random name of the variables
# @FEMALE_NAME and @MALE_NAME will be taken. If that name has more characters
# than the max, another name would be picked.
# -More nice Name Input.
#
#
#
#<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
#
#
# Enjoy it! Give me the creditif you use it!
#
# Samo, the thief.
#------------------------------------------------------------------------------
class Scene_Name
# ------------------------------------
def initialize
@FEMALE_NAME = ["Blanche", "Alma", "Lillie", "Ella", "Marion",
"Katherine","Pauline","Virginia","Laura","Lucille","Nellie","Viola","Sarah",
"Julia","Beatrice","Minnie","Ruby","Ida","Myrtle","Eva","Thelma","Agnes",
"Pearl","Elsie","Evelyn","Josephine","Bessie","Martha","Esther","Emma","Annie",
"Mabel","Bertha","Edith","Clara","Gertrude","Irene","Hazel",
"Catherine","Grace","Clarence","Edna","Frances","Gladys","Rose","Lillian","Ethel",
"Florence","Alice","Mildred","Marie","Dorothy","Elizabeth","Ruth","Anna","Margaret",
"Helen","Mary"]
@MALE_NAME = ["Clyde", "Sam", "Oscar", "Daniel", "Edwin",
"Lester","Russell","Stanley","Donald","Floyd","Eugene","Leonard","Kenneth",
"Leo","Anthony","Theodore","Jack","Andrew","Michael","Joe","Francis","Elmer",
"Herbert","Samuel","Howard","David","Willie","Earl","Ernest","Richard","Roy",
"Ralph","Raymond","Louis","Peter","Herman","Lawrence","Alfred",
"Carl","Fred","Clarence","Paul","Albert","Harold","Arthur","Harry","Thomas",
"Walter","Henry","Edward","Frank","Robert","Charles","Joseph","George","James",
"William","John"]
end
def main
@spriteset = Spriteset_Map.new
@actor = $game_actors[$game_temp.name_actor_id]
@edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
@edit_window.opacity = 225
@edit_window.y = -128
@input_window = Window_NameInput.new
@input_window.opacity = 195
@input_window.y = 480
@help_window = Window_Help_Name.new
@help_window.opacity = 225
@help_window.y = -80
@help_window.z = 9999
@input_window.z = 9999
@edit_window.z = 9999
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@edit_window.dispose
@input_window.dispose
@help_window.dispose
@spriteset.dispose
end
def generate_random_name
loop do
if $gender == "MALE"
number = rand(@MALE_NAME.size)
@new_name = @MALE_NAME[number]
else
number = rand(@FEMALE_NAME.size)
@new_name = @FEMALE_NAME[number]
end
if @new_name.size < $game_temp.name_max_char
@edit_window.name = @new_name
@edit_window.refresh
@edit_window.index = @new_name.size
@edit_window.update_cursor_rect
break
end
end
end
# ------------------------------------
def update
if @help_window.y != 0
@help_window.y += 10
end
if @edit_window.y != 0
@edit_window.y += 16
end
if @input_window.y != 128
@input_window.y -= 16
end
$game_map.update
@edit_window.update
@input_window.update
@help_window.update
if Input.trigger?(Input::SHIFT)
$game_system.se_play($data_system.cursor_se)
generate_random_name
end
if Input.repeat?(Input::B)
if @edit_window.index == 0
return
end
$game_system.se_play($data_system.cancel_se)
@edit_window.back
return
end
if Input.trigger?(Input::C)
if @input_window.character == nil
if @edit_window.name == ""
@edit_window.restore_default
if @edit_window.name == ""
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
return
end
@actor.name = @edit_window.name
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
return
end
if @edit_window.index == $game_temp.name_max_char
$game_system.se_play($data_system.buzzer_se)
return
end
if @input_window.character == ""
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@edit_window.add(@input_window.character)
return
end
end
end
#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
class Window_NameInput < Window_Base
CHARACTER_TABLE =
[
"A","B","C","D","E",
"F","G","H","I","J",
"K","L","M","N","Ñ",
"O","P","Q","R","S",
"T","U","V","W","X",
"Y","Z"," "," "," ",
"-","_","¿","?"," ",
"¡","!"," "," "," ",
"(",")"," "," "," ",
"a","b","c","d","e",
"f","g","h","i","j",
"k","l","m","n","ñ",
"o","p","q","r","s",
"t","u","v","w","x",
"y","z"," "," "," ",
" "," "," "," "," ",
".","´","`","^"," ",
" "," ","€","'"," ",
"0","1","2","3","4",
"5","6","7","8","9",
","," ","&"," "," ",
" "," "," "," "," ",
" "," ","","","",
"á","é","í","ó","ú",
"Á","É","Í","Ó","Ú",
"Ç","Ñ","ü","Ü","",
"à","è","ì","ò","ù",
"À","È","Ì","Ò","Ù",
"ï","Ï","ü","Ü","",
"","","","","",
"","","","","",
"","","","","",
"","","","","",
"","","","","",
"","","","","",
"","","","","",
]
#--------------------------------------------------------------------------
def initialize
super(0, 128, 640, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@index = 0
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
def character
return CHARACTER_TABLE[@index]
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0..179
x = 4 + i / 5 / 9 * 152 + i % 5 * 28
y = i / 5 % 9 * 32
self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
end
self.contents.draw_text(544, 9 * 32, 64, 32, "OK", 1)
end
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 180
self.cursor_rect.set(544, 9 * 32, 64, 32)
else
x = 4 + @index / 5 / 9 * 152 + @index % 5 * 28
y = @index / 5 % 9 * 32
self.cursor_rect.set(x, y, 28, 32)
end
end
#--------------------------------------------------------------------------
def update
super
if @index >= 180
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@index -= 180
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@index -= 180 - 40
end
else
if Input.repeat?(Input::RIGHT)
if Input.trigger?(Input::RIGHT) or
@index / 45 < 3 or @index % 5 < 4
$game_system.se_play($data_system.cursor_se)
if @index % 5 < 4
@index += 1
else
@index += 45 - 4
end
if @index >= 180
@index -= 180
end
end
end
if Input.repeat?(Input::LEFT)
if Input.trigger?(Input::LEFT) or
@index / 45 > 0 or @index % 5 > 0
$game_system.se_play($data_system.cursor_se)
if @index % 5 > 0
@index -= 1
else
@index -= 45 - 4
end
if @index < 0
@index += 180
end
end
end
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
if @index % 45 < 40
@index += 5
else
@index += 180 - 40
end
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @index % 45 >= 5
$game_system.se_play($data_system.cursor_se)
if @index % 45 >= 5
@index -= 5
else
@index += 180
end
end
end
if Input.repeat?(Input::L) or Input.repeat?(Input::R)
$game_system.se_play($data_system.cursor_se)
if @index / 45 < 2
@index += 90
else
@index -= 90
end
end
end
update_cursor_rect
end
end
#==============================================================================
# ■ Window_NameEdit
#------------------------------------------------------------------------------
class Window_NameEdit < Window_Base
#--------------------------------------------------------------------------
attr_accessor :name
attr_accessor :index
#--------------------------------------------------------------------------
def initialize(actor, max_char)
super(80, 0, 480, 128)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@actor = actor
@name = actor.name
@max_char = max_char
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
#--------------------------------------------------------------------------
def restore_default
@name = @default_name
@index = @name.split(//).size
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
def add(character)
if @index < @max_char and character != ""
@name += character
@index += 1
refresh
update_cursor_rect
end
end
#--------------------------------------------------------------------------
def back
if @index > 0
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
#--------------------------------------------------------------------------
def refresh
self.contents.clear
name_array = @name.split(//)
for i in 0...@max_char
c = name_array[i]
if c == nil
c = "_"
end
x = 200 - @max_char * 14 + i * 28
self.contents.draw_text(x, 32, 28, 32, c, 1)
end
draw_actor_graphic(@actor, 200 - @max_char * 14 - 40, 80)
end
#--------------------------------------------------------------------------
def update_cursor_rect
x = 200 - @max_char * 14 + @index * 28
self.cursor_rect.set(x, 32, 28, 32)
end
#--------------------------------------------------------------------------
def update
super
update_cursor_rect
end
end
#==============================================================================
# ■ Window_Help_Name
#------------------------------------------------------------------------------
#==============================================================================
class Window_Help_Name < Window_Base
#--------------------------------------------------------------------------
# - Inicio de Objetos...
#--------------------------------------------------------------------------
def initialize
super(0, 0, 80, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 16
refresh
end
#--------------------------------------------------------------------------
# - Actualizacion
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 80, 32, "SHIFT:")
self.contents.draw_text(0, 20, 80, 32, "Random")
self.contents.draw_text(0, 40, 80, 32, "Name")
end
end
INSTRUCTIONS:
-------------
Code:
#==============================================================================
#
# CNS (Custom Name System) by Samo, the thief
# v1.0
#
#-Place this script above Main
#-Before calling a Input Name, put this in a new call script:
#
# $gender = "GENDER"
#
# GENDER must be in quotes and can be MALE or FEMALE.
#
# ###################
# #######################----------------############################
# #~~~~~~~~~~~~~~~~~~~~~#..::OPTIONAL::..#~~~~~~~~~~~~~~~~~~~~~~~~~~#
# #######################----------------############################
# ###################
# Search the lines @MALE_NAME and @FEMALE_NAME and you will see too many names.
# Put the names you want there. The script will take at random one of those names.
#
#
#
# <FEATURES>
#
#
# -Animations of Windows and map background.
# -Random Name Feature when pressing SHIFT. a random name of the variables
# @FEMALE_NAME and @MALE_NAME will be taken. If that name has more characters
# than the max, another name would be picked.
# -More nice Name Input.
#
#
# Enjoy it! Give me the creditif you use it!
#
# Samo, the thief.
#------------------------------------------------------------------------------
Enjoy the script and give me the credit. Replies please! What do you think of this?
Samo, the thief.