I want to know if there is a scriptcall to check if a certain events selfswitch is ON that I can use in a common event. Maybe a call I can use in the conditional branch/script section?
I know how to switch an events selfswitch by a scriptcall in a common event, but I only want to switch it off and reset the variable tied to that event if the selfswitch is actually on. Is there a way to do that?
(Hope this is clear enough. It's for a harvesting mechanism, using Galv's Tools, therefore the harvesting part is run from a common event. I only want to reset the resource state if the resource is harvested.)
Thanks in advance!
Why are you doing it in a common event? Normally a common event is called from a number of other events, using the Common Event command. When you do it this way, the common event acts like an extension to the event that's calling it - it has the event's id - so you can use Conditional Branch > if Self Switch X is ON, and it will look at that event's self switch.
If it's not being called from the event you want to check, then you have to use a script call to look up the self switch of that event. If it's just one particular event on one particular map you can hardcode the numbers. But if it could be any one of a number of events and/or maps, you would likely use variables. Anyway, here's a starting point ...
In Conditional Branch, go to the Script box, and type $gameSelfSwitches.value([map, event, selfswitch]) which will be true if the self switch is on. Replace map, event and selfswitch with the appropriate values, no leading zeros. For example: $gameSelfSwitches.value([18, 5, 'A']) to see if self switch A is on for event 5 on map 18.
Why not use a regular switch instead of changing so many self switches?
That would require a switch for each resource, so a whole lot of switches, because I wouldn't know which resources the player would have gathered, and which not, so I couldn't check that with just one switch. Is there an advantage to using switches instead of selfswitches?
Besides, I'm using Glav's Tool plugin, and that contains code that turns a selfswitch on when "using" the tool on a resource (to prevent unlimited resources). And I'm no scripter at all, so I wouldn't know how to change that! 😉
Only if you want lots of things to do something at the same time. You didn't indicate that you only want to reset some of them and not all of them.
Since he is using Galv's tools which uses a self-switch per resource when gathered, he does need to stick with self switches even if he wanted to reset them all in one go.
It goes like this:
You have a resource (event)
You use a tool registered in Galv's plugin
Galv's plugin now activates a self switch on the resource event to denote that it is "gathered"
So in order to reset that event (or even all of them at the same time, amount doesn't really matter), he needs to tap the self switches that Galv's system activated.