Quick question - How would I toggle a switch if you have all FTB turns left?

Basically I want to have a switch turned ON when, in battle, you have all of your FTB actions remaining

(using Yanfly's Free Turn Battle: http://yanflychannel.wordpress.com/rmvxa/battle-scripts/ace-battle-engine/battle-system-free-turn-battle/)

and it to be turned OFF when any less than all of your FTB actions are remaining.

Example: 3 party members = 3 actions.

The switch is ON by default.

I have one member use "attack" and have 2 actions left.

The switch is OFF.

I make the other two "attack", the enemies attack, and it is the player's turn once again and all actions are restored.

The switch is ON.

Thank you.
To toggle a switch, you just say $game_switches[id] = !$game_switches[id].


WHERE and WHEN you make that happen depends on the battle system. If it's part of the standard attack skill, you'd just enter that into the formula before what's already there, and separate them with a colon - ;


So it'll be

$game_switches[id] = !$game_switches[id]; <old attack formula here>However, if you want this to toggle with each attack by a party member, your first attack will turn it OFF, the second will turn it ON, and the third will turn it OFF (your example just toggles it once, even though two party members have had their turn).
If you ONLY want it to toggle when one of your party members attacks (and not an enemy), you would have to add that into the formula as a condition:

Code:
$game_switches[id] = !$game_switches[id] if a.actor?; <old attack formula here>
I haven't looked at the script. If the above is not enough, and you have to configure it especially for the script, or as part of the script, then a different approach may be needed.
Thanks for your help!

But how would I set a switch to a Boolean instead of toggling it?

$game_switches[id]=false didn't seem to work.
It should have. Where did you do it? You did replace id with the number of the switch, right?


Toggling IS setting it to a boolean. If $game_switches[id] is true, then !$game_switches[id] is false.
Haha, yes I changed id to 15, as that is the switch in question. ($game_switches[15]=false) I'm not that stupid...

I know toggling is setting it to a boolean, but I meant I needed to literally set it to true or false because I didn't want the switch to change back and forth each time, only set it false under certain conditions and set it true under other conditions. 

As it turns out, my syntax wasn't incorrect but I had put one of the lines of code in the wrong place so it just appeared it wasn't working properly. Now I've got it in the right place and it works great. Thanks a ton for your help Shaz! You can close this now. 
I'm not that stupid...
lol - well, I like to make that assumption. But once when someone was having a problem, that's exactly what caused it 😀 So now I have to add it, just to make sure 😉


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/quick-question-how-would-i-toggle-a-switch-if-you-have-all-ftb-turns-left.20249/