Script for key input.

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
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?
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

TheGreenHorse

Veteran
Veteran
Joined
Mar 31, 2014
Messages
177
Reaction score
26
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
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.
 
Last edited by a moderator:

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
"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!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
"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.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Oh! Okay. Got it. XD
 

TheGreenHorse

Veteran
Veteran
Joined
Mar 31, 2014
Messages
177
Reaction score
26
First Language
English
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top