Trouble With Making Variables Work For Me

I'm currently working through Beginning RPG Maker MV and I'm stuck on a relatively simple exercise. I am attempting to create a treasure chest that appears when I trigger enough trees linked to it.

Code for the trees is as follows:

Text : None, Window, Bottom
: : This tree looks peculiar
If : Self Switch A is OFF
Control Variables : #0001 Tree += 1
Control Self Switch : A = ON

: End


I have the Priority set on "Same as characters", the Trigger set on "Action button" and the Self-Switch A check turned on under Variables.

After that, I did a Quick Event Creation to make the chest and clicked on the Variable condition of "0001 Tree > 5"

Yet, no matter how much I reenter the programming in the trees or for the chest (including full deletion and retyping of the tree code as well as recreating the chest via Quick Event Creation) it's refusing to appear whenever I've hit enough trees.

In short, HELP!
the Trigger set on "Action button" and the Self-Switch A check turned on under Variables.
I presume you are talking about the event page conditions, in which case the page conditions are what needs to be met for the event page to become active.
According to the event snippet you posted, you don't need to enable event page conditions at all because the event command:
"if self switch A is off" is handling the "do this thing once" part of the event.
As you can see, if the self switch is off, then it will do the thing then enable self switch A. From that point forward, self switch A is on, so "if self switch A is off" will never be met, and therefore it won't trigger that portion of the event.

If this is incorrect, then you will need to post a screenshot of your event so we can better see how you have created the event.
Additionnaly to what has been said above, checking if self switch is set to OFF is a bit redundend (in this scenario).
By default, it is always OFF, meaning you can just skip that part of the code.

It can be usefull in certain conditions, especially when you are going back and forth with the selfswitches, but here it's a matter of "execute this event once".

You can rewrite it as such :
◆Text:None, Window, Bottom
:Text:This tree looks peculiar
◆Control Variables:#0001 Tree += 1
◆Erase Event


If you need that tree to be definitely put off (meaning, during the entire game), you can use the selfswitch with a second event page.
Instead of Erase Event, you want to set selfswitch A to ON
Then, create a new event page, set the conditions to self switch A, and leave the page blank.


To achieve desired result and using this logic, you will need to duplicate this event 5 times, so that the player cuts down 5 trees, resulting in the variable value being 5.
Which should then trigger your chest to appear.

If you ever doubt of the actual variable value, you can use a seperate event with a character, use the text command and make him say something like : Current variable value for Tree is : \v[1]
You will be able to see if it actually progress or not, enabling you to better target where the issue is.
The OP's tree code looks correct. I don't think using erase is a good idea because it will return once you leave the map. Besides, he didn't mention anything about cutting it down.

But I can't say for sure unless I see the treasure chest event screenshot.

There is a debug menu in playtest if you press F9 where you can check the variables.
The OP's tree code looks correct. I don't think using erase is a good idea because it will return once you leave the map. Besides, he didn't mention anything about cutting it down.

But I can't say for sure unless I see the treasure chest event screenshot.

There is a debug menu in playtest if you press F9 where you can check the variables.
I assumed cutting down the tree was the goal, but without screenshot of the event it's hard to tell what he tries to do. ^^

Erase Event would be good if he wants the trees to come back, otherwise the selfswitch to blank page is a classic solution ^^

Depends on what he tries to accomplish.
if he needs to check, he can also set another if below BEFORE selfswitch A
is on, so it checks and do whatever it needs to do.

otherwise, a parallel event (wait 10 for checks) and execute it that way.

I also recommend if you need it often or is scattered by different maps, use a common
event and use that inside the events.

in this case, if you make a mistake, you edit it once, instead of 5+ times by recopy
and paste those events 🙂

another way is spawn event to grab all of those which is also an alternative.
checking if self switch is set to OFF is a bit redundend (in this scenario).
By default, it is always OFF, meaning you can just skip that part of the code.
That doesn't appear to be correct.

The OP always wants to display the inspection text "This tree looks peculiar," but only wants to increase the tree variable the first time you interact with the tree.

So the conditional for the self switch is correctly done.

I agree that actual screenshots of all the involved events needs to be posted.
First of all, sincere thanks to everyone who responded. This is my first time actually asking for help on this program and it's nice to see such support.

Now, to address all the issues brought up in the replies:

1) Yes, I misread the Self-Switch A line and got that confused. Rest assured, it has been corrected.

2) No, I am not trying to cut down trees in this scenario, just touch them to trigger the chest's appearance.

3) As requested, I'm enclosing screenshots of the Tree code and the Treasure Chest code with this post.

I would greatly appreciate any further assistance. Thanks again!
Screenshot (1).pngScreenshot (4).png
You still have Self Switch A checked as a condition for the event page.

That means - unless you're using code someplace else to set that switch - that page will never appear.

1733859501937.png


That's what @TheAM-Dol told you in the very first reply.
Yeah, I caught right after. Sadly, even after I've removed it, it's now COMPLETELY non-responsive, doesn't even give me the text. Ideas?
Is your event in front of the tree, or on the tree? Since you have Priority "Below characters", you would have to stand on this event to trigger it.
Is your event in front of the tree, or on the tree? Since you have Priority "Below characters", you would have to stand on this event to trigger it.
On the trees, five in all. I need them to be "Same As Characters", right?
Yes, if you're trying to activate from an adjacent tile, they need to be Same as Characters.
As Zia mentioned, the event needs to be set to "same as player" in it's priority in order to be activated from an adjacent tile.
When the priority is set to below or above player, the player must be in the same grid in order to activate it.

edit:
opened this page 30 minutes ago, go distracted, didn't refresh, then replied.
Turan slow-motioned ninja'd me.
Problem solved, everyone! It's working perfectly now. Thank you again for all your help!
This thread is closed due to being indicated as solved. Make sure to report it next time, so we can see! If you need it reopened, you can report to us to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/trouble-with-making-variables-work-for-me.173807/