Hi. I have a custom 'name input' script.
This is the code:
It works fine on the pokemon started kit on which I found it. Yet when I put it into my game I get the following error:
Any ideas?
Thanks
This is the code:
Code:
#==============================================================================
# â– Scene_Name
#------------------------------------------------------------------------------
# Allows for Name Input via the Keyboard
#==============================================================================
class Scene_Name
#--------------------------------------------------------------------------
# ◠メイン処ç†
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@name = Window_Name.new
@name.z = 999999
@input = Window_NameInput.new
@input.z = 999999
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画é¢ã‚’æ›´æ–°
Graphics.update
# フレーム更新
update
# ç”»é¢ãŒåˆ‡ã‚Šæ›¿ã‚ã£ãŸã‚‰ãƒ«ãƒ¼ãƒ—ã‚’ä¸æ–
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# メッセージウィンドウを解放
@spriteset.dispose
@name.dispose
@input.dispose
# タイトル画é¢ã«åˆ‡ã‚Šæ›¿ãˆä¸ã®å ´åˆ
end
#--------------------------------------------------------------------------
# ◠フレーム更新
#--------------------------------------------------------------------------
def update
@spriteset.update
@name.update
@input.update
end
end
#==============================================================================
# â– Window_Chat
#------------------------------------------------------------------------------
#  Displays chat messages.
#==============================================================================
class Window_Name < Window_Base
#--------------------------------------------------------------------------
# â— Initializes chat window.
#--------------------------------------------------------------------------
def initialize
super(40, 140, 400, 134)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
self.opacity = 255
refresh
end
#--------------------------------------------------------------------------
# â— Refreshes chat window.
#--------------------------------------------------------------------------
def refresh
self.contents.clear
x = 4
y = 0
w = 480
h = 32
self.contents.draw_text(x,y,w,h, "Type your name by using the keyboard.")
self.contents.draw_text(x,y+24,w,h, "Press Shift-key to use capital letters.")
self.contents.draw_text(x,y+48,w,h, "Press Backspace-key to remove a letter")
self.contents.draw_text(x,y+72,w,h, "and press Enter when you're done.")
end
#--------------------------------------------------------------------------
# â— Updates chat window.
#--------------------------------------------------------------------------
def update
refresh
super
end
end
#==============================================================================
# Window_ChatInput
#------------------------------------------------------------------------------
#
#==============================================================================
class Window_NameInput < Window_Base
#--------------------------------------------------------------------------
# â— Initializes chat input window.
#--------------------------------------------------------------------------
def initialize
super(40, 60, 400, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
self.opacity = 255
@text = []
refresh
end
#--------------------------------------------------------------------------
# â— Refreshes chat input window.
#--------------------------------------------------------------------------
def refresh
@log = @text.to_s
self.contents.clear
actor = $game_party.actors[0]
draw_actor_graphic(actor, 32, 48)
self.contents.draw_text(64, 4, 480, 48, @text.to_s + "_")
end
#--------------------------------------------------------------------------
# â— Refreshes chat input window.
#--------------------------------------------------------------------------
def add(char)
if @text.size >= $game_temp.name_max_char
$game_system.se_play($data_system.buzzer_se)
else
@text.push(char.to_s)
refresh
end
end
#--------------------------------------------------------------------------
# â— Updates input chat window.
#--------------------------------------------------------------------------
def update
# Sends chat message.
if Input.getkey(13)
if @text.size == 0
$game_system.se_play($data_system.buzzer_se)
else
$pkmn.trainername = @text.to_s
$game_variables[1] = @text.to_s
$game_variables[2] = $game_party.actors[0].name
$scene = Scene_Map.new
end
end
# Removes last entry in test.
if Input.getkey(8)
if @text.size == 0
$game_system.se_play($data_system.buzzer_se)
else
@text.delete_at(-1)
refresh
end
end
# Adds a pressed key.
if Input.getstate(16)
add("A") if Input.getkey(65)
add("B") if Input.getkey(66)
add("C") if Input.getkey(67)
add("D") if Input.getkey(68)
add("E") if Input.getkey(69)
add("F") if Input.getkey(70)
add("G") if Input.getkey(71)
add("H") if Input.getkey(72)
add("I") if Input.getkey(73)
add("J") if Input.getkey(74)
add("K") if Input.getkey(75)
add("L") if Input.getkey(76)
add("M") if Input.getkey(77)
add("N") if Input.getkey(78)
add("O") if Input.getkey(79)
add("P") if Input.getkey(80)
add("Q") if Input.getkey(81)
add("R") if Input.getkey(82)
add("S") if Input.getkey(83)
add("T") if Input.getkey(84)
add("U") if Input.getkey(85)
add("V") if Input.getkey(86)
add("W") if Input.getkey(87)
add("X") if Input.getkey(88)
add("Y") if Input.getkey(89)
add("Z") if Input.getkey(90)
add(")") if Input.getkey(48)
add("!") if Input.getkey(49)
add("@") if Input.getkey(50)
add("#") if Input.getkey(51)
add("$") if Input.getkey(52)
add("%") if Input.getkey(53)
add("^") if Input.getkey(54)
add("&") if Input.getkey(55)
add("*") if Input.getkey(56)
add("(") if Input.getkey(57)
add(":") if Input.getkey(186)
add("+") if Input.getkey(187)
add("<") if Input.getkey(188)
add("_") if Input.getkey(189)
add(">") if Input.getkey(190)
add("?") if Input.getkey(191)
add("{") if Input.getkey(219)
add("|") if Input.getkey(220)
add("}") if Input.getkey(221)
add("\"") if Input.getkey(222)
else
add("a") if Input.getkey(65)
add("b") if Input.getkey(66)
add("c") if Input.getkey(67)
add("d") if Input.getkey(68)
add("e") if Input.getkey(69)
add("f") if Input.getkey(70)
add("g") if Input.getkey(71)
add("h") if Input.getkey(72)
add("i") if Input.getkey(73)
add("j") if Input.getkey(74)
add("k") if Input.getkey(75)
add("l") if Input.getkey(76)
add("m") if Input.getkey(77)
add("n") if Input.getkey(78)
add("o") if Input.getkey(79)
add("p") if Input.getkey(80)
add("q") if Input.getkey(81)
add("r") if Input.getkey(82)
add("s") if Input.getkey(83)
add("t") if Input.getkey(84)
add("u") if Input.getkey(85)
add("v") if Input.getkey(86)
add("w") if Input.getkey(87)
add("x") if Input.getkey(88)
add("y") if Input.getkey(89)
add("z") if Input.getkey(90)
add("0") if Input.getkey(48)
add("1") if Input.getkey(49)
add("2") if Input.getkey(50)
add("3") if Input.getkey(51)
add("4") if Input.getkey(52)
add("5") if Input.getkey(53)
add("6") if Input.getkey(54)
add("7") if Input.getkey(55)
add("8") if Input.getkey(56)
add("9") if Input.getkey(57)
add(";") if Input.getkey(186)
add("=") if Input.getkey(187)
add(",") if Input.getkey(188)
add("-") if Input.getkey(189)
add(".") if Input.getkey(190)
add("/") if Input.getkey(191)
add("[") if Input.getkey(219)
add("\\") if Input.getkey(220)
add("]") if Input.getkey(221)
add("'") if Input.getkey(222)
end
add(" ") if Input.getkey(32)
add("*") if Input.getkey(106)
add("+") if Input.getkey(107)
add("-") if Input.getkey(109)
add("/") if Input.getkey(111)
end
end
It works fine on the pokemon started kit on which I found it. Yet when I put it into my game I get the following error:
Script 'Name Input' line 143: NoMethodError occured.
undefined method 'getkey' for Input:Module
Any ideas?
Thanks