Stormhaven

Villager
Member
Joined
Dec 30, 2016
Messages
13
Reaction score
2
First Language
English
Primarily Uses
I've been trying to figure out how to get this work, sadly Im no good at scripting yet, so I've been struggling understanding previous answers that could be applicable. I have a moving event that I want to be able to be caught by another event touching it, but I'm not sure how to set that up. I'm assuming it would need to be a script, but I'd be happy to be proven wrong! Any ideas?

EDIT: I'm dumb, seem to find my own solutions minutes after asking for help lately. Used a version of something someone else did in the forums, in case anyone is curious.


Math.abs($gameMap.event(14).x - $gameMap.event(16).x) + Math.abs($gameMap.event(14).y - $gameMap.event(16).y) === 1

If anyone could tell me how to edit that so one of the events is the player instead I'd appreciate it! I could use Event Touch but the way the event is set up currently that would take some edits.
 
Last edited:

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,691
Reaction score
2,602
First Language
Dutch
Primarily Uses
RMMV
Code:
const actor = $gameActors.actor(1);
const eventID = 16;
const gmap = $gameMap;
Math.abs(gmap.event(actor).x - gmap.event(eventID).x) + Math.abs(gmap.event(actor).y -
Math.abs gmap.event(eventID).y)

depending on which event it is used for, you can use instead of "eventID" set to 16
to "this.event".

actor ID number on top to the actor you want. if you want the party leader, use
$gamePlayer.leader() instead.

there are more methodes, depending what the event exacly does and the amount
of events to use, as it can than better done with a notetag on those events.
 

Stormhaven

Villager
Member
Joined
Dec 30, 2016
Messages
13
Reaction score
2
First Language
English
Primarily Uses
Code:
const actor = $gameActors.actor(1);
const eventID = 16;
const gmap = $gameMap;
Math.abs(gmap.event(actor).x - gmap.event(eventID).x) + Math.abs(gmap.event(actor).y -
Math.abs gmap.event(eventID).y)

depending on which event it is used for, you can use instead of "eventID" set to 16
to "this.event".

actor ID number on top to the actor you want. if you want the party leader, use
$gamePlayer.leader() instead.

there are more methodes, depending what the event exacly does and the amount
of events to use, as it can than better done with a notetag on those events.
I've tried a few different versions and nothing is working, any idea what I'm doing wrong?

My most recent try was this in a Script conditional:

Math.abs($gameMap.event($gamePlayer.leader()).x - $gameMap.event(16).x) + Math.abs($gameMap.event($gamePlayer.leader()).y - Math.abs $gameMap.event(16).y) === 1

I've tried setting up the variables like you did above, that didn't seem to do anything. I'm assuming I'm missing something but I don't know enough about scripting to know what.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,691
Reaction score
2,602
First Language
Dutch
Primarily Uses
RMMV
I made a mistake, $gameParty.leader(); or $gameParty.members()[0];

sorry about that, as $gamePlayer does exist, but for different kind of
commands.

using 1 of the above (both targets the leader), should do the trick.
 

Stormhaven

Villager
Member
Joined
Dec 30, 2016
Messages
13
Reaction score
2
First Language
English
Primarily Uses
I made a mistake, $gameParty.leader(); or $gameParty.members()[0];

sorry about that, as $gamePlayer does exist, but for different kind of
commands.

using 1 of the above (both targets the leader), should do the trick.
No worries! Sadly I tried those now, and neither seemed to work.

Math.abs($gameMap.event($gameParty.leader()).x - $gameMap.event(16).x) + Math.abs($gameMap.event($gameParty.leader()).y - $gameMap.event(16).y) === 1

I put that in the Script section of a conditional, that's the right place to put it right? Is there a mistake that I'm missing?

Thanks for all your help!
 

Stormhaven

Villager
Member
Joined
Dec 30, 2016
Messages
13
Reaction score
2
First Language
English
Primarily Uses
I got it! Did some testing after reading some similar issues.

Math.abs($gamePlayer.x - $gameMap.event(16).x) + Math.abs($gamePlayer.y - $gameMap.event(16).y) === 1

That's the solution! This checks if the player is currently adjacent to an event without using Event Touch, for the strange case if one would need it like mine.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,289
Reaction score
4,240
First Language
English
Primarily Uses
RMMV
...$gamePlayer.x...

That's the solution!
Yes, that's correct. The reason why @ShadowDragon 's suggestions wouldn't work is everything in $gameParty is returning an actor, and actors don't have coordinates associated with them.

They are also not an event, so saying $gameMap.event(actor ID is simply incorrect syntax (it's supplying a Game Actor as an argument, when it expects a number). And even $gameMap.event(actor ID) wouldn't work correctly, as they're not events.

The $gamePlayer is what represents the character you're controlling on the map.
 

Latest Threads

Latest Posts

Latest Profile Posts

Hello! I’d like to ask where is a good place to start logging about my game dev progress as production of my game goes forth
In one of our campus classrooms was a bag full of stuff people forgot there... my bag. That I forgot there xD
You know your room is too tiny for how much stuff you have when it gives you literal insomnia. I just cleared a bunch of stuff out and man it feels good!
1670381555475.png
Meet the Kernel. You encounter him in cyberspace. He's important!
I released a test version of my game on itch.io. If anyone wants to check it out, here's the link (for now in Brazilian Portuguese only, sorry).

https://rafael-lobo.itch.io/insolita

Forum statistics

Threads
127,094
Messages
1,183,894
Members
167,007
Latest member
nayomitsu
Top