I have an EVENT "A"
I have it setup if i hold the "L" button, and press "UP", Event "A" moves up one tile.
each time it moves, it adds +1 to a variable "Step Counter"
it works fine: hold L, press up, the event moves up, and adds 1 to the "step Counter"
EXCEPT, when the event ends up hitting a wall (or impassible tile), the counter rapidly increases, but the "EVENT A" doesnt move (as its up against an impassible tile... note: the "Skip if cannot move" is checked on)
I understand whats happening:
Conditional branch:
IF "UP" is being pressed
move "EVENT A" up (skip if cannot move)
Add +1 to variable "step counter"
^^ its detecting the UP press, it tries to move, but cannot, and it moves on to +1 to step counter
How can i make it so that when the event hits the wall, it stops counting?
Hello. I have a random thought.
could you script call the variable change within the move route itself?
use
$game_variables[X] = $game_variables[X] + 1
That way if it bumps into the wall, the movement route is skipped and the script call is skipped. So the variable won't add if it hits the wall.
I have edited the script call in my post above. That should work in the move route.
🙂 thanks for the reply
so, im just getting started on learning scripts...
Your idea sounds like it could work,
so i tried what you suggested, (i think) but im getting the same results.
This is how i originally had it:
EV002 "CONTROLLER EVENT"
Trigger: Player Touch
Contents:
@>Set Move Route: [EV001 PLAYER] (Skip, Wait)
: :$>Move Up
@>Control Variables: [0001:counter] +=1
@>
This is how i thought you meant:
EV002 "CONTROLLER EVENT"
Trigger: Player Touch
Contents:
@>Set Move Route: [EV001 PLAYER] (Skip, Wait)
: :$>Move Up
: :$>Script: $game_variables[01] = $game_variables[01] +1
======================================
so, this is what i did, and i didnt notice any change, perhaps im doing something wrong?
Question: the var[X] you mentioned, should both be the same variable, like ive done above?
Also,: when i insert the variable number, is [0001] the same as [01]?
Thank you, im going to keep messing with this, as it really sounds like a solution for me, but if you could help correct me, im new to scripts (been trying to learn!) 🙂
😀 hey, i just realized though, this IS adding to my counter!! so, it looks like i've got the script call somewhat working (a first for me)
but its still raising the "step counter" variable when i hit a wall, like before...
maybe i have it in the wrong place?
in the "Set move route" it seems to be performing:
Move
+1 to counter script
but only canceling the move, and not canceling the script
***EDIT,
i just noticed the 'tooltip' on "Skip if cannot Move":
"skips any command that would move a character or event into
an impassable location" < so this suggests it only affects movement
hmmm... so, do i need to define where each wall is for this to work?
it seems like this is "if event coordinate = X, do not add?
then i would have to define every wall, in every map, is that so?
You need to compare the event's X and Y position after the move to their X and Y position before the move. If either is different, then you add to the counter variable.
In the conditional branch for the button press, set variable 1 to event's X pos and set variable 2 to event's Y pos. After the move route, set variable 3 to the event's X pos and variable 4 to the event's Y pos. Create another conditional branch that checks if variable 1 does not equal variable 3, or if variable 2 does not equal variable 4. Inside that conditional branch, increase the counter.
Im not sure im getting this...
Im understanding is that variableYa, is linked to the EVENT position
then, im not sure, but, to me it looks like you'd have me link 'variableYb' to EVENT position
and then compare them, but... its always the same position.. when the EVENT moves, it updates both
'variableYa', and 'variableYb' to the Events location...
I've attached a screenshot of what i have, to my understanding.
Very sorry for the confusion here... i am grateful
Also, BRENTBAM; i've never even noticed the REGION ID button before, im looking into its function now,
and will play around and try that next. THANK YOU
oh yea, i've only been working with the Y axis
im sorry, im a little burned out.. im startin to run through all this logically in my head...
im sure i can get this... i was REALLY hoping that first suggestion would work, with the script...
I didnt want to waste VARIABLES on this part, but i remembered i already have 4 FREE Variables linking to the Events position... and now that i think I believe i have already fixed this problem in another project from a few months ago... ill have to check that out...
sorry, im really burned out right now, i cant think straight... lol...
BUT yea, it works the same on the Y axis only...
Everytime the event moves, it updates "VarYa," and "VarYb" to be the same coordinates.
but, if I take "VarYa", and i give it a +1 at some point, that SHOULD make the 2 VAR different, until the next frame, where it will update back to being the same.... my problem now is SORTING, so im going to ponder that right now...
THANKS guys, ill let u know if i figure this out
Ok no worries let me know. I’m sure it’s closer.
Ok guys, Ive figured it out, works great now...
So,
VarYa = EVENT Y coord
VarYb = EVENT Y coord, tied to a switch
... hard to explain, but basically, the coordinate "A" was either constantly following "B"
or, it was constantly +1 of "b"
I needed "A" and "B" coords, follow each other, but when i hit the wall, "A" is automatically tied to me, while "B" is only tied to me when i initiate movement, then switch goes off.... they follow each other, untill i hit a wall, and B keeps going.... then, if "B" gets MORE than +1 of "A",, to reset to its original Event position...
ill add a screenshot, but my naming conventions are different from my examples here,
Im having a hard time explaining, but i can say all your advise helped put me in the right direction.
I believe, all that was missing was, i needed a switch for Var"B"....
Thank you Thank you Thank you!