Help, i need variable to stop counting

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
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?
 

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
53
Reaction score
24
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited:

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
53
Reaction score
24
First Language
English
Primarily Uses
RMVXA
I have edited the script call in my post above. That should work in the move route.
 

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
:) 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!) :)
 

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
:D 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
 
Last edited:

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
53
Reaction score
24
First Language
English
Primarily Uses
RMVXA
Okay, sorry that didn't work I was looking for an easy solution.

Will have to do something more complex. You will have to make a seperate parallel processing event that captures the events location. It looks like this:

1600302999853.png

Then make a conditional branch in the move event. If the event is at a high enough Y location (at the wall) it won't add the variable.
 

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
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?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
667
Reaction score
431
First Language
English
Primarily Uses
RMVXA
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.
 

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
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
 

Attachments

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
53
Reaction score
24
First Language
English
Primarily Uses
RMVXA
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.
Hey RPG Sandwhich.

I would edit that conditional branch for just the Y variable. Does that work if you only do just the Y variable? I want to test and see if it does it.
 

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
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
 
Last edited:

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
53
Reaction score
24
First Language
English
Primarily Uses
RMVXA
Ok no worries let me know. I’m sure it’s closer.
 

rpgsandwich

Villager
Member
Joined
Aug 30, 2020
Messages
11
Reaction score
4
First Language
English
Primarily Uses
RMVXA
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!
 

Attachments

Last edited:

BrentBAM

Veteran
Veteran
Joined
Jul 22, 2020
Messages
53
Reaction score
24
First Language
English
Primarily Uses
RMVXA
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!
Great to hear! So glad it worked! Pretty awesome.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Ami
--- Currency ---

Hero: This city cannot accept Gold to buy the items.
Merchant: You can exchange Gold into TC,depending the rate of TC this time.
Hero: Really? Then,i want to exchange 999999999G.
Merchant: Let's see……Wait a second,are you Cheating again?
Hero: Hell No!!! I earn it with myself!!!
There's always a time when you're super excited to create something but you already have no energy left. :I
I think of all the effects in my game, the light passing through fog has got to be my favorite....

...Also I spent all day trying to figure out how I had suddenly messed it up and made it start dropping frames like crazy. So I had all day to look at it... mocking me... with it's previous 60fps reduced to 30fps... At least it's fixed now.
Dalph wrote on slimmmeiske2's profile.
Slimmm, we should team one day and make "Reid in Wonderland" or "Aluxes in boots".

Forum statistics

Threads
103,480
Messages
999,651
Members
135,028
Latest member
DOAmaster
Top