Jump to content
estriole

EST - NAME INPUT USING KEYBOARD

Recommended Posts

EST - NAME INPUT USING KEYBOARD

v.1.0

 

Requires:
Neon Black Keyboard Input 1.0a
http://forums.rpgmakerweb.com/index.php?/topic/3456-developer-console/#entry37268
enter the link to his keyboard module script there.

or

http://pastebin.com/raw.php?i=rD4rQtKP
for direct link to his pastebin. in case you're confused where's the link above.

Version history
v.1.0 - 2013.02.15 - finish the script

Introduction:


Have you ever feel it's not comfortable to input name by choosing which symbol then press enter.

letter by letter. so time consuming.

this script change that!. instead of choosing symbol and press enter. you type letter directly from keyboard.

press esc / backspace to erase a character
press enter when you're done. maybe will put confirmation window later.

btw the name input window still there. i just hide it from view and change
some behavior. :D.

Usage
Plug and Play

Compatibility
it should compatible with most script.
If you using Tsukihime Simple Text Input.

http://www.rpgmakervxace.net/topic/4238-simple-text-input/

put this script ABOVE that script. so the script also use KEYBOARD :D. since the script is using name input window too.

 

Screenshot

Basically the view is the same with normal name input scene. the only different is that you won't see default Name input window because i hide it from view. then i modify it to get the input from keyboard directly

so no screenshot needed i guess.

 

Demo

It also not needed... :D

 

Script

http://pastebin.com/CRxFwGEP

Edited by estriole

Share this post


Link to post
Share on other sites

Great work! :D

 

 

 

(...) maybe will put confirmation window later. (...)

Hey, you don´t really need to include it. If you want a confirmation message, just do the following inside the event:

 

KOUzf2L.jpg

 

