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

Discussion in 'RPG Maker MV' started by Cloud_FFVII, Apr 22, 2017.

  1. Cloud_FFVII

    Cloud_FFVII Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    Spanish
    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: Apr 22, 2017
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,311
    Likes Received:
    6,437
    Location:
    Germany
    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)
     
    #2
    Cloud_FFVII likes this.
  3. Cloud_FFVII

    Cloud_FFVII Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    Spanish
    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! :)
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,311
    Likes Received:
    6,437
    Location:
    Germany
    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.
     
    #4
  5. Cloud_FFVII

    Cloud_FFVII Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    Spanish
    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.

    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: Apr 23, 2017
    #5
  6. Andar

    Andar Veteran Veteran

    Messages:
    28,311
    Likes Received:
    6,437
    Location:
    Germany
    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.
     
    #6
    SwiftSign likes this.
  7. Cloud_FFVII

    Cloud_FFVII Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    Spanish
    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
     
    #7

Share This Page