Spike Trap Issue

I also don't understand why you're doing it through a parallel event and checking regions instead of just making the spikes damage on touch like @AquaEcho suggested, but...definitely no need to use code.
The OP didn't thoroughly explain what he was trying to do which leads us to guess, but the way it's set up is if the player is in region 1, the traps in that region start protracting and retracting. Otherwise, they're inactive

I believe the OP wants to do something like this
All of the script call is the incorrect syntax - there's a pinned thread with MV script calls that has the correct syntax you can copy.

But I don't understand why you're resorting to script if you're not familiar with it, all of that can be done with event commands.

I also don't understand why you're doing it through a parallel event and checking regions instead of just making the spikes damage on touch like @AquaEcho suggested, but...definitely no need to use code.
I am not trying to make them damage as soon as the player touches them. I am trying to make it so when the player walks over them, they pop up and have the chance to damage the party while the party goes to the other side of them.

The OP didn't thoroughly explain what he was trying to do which leads us to guess, but the way it's set up is if the player is in region 1, the traps in that region start protracting and retracting. Otherwise, they're inactive

I believe the OP wants to do something like this
That is really close, but I want the spikes to damage the player only if they are standing directly on the trap when it comes all the way up.
Basically, I want it to be like this:
I am not trying to make them damage as soon as the player touches them. I am trying to make it so when the player walks over them, they pop up and have the chance to damage the party while the party goes to the other side of them.
That tutorial is not good practice because he is making every trap a parallel event and as I stated earlier, the more you have running at once the more it will tax your PC and you'll start seeing lag. You're basically having every trap check if the player's x and y coordinates is the same as that trap event's coordinates every frame.

It will be especially noticeable on older PCs or phones with lower processing power.

You can do something like make the SpikeController event check the player's tile every x frames and see if that tile has another event on it (with a <spiketrap> note tag) and if the spikesUp switch is on. Then you have only one parallel event handling all the traps.
That tutorial is not good practice because he is making every trap a parallel event and as I stated earlier, the more you have running at once the more it will tax your PC and you'll start seeing lag. You're basically having every trap check if the player's x and y coordinates is the same as that trap event's coordinates every frame.

It will be especially noticeable on older PCs or phones with lower processing power.

You can do something like make the SpikeController event check the player's tile every x frames and see if that tile has another event on it (with a <spiketrap> note tag) and if the spikesOn switch is on. Then you have only one parallel event handling all the traps.
How would that be set up though? Sorry if I am making this difficult.
the way AquaEcho mentions on the setup is really close what I did,
but I use the move route before turning on the Spike Switch on the
spike traps event ID's so you see it come up before flipping and vice versa.

I have time in 3-4 hours to show what I did on my stairs.
if you want to use the region ID, use it on the spikes alone, but each
trap on parallel is something you want to avoid and use 1 parallel controller
for all the traps on that map, which is better performance.

I saw a game that use lot's of trap parallels and hard to navigate once
on that map.

Tutorials can be good to learn the basics, but it is also meant to understand
and to extend what you need.

@slickdeath97 using the snippets, for player touch, this works if you use
a lot in different place.

Spoiler: Parallel Controller on Map
this controller uses a switch "StairSlope" which you can use "Spike Trap"
to toggle on and off, use wait how you want too, as when the spikes it up, it dmg
the player on page 2. (the event is from a plateau but the effect for your trap is the same)
parallelController.png

Spoiler: Strair Slope
Strair Slope is "Player Touch" as you could use Event Touch too, page 1 is nothing,
page 2 is a common event, which where you do the dmg you want to deal with.
so multiple traps react the same.
PlayerTouch.png

Spoiler: Common Event
the common event is the same in my case, you can do damage to the player,
maybe jump back, depending on the direction they face.
CommonEvent.png

the snippet I used works in this case very effective, if you use only a few traps on the
map, the solution AquaEcho mentioned and the scripcall on the branch is more than
enough, but a region on the trap alone can suffice as you tell once its on it, it dmg
the player on the x, y where the player is.

without the region, this approach is effect and do not consume a lot of parallel,
as only 1 parallel control each trap inside the controller.

hopefully this will enlighten you more how I made my approach and how you get
yours to work how you like it to work.
I am not trying to make them damage as soon as the player touches them. I am trying to make it so when the player walks over them, they pop up and have the chance to damage the party while the party goes to the other side of them.
That's fine. My point remains that there are event commands for all of the things you're trying to use a script call for.
@slickdeath97 using the snippets, for player touch, this works if you use
a lot in different place.

Spoiler: Parallel Controller on Map
this controller uses a switch "StairSlope" which you can use "Spike Trap"
to toggle on and off, use wait how you want too, as when the spikes it up, it dmg
the player on page 2. (the event is from a plateau but the effect for your trap is the same)
View attachment 297967