(Always remembering that both Label and Jump to Label must have the exact name (case included)(as far as I understand xD )

 

 

Share this post


Link to post
Share on other sites

ah yes. you could do that too :D. but i'm thinking more like quiz system for my project. so maybe i will still add confirmation window later when i'm not busy. but for now i guess the solution provided by starg09 can be used :D.

Share this post


Link to post
Share on other sites

Licenses

Free to use in all project (except the one containing pornography)

as long as i credited (ESTRIOLE).
 
:D
 
btw what i mean containing pornography means porn games. if it's only a little 'fan service' here and there it's still okay :D.
Edited by estriole

Share this post


Link to post
Share on other sites

basically this script is plug and play.

just use event command change name (change actor name). and you could type the letter directly using keyboard instead default method choosing symbol press enter etc.

this also support tsukihime simple text input too since that script use same window.

Share this post


Link to post
Share on other sites

There was a script like this for VX which I loved and used. The main difference here is pretty problematic though. I use this script to let the player quickly type in keywords to 'ask' NPCs. However, your script clears the previous message box before bringing up the hero name input.

 

The VX script that I used a year or two ago did not. For instance, you talk to an NPC and he says a message on the bottom portion of the screen. Then, that message stays there, and the input hero name appears on the top. Allowing you to review his message for any keywords etc. before typing your response.

 

Can this be modified to permit that? Please help, this is a key script for my game.

Share this post


Link to post
Share on other sites

This script only modify the window behavior. By default name input processing is ANOTHER scene(not running in scene map). So of course the last game message is closed.

And to change that you need to rework the scene_map. And maybe quite a lot (adding the window, adding the handler, adding the hide and view code, etc).

 

Some solution is using tsukihime simple text input script. You could retype your question as title in that scene.

Share this post


Link to post
Share on other sites

I was using your code to create an input window during a battle scene.

Basically it just inserts a NameEdit & NameInput window between the enemy selection and next turn / turn end.

 

The problem I'm having is when I initialize a new window in that scene, it'll take the input of 'z' or 'enter' to NameInput window.

This doesn't occur on the normal event call on "Name Input Processing" though.

 

 

I'm assuming I'm missing something with the process handling for those two difference scenes.

 

If it was a problem with the initialization process handling for NameInput started too early during the Battle Scene, then it should also apply to the original one too.

However, it doesn't, since hitting 'z' or 'enter' with the original selection screen wouldn't toss the extra process key to selection 'A' onto the NameEdit.

 

If it was something odd with the process handling on the EST keyboard, then it should have also applied to the "Name Input Processing" event, but it doesn't....

 

So, I'm at a lost here... been digging around and haven't seen anything out of place.

 

I've also posted my problem here incase if someone else can help;

http://www.rpgmakervxace.net/topic/17491-estrioles-nameinput-taking-previous-z-key-as-input/

Share this post


Link to post
Share on other sites

Hmm... I cannot help much without seeing your code. But try adding

Input.update

before showing the name input window

Ex:

Input.update

@whatyourwindowname.show.activate

 

Since the keyboard listener code will run only if the window open? and active.

If that doesn't solve the problem then you might sent a small demo (below 5mb pls) for me to inspect.

 

Edit: depending on where you create the window. You might want to add Input.update too. (Might not necessary if you create it right).

Edited by estriole

Share this post


Link to post
Share on other sites

Input.update didn't work.

 

The code was in the link, but I'll repost it here too.

It's plug and play code, requires your est keyboard, and tsuki Window_TextInput for the message window.

http://www.rpgmakervxace.net/topic/4238-simple-text-input/

 

As you can see below, I've initialized the window when the user selects an enemy target.

I could and did pull it out, creating the NameEdit and NameInput windows with the Scene_Battle initialization. Hide and deactivate it until it is called upon. However, it didn't make a difference.

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Enemy Window
  #--------------------------------------------------------------------------
  alias create_enemy_window_orig create_enemy_window
  def create_enemy_window
    @enemy_window = Window_BattleEnemy.new(@info_viewport)
    @enemy_window.set_handler(:ok,     method(:on_enemy_name))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Enemy Name Prompt
  #--------------------------------------------------------------------------
  def on_enemy_name
    @enemytarget = @enemy_window.enemy.original_name
    @edit_window = Window_TextEdit.new('Spell '+@enemytarget+' name', 15)
    @input_window = Window_NameInput.new(@edit_window)
    @input_window.set_handler(:ok,      method(:on_enemy_ok))
    @input_window.set_handler(:cancel,  method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Enemy [OK]
  #--------------------------------------------------------------------------
  alias on_enemy_ok_orig on_enemy_ok
  def on_enemy_ok
    @edit_window.close
    @input_window.close
    @inputname = @edit_window.name
    if @inputname == @enemytarget then
      #Sound.play_ok
      BattleManager.actor.input.target_index = @enemy_window.enemy.index
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      next_command
    else
      Sound.play_buzzer
      @edit_window.close
      @input_window.close
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      command_guard
    end
  end
  #--------------------------------------------------------------------------
  # * Enemy [Cancel]
  #--------------------------------------------------------------------------
  alias on_enemy_cancel_orig on_enemy_cancel
  def on_enemy_cancel
    @edit_window.close
    @input_window.close
    @enemy_window.hide
    case @actor_command_window.current_symbol
    when :attack
      @actor_command_window.activate
    when :skill
      @skill_window.activate
    when :item
      @item_window.activate
    end
  end
end
Edited by rnorzsrpir

Share this post


Link to post
Share on other sites

i cannot replicate your bug (input:z stucked).

maybe it your battle system

 

you could post a new demo containing all your script in same order as your project (below 5mb please). so i can inspect it.

 

but i found another bug.

as soon as battle start... choosing attack. it will bring enemy selection window. press escape. it will throw error nil class. since the window haven't created yet.

also it's not good to creating windows many times. in long battle it might cause error (103 error maybe).

.close only hide the window. but the object still there. then you create another one. hide it again. create again another one.

 

another thing i see you use alias but didn't use it. so your script compatibility will be low...

 

i tweak your code a bit so it dispose the window after it's not needed anymore. and use your created alias. also fixed the bugs

 

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Enemy Window
  #--------------------------------------------------------------------------
  alias create_enemy_window_orig create_enemy_window
  def create_enemy_window
    create_enemy_window_orig
    @enemy_window.set_handler(:ok,     method(:on_enemy_name))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Enemy Name Prompt
  #--------------------------------------------------------------------------
  def on_enemy_name
    @enemytarget = @enemy_window.enemy.original_name
    @edit_window = Window_TextEdit.new('Spell '+@enemytarget+' name', 15)
    @input_window = Window_NameInput.new(@edit_window)
    @input_window.set_handler(:ok,      method(:on_enemy_ok))
    @input_window.set_handler(:cancel,  method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Enemy [OK]
  #--------------------------------------------------------------------------
  alias on_enemy_ok_orig on_enemy_ok
  def on_enemy_ok
    @inputname = @edit_window.name
    dispose_naming_window
    if @inputname == @enemytarget then
      on_enemy_ok_orig
    else
      Sound.play_buzzer
      dispose_naming_window
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      command_guard
    end
  end
  def dispose_naming_window
    @edit_window.dispose if @edit_window && !@edit_window.disposed?
    @input_window.dispose if @input_window && !@input_window.disposed?
    @edit_window = nil
    @input_window = nil
  end
  #--------------------------------------------------------------------------
  # * Enemy [Cancel]
  #--------------------------------------------------------------------------
  alias on_enemy_cancel_orig on_enemy_cancel
  def on_enemy_cancel
    dispose_naming_window
    on_enemy_cancel_orig
  end
end

 

btw... nice concept you have there. it will be good for educational games for kids.

but some point you should considered. since at first i type SlimeA because that what i see in the enemy name window :D.

while the answer is the enemy original name (Slime).

 

need tutorial to explain that (only spell 'slime' instead of 'slimea') if you're planning to make that kind of game :D.

the idea could be expanded by changing the battle system where the actor act immediately when choosing command (i forgot what the system called. but i think yanfly / yami have that script). then giving time limit when choosing target :D. (typing game).

it could be fun.

 

also i might not have internet connection for couple of days (it's islam holy day. and in my country "all workplace" closed. and my internet is in my workplace :D).

so i might only check the forum using phone. thus might not check your uploaded demo soon.

 

 

edit: you might also test the arrangement of the script. in my test it's arranged this way:

- Neon Black Keyboard

- Est Name input using keyboard

- Tsukihime Text input

- Your script

 

improper arrangement could also spawn error/bugs.

Edited by estriole

Share this post


Link to post
Share on other sites

I've removed the alias while changing around the code, forgot to place it in again though compability shouldn't be an issue at the moment.

Thanks for correcting close to dispose. I thought close did garbage collection too, I guess messed up and misread it while browsing Window_Base. Or just wanted to keep thinking close was dispose even after reading it...

The code was already arranged the same way you've listed it, but I'm not having the same bug you're explaining with choosing an attack on the enemy selection window.
 
Not sure where you're getting that error. Hitting 'ESC' or 'x' going back one window from 'select enemy' shouldn't involve anything with the input windows. When enemy window is created its ok handler will go to the creation of the name input windows, its cancel handler is still the same.

  #--------------------------------------------------------------------------
  # * Create Enemy Window
  #--------------------------------------------------------------------------
  alias create_enemy_window_orig create_enemy_window
  def create_enemy_window
    create_enemy_window_orig
    @enemy_window.set_handler(:ok,     method(:on_enemy_name))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end

I've checked with no issues on my end...

fight -> attack -> select enemy
fight -> special -> skill -> select enemy

 
Only thing I haven't considered yet was the attack all enemy type of skills, like cleave, which does not call for select enemy, thus bypassing the whole input process.
 
Not sure why you're not having the same issue on my end either....
The extra input occurs between select enemy to the creation of the input window.
 

fight -> attack -> select enemy -> create input window

 
It occurs during the transition;
if you either press any of the assigned "C" keys such as 'z' or 'enter'.
or if you hold down any of those keys as well.
 
You might avoid extra input from the transition it if you tap the key very quickly.
 
Well here's the demo, w/o the RTP data of course.
https://dl.dropboxusercontent.com/u/8331016/ProjectD.exe

Edited by rnorzsrpir

Share this post


Link to post
Share on other sites

In the code I tweak. I fixed that crash bug.

 

Your code before will crash if:

1) Start the battle

2) Immediately Choose the attack command. Don't choose any enemy.

3) Immediately press escape (cancelling)

Crash...

 

Since you try to close name input window but at that moment you haven't created the window yet (since first time you create that window is when you select an enemy).

Here's your previous method that make the error.

def on_enemy_cancel
    @edit_window.close
    @input_window.close
    @enemy_window.hide
    case @actor_command_window.current_symbol
    when :attack
      @actor_command_window.activate
    when :skill
      @skill_window.activate
    when :item
      @item_window.activate
    end
  end
I modify it by adding check before dispose the window. Does the window exist or already disposed.

 

For your demo I'll check it out when holiday over :D.

I might need some more info later.

Share this post


Link to post
Share on other sites

Ah, right. That would cause a problem without the conditions to check if the window existed in the first place.

Tossing a check condition before closing would also work.

 

Or... creating the window when the battle scene is initialize and just call upon it when needed. This way the window doesn't have to be disposed and recreated each time a player decide to call the Window_BattleEnemy, only have to update the contents. I didn't get that working until a few days ago, since I was trying to figure out how refreshing worked with the windows and the scope of the variables.

In this initialization, the window is created with the create_all_windows and is hidden and deactivated until called upon

When called upon, it sets a new title with the target enemy name, and refreshes the window. Instead of setting a new title and creating a new window.

 

But, still in both cases the input from the previous window will affect the EST NameInput keyboard monitoring process.

Edited by rnorzsrpir

Share this post


Link to post
Share on other sites

Holiday finally over. When I go to my workplace I'll check out your demo. Sorry for the wait.

 

Also. Creating and disposing window like you did is already okay. I think. Since at that momment the battle currently on stop phase.

It would be different if you create the window when there something happen in battle.

 

Edit: cannot access internet today. There's something wrong with my provider. Will check it tomorrow.

Edited by estriole

Share this post


Link to post
Share on other sites

@morzsrpir: internet back up. checked your demo.

and yes even in my project it also stuck. (earlier i use enter. but rereading your post and try using z).

 

the culprit is neonblack keyboard script. it's update method didn't clear the input from memory. thus it will enter it when the window created.

found a way to fix it.

 

below i have two version of implementation WITH the bugfix included (lines 6-10 is the bugfix to neonblack keyboard script).

i also add configuration. to have the name checking case sensitive or not. if set to true... Slime must be typed Slime. if set to false. Slime could be type as SLiMe

1) create the input window at start of battle. and show and hide them when not needed.

 

 

 

