Script for key input.

● ARCHIVED · READ-ONLY
Started by _Shadow_ 8 posts View original ↗
  1. Hello.

    I wanna make a small script that will run all the time, 

    and it will constantly checks if the user has pressed "A" button.

    Something like event listener in Java.

    If the player presses A, it opens the item menu directly.

    How can it be made to work properly?

    Cause i cant make it work no matter what I try.

    Thanks in advance.

    Edit:

    P.S. Where should I put the script?
  2. IS the A button one that's normally checked? I ask because Ace names its keys, but the key you have to press is something different. So I don't know if you mean the actual A key, or the one that Ace calls A (if there is one).


    Anyway - look in Scene_Map to see how it handles opening the menu when you press escape. You should be able to put in a similar test somewhere around the same location, for the button you're after.
  3. class Scene_Map  def update_scene    check_gameover    update_transfer_player unless scene_changing?    update_encounter unless scene_changing?    update_call_menu unless scene_changing?    update_call_debug unless scene_changing?    update_call_item_menu unless scene_changing?  end    def update_call_item_menu    if $game_system.menu_disabled || $game_map.interpreter.running?      @menu_calling = false    else      @menu_calling ||= Input.trigger?:)X)      SceneManager.call(Scene_Item) if @menu_calling && !$game_player.moving?    end  endend

    The code for A in ace is X. Hope this helps!

    EDIT: Let me explain what happens.

    Scene_Map calls the menu using a method called call_menu. The method update_call_item_menu here is replica of update_call_menu.

    Scene_Map using update_scene updates all the input keys etc. Here, i added a new method update_call_item_menu there so that it can get executed.

    Only difference between update_call_item_menu and update_call_menu is that i used :X there instead of :B (A instead of Esc), and changed call_menu to SceneManager.call(Scene_Item) which will call the item scene.

    Hope this helps you.
  4. For Shaz:

    I mean pressing A on keyboard to open Item Menu. :)

    Ohhhhhh!!!!!!

    Now everything that happened to me makes sense.

    Wow Shaz!

    You putted chaos into order here!

    So that's why I couldn't make it work properly.

    Scene_Map you said... let me take a look.

    For The Green Horse:

    My my...  nice script solution.

    Thank you Shaz.

    Thank you The Green Horse.

    I appreicate your help.

    Cheers.
  5. "The code for A in ace is X. Hope this helps!"

    Just for reference... what is the code for keyboard keys

    Z, X C, S and D?

    (Asking of course in case there are by default any, otherwise I will implement an interface i have seen one lurking out there :p )

    After answering this one...

    well I guess we can close the case.

    Again thanks!
  6. Dreadshadow said:
    "The code for A in ace is X. Hope this helps!"


    Just for reference... what is the code for keyboard keys
    You can't tell that, because there is no fixed coding.
    Ace reacts to buttons like :X or :Y (not X like the post above said).


    These are mapped to real keyboard key in the configuration you can open ingame with F1.


    That means the DEFAULT for Keyboard A is button :X - until the player changes that keyboard mapping.


    Do not even try to make a fixed connection in your script, use only the button codes (the ones with the : ), and give a hint to the player that he can map the buttons with F1 configuration.
  7. Oh! Okay. Got it. XD
  8. Andar said:
    You can't tell that, because there is no fixed coding.

    Ace reacts to buttons like :X or :Y (not X like the post above said).

    These are mapped to real keyboard key in the configuration you can open ingame with F1.

    That means the DEFAULT for Keyboard A is button :X - until the player changes that keyboard mapping.

    Do not even try to make a fixed connection in your script, use only the button codes (the ones with the : ), and give a hint to the player that he can map the buttons with F1 configuration.
    Oops i needed to write "Default Code".

    But i told dread about this earlier. Anyways, sorry for posting wrong.