Check if Selfswitch in ON in Common Event?

Eraine

Veteran
Veteran
Joined
Sep 9, 2016
Messages
70
Reaction score
93
First Language
Dutch
Primarily Uses
RMMV
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!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Eraine

Veteran
Veteran
Joined
Sep 9, 2016
Messages
70
Reaction score
93
First Language
Dutch
Primarily Uses
RMMV
Thanks @Shaz ! That was what I was looking for :)
I am using a common event because I use a day/night cycle and reset resources (if needing a reset) in a "sleep" event, which is the common event I was talking about. So I'm not calling the common event from the event itself and therefore needed to know how to check the selfswitch status of said event.
(And it's not just one resource-event that needs resetting, it's about a 100 of them (different types of resources). So I figured doing this from a common event helps keep overview. Because then there's no need to doublecheck all of these resources on all of the maps if anything related to tehm changes, since they are in one list in the common event. It also prevents accidentaly resetting some of them multiple times, because I'm sure they will only be reset if the common event is called.)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Why not use a regular switch instead of changing so many self switches?
 

Eraine

Veteran
Veteran
Joined
Sep 9, 2016
Messages
70
Reaction score
93
First Language
Dutch
Primarily Uses
RMMV
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! ;)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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.
 

Eraine

Veteran
Veteran
Joined
Sep 9, 2016
Messages
70
Reaction score
93
First Language
Dutch
Primarily Uses
RMMV
@Shaz I thought I explained that I only wanted to reset the events that had been "used" (and thus not all of them every time) in the first post, but I can see how that was not very clear.
Anyways, I got it working the way I wanted it to now, because of your help, so thank you very much!! :)

@Engr. Adiktuzmiko Yes, that is the point, thanks for helping me explaining the situation! (oh, and actually, I'm a "she" ;))

This question is answered, so the topic can be closed!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top