# ENEMY SPELL NAME INPUT SO I USE MODULE ESNI INSTEAD
module ESNI
  CASE_SENSITIVE = true
end

module Keyboard  ## The DLL file, function, import, and export.
  def self.update  ## Resets the check state each frame.
    self.get_key_state  ## Sets the key states.
  end
end

class Window_TextEdit < Window_Base
  def set_text(text,max_char)
    @text = text
    @max_char = max_char
    refresh
  end
end

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Enemy Window
  #--------------------------------------------------------------------------
  alias create_enemy_window_orig create_enemy_window
  def create_enemy_window
    create_enemy_window_orig
    @enemy_window.set_handler(:ok,     method(:on_enemy_name))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
    create_input_window
  end
  def create_input_window
    @edit_window = Window_TextEdit.new("", 15)
    @edit_window.hide.deactivate
    @input_window = Window_NameInput.new(@edit_window)
    @input_window.deactivate
    @input_window.set_handler(:ok,      method(:on_enemy_ok))
    @input_window.set_handler(:cancel,  method(:on_enemy_cancel))    
  end
  def on_enemy_name
    @enemytarget = @enemy_window.enemy.original_name
    @edit_window.set_text('Spell '+@enemytarget+' name', 15)
    @edit_window.show.activate
    @input_window.activate
  end
  #--------------------------------------------------------------------------
  # * Enemy [OK]
  #--------------------------------------------------------------------------
  alias on_enemy_ok_orig on_enemy_ok
  def on_enemy_ok
    @edit_window.hide.deactivate
    @input_window.deactivate
    @inputname = @edit_window.name
    if @inputname == @enemytarget
      on_enemy_ok_orig
    elsif ESNI::CASE_SENSITIVE == false && @inputname.downcase == @enemytarget.downcase
      on_enemy_ok_orig
    else
      Sound.play_buzzer
      @edit_window.hide.deactivate
      @input_window.deactivate
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      command_guard
    end
    @edit_window.restore_default
  end
  alias on_enemy_cancel_orig on_enemy_cancel
  def on_enemy_cancel
    @edit_window.hide.deactivate
    @input_window.deactivate
    on_enemy_cancel_orig
  end  
