Solved-How to condense 'is X or Y or Z buttons pressed' conditional branches into one through script

Status
Not open for further replies.

dragoonwys

Freelance Illustrator
Veteran
Joined
Jul 26, 2016
Messages
358
Reaction score
925
First Language
english
Primarily Uses
RMMV
Hi there! Context, I'm trying to make http://yanfly.moe/2015/12/03/yep-36-map-gold-window/ this window appear and disappear whenever the character moves or stops in place. Unfortunately I don't know how to do that directly as an extension to the code yet so I am using in editor events instead.

I have this parallel event that involves checking if the character is moving in any direction, if they are moving it will call on the plugin command that opens the window, if not, it will call on another plugin command to close it.

I know I can do it by having multiple Conditional branches, 'if left button is pressed' etc, but I was wondering how I can condense this into one working if statement via script (I think it involves Input.isPressed? I'm sorry, this is one of the lines I found in the core that has to do with buttons. Not the a lit bulb with this yet. ^^') and use || between the 4 buttons, instead of having 4 conditional branches that pretty much do the same thing after its confirmed that the player is or not moving.

Can someone point me to the right direction on how this is done, or if there is a better way of doing this? Should I scrap the entire idea of using events and it's more efficient to code an extension? Thank you.
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
399
Reaction score
221
First Language
English
Primarily Uses
RMMV
There is a script that checks if the player is moving
Code:
$gamePlayer.isMoving()
If that doesn't work the way you want and you want to use the key is pressed method you could use this
Code:
Input.isPressed('left') || Input.isPressed('up') || Input.isPressed('right') || Input.isPressed('down')
The || functions as the word 'or' and checks each condition individually and if one of them is true then the whole thing is true. If in the future you're looking for the 'and' method you can use &&
 

dragoonwys

Freelance Illustrator
Veteran
Joined
Jul 26, 2016
Messages
358
Reaction score
925
First Language
english
Primarily Uses
RMMV
@Silva
Ahhh I see! Thank you very much for pointing that out.
I see what I was doing wrong, I placed the || in the wrong place and now it works. I'll be using the .isMoving script since I like the format better, thank you for explaining everything! ^o^
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,225
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

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,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top