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
79
Reaction score
81
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
79
Reaction score
81
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 Profile Posts

Finally started working on Grim Trigger episode 2 today :LZScat: it's half comic/half visual novel!

GfY3Rwj.png
Is it interesting to get more backstory on villains? A key moment in their past, their childhood, or maybe something that shows they've always been that way? To see or not to see?
"Everything tastes like chicken until it's chicken, then it doesn't taste like chicken."
Context: chicken samosas do not taste like chicken. I thought it was veggie samosas.
Just another ordinary evening.
This pig girl is a merchant and playable character.
Currently there's no name for her yet. a suggestion is welcomed.
Merchant.jpg
Merchant-1.jpg
Want for a Nail: I'm trying to figure out what controllers work with MZ, one support thread, a plugin request thread, a dead controller, and a $48 eBay purchase, and a PS1/PS2 USB adapter later. Still stuck with keyboard controls...

Forum statistics

Threads
110,351
Messages
1,052,570
Members
143,393
Latest member
cobertk
Top