RPGM12321

Villager
Member
Joined
Feb 23, 2021
Messages
15
Reaction score
1
First Language
Eng
Primarily Uses
RMXP
Hi!

Is it possible to have an event start on button press?

I have learnt through this forum how to do a conditional branch for 'if button is pressed' (for player running), but would now like to see if it is possible to activate an event if a button is pressed once and then deactivated if it is pressed again.

Eg. the player is a normal sprite and then if button G is pressed, it changes the sprite to the player holding a sword.

Not sure if this is a conditional branch for 'if button is pressed'?
 

orochi2k

The Mad King of Neolithic
Veteran
Joined
Jan 2, 2021
Messages
82
Reaction score
101
First Language
Chinese
Primarily Uses
RMXP
By default RMXP only support a very limited number of keyboard input.
Thus, a script to support a full keyboard input may be needed.

After that, you just put it in a common event that runs in parallel
And do something like ...
condition script: Input.press?(Input::UP) #this means if up key is pressed.
Do something here...

If you want to force start an even on the current map.
Just use:
wishlist my game below.
Wait, that's not the correct copy-paste message.


Just use:
$game_map.events[PUT YOUR EVENT ID HERE].start

So...
Let's try this
if Input.press?(Input::UP) $game_map.events[1].start end
In a parallel event or a common parallel event.
When the up key is pressed, the no.1 event of this map will fire.
 

RPGM12321

Villager
Member
Joined
Feb 23, 2021
Messages
15
Reaction score
1
First Language
Eng
Primarily Uses
RMXP
Self Resolved - answer underneath this post

Hi Orochi2K!

You seem to have all the answers!

So this works fine, thank you.
However, is there a way to have it deactivate again with the same key?

I currently have a common parallel and a common with the following:

1)
Conditional Branch: Script: Keys.press?(D)
Set Move Route: Player
: $>Change Speed: 6
Wait for moves completion
Call common event 2

2)
Conditional Branch: Script: Keys.press?(D)
Set Move Route: Player
: $>Change Speed: 4
Wait for moves completion
Call common event 1

But it just crashes saying maximum number of common events error.

Essentially what I am trying here is when you press D, it makes you run and then if you press it again, it makes you walk.

Resolution

I found that putting another conditional branch inside the first branch and have it as Keys.toggle?(D) and then change speed back to 4 worked, no need for a 2nd common event!
 
Last edited:

orochi2k

The Mad King of Neolithic
Veteran
Joined
Jan 2, 2021
Messages
82
Reaction score
101
First Language
Chinese
Primarily Uses
RMXP
Whenever you want something on and off, it's likely the time to use a switch.
You can use RMXP's switch in script by calling:
$game_switches[THE ID OF SWITCH] = true / false
 

Latest Threads

Latest Posts

Latest Profile Posts

Whenever I start on a new chapter, it doesn't feel like the next episodes, but more like sequels :)
It can be frustrating that so many commercial games have used up titles that might otherwise be great for a project.
Light up explosions with QABS and Community Lighting.
qcPQHt9.gif

Forum statistics

Threads
110,655
Messages
1,054,985
Members
143,779
Latest member
Epitaph78
Top