end

 

 

2) create the input window when selecting the enemy. and disposing it when not needed.

 

 

 

# ENEMY SPELL NAME INPUT SO I USE MODULE ESNI INSTEAD
module ESNI
  CASE_SENSITIVE = true
end

module Keyboard  ## The DLL file, function, import, and export.
  def self.update  ## Resets the check state each frame.
    self.get_key_state  ## Sets the key states.
  end
end

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Enemy Window
  #--------------------------------------------------------------------------
  alias create_enemy_window_orig create_enemy_window
  def create_enemy_window
    create_enemy_window_orig
    @enemy_window.set_handler(:ok,     method(:on_enemy_name))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Enemy Name Prompt
  #--------------------------------------------------------------------------
  def on_enemy_name
    @enemytarget = @enemy_window.enemy.original_name
    @edit_window = Window_TextEdit.new('Spell '+@enemytarget+' name', 15)
    @input_window = Window_NameInput.new(@edit_window)
    @input_window.set_handler(:ok,      method(:on_enemy_ok))
    @input_window.set_handler(:cancel,  method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Enemy [OK]
  #--------------------------------------------------------------------------
  alias on_enemy_ok_orig on_enemy_ok
  def on_enemy_ok
    @inputname = @edit_window.name
    dispose_naming_window
    if @inputname == @enemytarget
      on_enemy_ok_orig
    elsif ESNI::CASE_SENSITIVE == false && @inputname.downcase == @enemytarget.downcase
      on_enemy_ok_orig
    else
      Sound.play_buzzer
      dispose_naming_window
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      command_guard
    end
  end
  def dispose_naming_window
    @edit_window.dispose if @edit_window && !@edit_window.disposed?
    @input_window.dispose if @input_window && !@input_window.disposed?
    @edit_window = nil
    @input_window = nil
  end
  #--------------------------------------------------------------------------
  # * Enemy [Cancel]
  #--------------------------------------------------------------------------
  alias on_enemy_cancel_orig on_enemy_cancel
  def on_enemy_cancel
    dispose_naming_window
    on_enemy_cancel_orig
  end
end

 

 

 

you can choose which one you would like (hide/show or create/dispose).

i tried both and both have 60 fps... (no difference)

Share this post


Link to post
Share on other sites

Sorry for taking so long to come back.

Thanks for pointing out and getting the Keyboard module fix.

 

Looking at the CP Input by neon black for the Keyboard module, there is an instance variable @checked set as false which is defined with the self.update method. It controls the monitoring of the key state.

Wouldn't your definition for Keyboard module self.update method redefine it? If it did redefine it, it would have broke since @checked has to be set to back to false each update.

But, it seemed to have appended to the already existing module method, or am I wrong?

 

As for the additional code, you didn't have to write up the rest of it. I've mentioned last post that I've written it already, but I appreciated it anyways.

 

I like the non-case sensitive addition, it'll be nice to have incase if someone has caps locks on by mistake and type SLIME instead of Slime, or other human mistakes.

Share this post


Link to post
Share on other sites

From what I see in the code... The @checked is never used anyway. :P. Because before checking the input it will set it to true (first line in the get key state method if I remember correctly) thus @checked will 'always' true whenever @checked used as condition... Thus the update method to change @checked to false has no effect. But I might be wrong too. So if you're affraid. You can just put back the @checked = false in first line in update method (although by logic after you set it to false it will set back again to true by get key state method...)

 

Edit: for why I write the rest of code. It because before I found that the input module that caused it. I try making it work by hide/show method. Thus the script was made. I also finish the create/dispose version too so I can test and compare it. And after both version finished. And still have those bugs. Then I finally pointed the root of problem in keyboard module. And since the script has been written anyway. I just share it. So you can use it as reference.

Edited by estriole

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×