Spoiler: Strair Slope
Strair Slope is "Player Touch" as you could use Event Touch too, page 1 is nothing,
page 2 is a common event, which where you do the dmg you want to deal with.
so multiple traps react the same.
View attachment 297968

Spoiler: Common Event
the common event is the same in my case, you can do damage to the player,
maybe jump back, depending on the direction they face.
View attachment 297966

the snippet I used works in this case very effective, if you use only a few traps on the
map, the solution AquaEcho mentioned and the scripcall on the branch is more than
enough, but a region on the trap alone can suffice as you tell once its on it, it dmg
the player on the x, y where the player is.

without the region, this approach is effect and do not consume a lot of parallel,
as only 1 parallel control each trap inside the controller.

hopefully this will enlighten you more how I made my approach and how you get
yours to work how you like it to work.
Ok, so I got it working that way, but two slight issues now. When the player just stands on the spikes, they deal no damage, also they don't do the movement animation, they just pop up full. How do I fix these?
1710178393911.png

1710178412892.png

1710178439433.png

1710178457945.png

1710178485519.png
Ok, so I got it working that way, but two slight issues now. When the player just stands on the spikes, they deal no damage, also they don't do the movement animation, they just pop up full. How do I fix these?
In the parallel spikeController event, right after it turns on the spikesOn switch, have it check if another event is at the player's position, activate that event's page.
the reason is it deals no dmg is because you dont use this snippet:

JavaScript:
    // Event start when not moving
    const GameEvent_setupPage = Game_Event.prototype.setupPage;
        Game_Event.prototype.setupPage = function() {
            GameEvent_setupPage.call(this);
                this.checkEventTouch();
        };

    Game_Event.prototype.checkEventTouch = function() {
        if (this._trigger == 1 || this._trigger == 2) {
            if ($gamePlayer.x == this.x && $gamePlayer.y == this.y) {
                this.start();
            }
        }
    };

I made this snippet so it does trigger when the player doesn't move,
if the player moves, it's still activated, save this code as a plugin and your good.
and it trigger when you stand still.
the reason is it deals no dmg is because you dont use this snippet:

JavaScript:
    // Event start when not moving
    const GameEvent_setupPage = Game_Event.prototype.setupPage;
        Game_Event.prototype.setupPage = function() {
            GameEvent_setupPage.call(this);
                this.checkEventTouch();
        };

    Game_Event.prototype.checkEventTouch = function() {
        if (this._trigger == 1 || this._trigger == 2) {
            if ($gamePlayer.x == this.x && $gamePlayer.y == this.y) {
                this.start();
            }
        }
    };

I made this snippet so it does trigger when the player doesn't move,
if the player moves, it's still activated, save this code as a plugin and your good.
and it trigger when you stand still.
That worked. Forgot to add it back in. Lol. How do I fix the animation part though?
That worked. Forgot to add it back in. Lol. How do I fix the animation part though?
You could put the move route you had before in an autonomous move route
the reason is it deals no dmg is because you dont use this snippet:
Just so you know, that's not necessary.

The function call from the default engine that @AquaEcho gave in post 3 will activate any player/event touch events on the player's space.
Just so you know, that's not necessary.

The function call from the default engine that @AquaEcho gave in post 3 will activate any player/event touch events on the player's space.
if its a single trap, it can work, but if you have a lot of traps, it wouldn't
be that effective to use.

if the map has 10 traps, the way I provided is more effective than using 10 parallels.
the conditional trigger is the same, no doubts, but I gave a solution that handle multiple
traps in one.
You only have one parallel event, the controller one handling all the traps. You would use that script here
In the parallel spikeController event, right after it turns on the spikesOn switch, have it check if another event is at the player's position, activate that event's page.
if its a single trap, it can work, but if you have a lot of traps, it wouldn't
be that effective to use.

if the map has 10 traps, the way I provided is more effective than using 10 parallels.
I have no idea what you're talking about.

The function call $gamePlayer.checkEventTriggerHere([1,2])
will activate any events with player or event touch triggers on the player's space.

Why would you need 10 parallel events?
So I got them working and also got it working with the region part as well, just put the region id part inside the Trap Controller event.
1710183703770.png

1710183734832.png

Now the spikes will only pop if the player is on that region.
that's why you need the region, once close, it activate the spike traps,
otherwise, it stay low or up otherwise?

glad you got it work the way you want too.
that's why you need the region, once close, it activate the spike traps,
otherwise, it stay low or up otherwise?

glad you got it work the way you want too.
I appreciate all the help. Thanks again for everything all of you.
This thread is being closed due to being solved. If you need it reopened, report it to let us know why. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/spike-trap-issue.166674/