Force a Key press from Script | Trigger Event in front of the Player from Script

Cloud_FFVII

Veteran
Veteran
Joined
Dec 31, 2015
Messages
31
Reaction score
1
First Language
Spanish
Primarily Uses
Hello everyone!

I've been searching and trying different things all over internet, without luck... I would appreaciate if someone gives me some light on this...

WHAT I AM TRYING TO DO.
Originally, the idea is to create a Resident Evil style gameplay, I have all set already: menu with pictures, weapons, limit items, submenus, grid,etc...but I was wondering a way to "Use" the item from the menu and activate the event in front of the player...

For example, I have a key and want to open a door with it.
- I go to menu, select the key - Use it- and a common event with nothing on it occurs.
I guess the solution would go on this common event.

I already have the variable to save the ID of the last used item (KEY), then compare it in a conditional branch indide the event (DOOR) and that should be it...

Example:
DOOR EVENT - TRIGGER BY ACTION KEY
if (lastItemUsedID == n) {
Door open
lasiItemUsed -1
}

The problem is that I want to "activate" (trigger,autorun) the event in front of the player...but I can't do it.

Another solution could be by "forcing" to press the "Action Key" just after the item used (call from a script), so it would activate the event and then the conditional branch would run...but I haven't found the way to do it.
All the methods are for checking and requires the player to press the key itself...I want to press it from a script.


Hope your guys get it. My brain's killing me :(
Thanks in advance

PD: Sorry for my English.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,261
Reaction score
7,632
First Language
German
Primarily Uses
RMMV
No, you don't want to mess with key presses - the keyboard buffer is not something you want to mess with, which is one of the many reasons you won't find such a script command.

Please take a step back and describe what you want the player to do (instead of how you want the player to do it).
Then we can make suggestions how to handle this, but inserting data into the keyboard buffer is NOT what you want to do here due to the side effects and a lot of other problems with that (basically the browsers are specifically written to prevent that, because if a HTML-Game could do that by javascript, nothing would be able to stop malware and virusses)
 

Cloud_FFVII

Veteran
Veteran
Joined
Dec 31, 2015
Messages
31
Reaction score
1
First Language
Spanish
Primarily Uses
Thanks for answering Andar!

You're right, I know the risks and problems it could bring...but I just couldn't think in something else. (My head was killing me XD)
So I just suggested if there was a way...just throw some ideas of how to do it. XD

At the moment, after a break, I finally did what I wanted with some effort and tricks.
Used a plugin for proximity events and the rest is just "common events". I think that it's the best solution for now.

But well, resuming all the problem. I want to use an item from the menu in front of an event and make the event react to it.
That's pretty much the situation. If you think there's a better way, please let me know. I appreciate it! :)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,261
Reaction score
7,632
First Language
German
Primarily Uses
RMMV
call an common event from the item, have the common event check player position and where the facing is, then use that to identify the event with get location info. From then it depends on what exactly you want to do - and there are alternatives to this process depending what you want to do.

One alternative is to have everything handled by the map event - always trigger it but then use event commands like "select item" to have the player interact instead of the menu.

You're still not telling what you want the player to do - you're only telling how you want to do an unknown something.
And unless you tell the "what" we can only guess for a solution.
 

Cloud_FFVII

Veteran
Veteran
Joined
Dec 31, 2015
Messages
31
Reaction score
1
First Language
Spanish
Primarily Uses
Ummm...l think I don't get it.
What I want the player to do? Use an item from the menu and that the event in from of the player reacts to the used item. For example, use a key and the door event in front reacts to it.

call an common event from the item, have the common event check player position and where the facing is, then use that to identify the event with get location info.
Sorry but..., can I get the location of any event on the map from a common event? I don't get it. :(

On any case, I solved the issue with a plugin for proximity events. This is a very early example of what I mean, in the last part, when I use an item to open a door WITHOUT the SELECT ITEM command. :)


If there's no other better way to handle this, I guess I'll have to stick with this method.
Thanks for the advices!
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,261
Reaction score
7,632
First Language
German
Primarily Uses
RMMV
@Cloud_FFVII
Yes, there are other ways to handle it.
The easiest way (the intended default way) is not go through the menu, but have the event (the door for example) ask the player what item to use on it. That is what the select item command is for - it displays all items of the selected type (regular, key, hidden A and hidden B ) in the inventory, then the player can select one of them and the command stores the ID of that item in the variable.
The event can then check which ID is in the variable and react with whatever you want it to do (including removing the key to open door or give funny messages "the door can't drink a potion" depending on what the player selected.

Going that way there is absolutely no need to identify the event from elsewhere (just have the door activate on button or on player touch and then ask for the item), and it is even faster and better for playability because the player is not forced to open the menu for doing someting, the entire sequence is in one event only.
 

Cloud_FFVII

Veteran
Veteran
Joined
Dec 31, 2015
Messages
31
Reaction score
1
First Language
Spanish
Primarily Uses
@Cloud_FFVII
Yes, there are other ways to handle it.
The easiest way (the intended default way) is not go through the menu, but have the event (the door for example) ask the player what item to use on it. That is what the select item command is for - it displays all items of the selected type (regular, key, hidden A and hidden B ) in the inventory, then the player can select one of them and the command stores the ID of that item in the variable.
The event can then check which ID is in the variable and react with whatever you want it to do (including removing the key to open door or give funny messages "the door can't drink a potion" depending on what the player selected.

Going that way there is absolutely no need to identify the event from elsewhere (just have the door activate on button or on player touch and then ask for the item), and it is even faster and better for playability because the player is not forced to open the menu for doing someting, the entire sequence is in one event only.
You're right, the SELECT ITEM command could be the other option. I knew about it, but I wanted to try something else, that's why I asked if there was something I missed. (since I've been using VX Ace for years and now moved to MV) XD

The thing is that, since you need to combine items from inventory, it's more "confortable" to use them directly. Somehting like the old Resident Evil gameplay style. I think I got it solved with a plugin to activate an event when I'm near it.

I appreciate the help and the advices, Andar! You can close the thread now.

Regards
 

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

Latest Threads

Latest Profile Posts

Why is there so much month left at the end of money? D=
Hello humans! How goes your day in this journey of living? I hope it is good, for I am human like you, and I am feeling great! Worship the altar.
Sand is basically small rocks

Forum statistics

Threads
105,624
Messages
1,015,036
Members
137,285
Latest member
AndrewRobertson
Top