08-02-2020, 02:39 AM
(This post was last modified: 08-22-2020, 03:06 AM by kyonides.
Edit Reason: toggle_switch added
)
General Methods for XP + VX + ACE
Sometimes people show up complaining about their inability to easily setup self switches in a script call event command.
Well, here's a quick way to get its current value or set a new one.
Since we're using scripts here, you can use any letter you can think off as an self switch ID element.
Keep in mind the default implementation requires you to provide an array of 3 elements as a key to find that self switch.
This scriptlet allows you to only set those elements you really care about at any given time.
For XP
Code:
class Interpreter
def self_switch(char, ev_id=0)
ev_id = @event_id if ev_id == 0
$game_self_switches[[@map_id, ev_id, char]]
end
def set_self_switch(char, value, ev_id=0)
ev_id = @event_id if ev_id == 0
$game_self_switches[[@map_id, ev_id, char]] = value
end
def toggle_switch(char, ev_id=0)
ev_id = @event_id if ev_id == 0
key = [@map_id, ev_id, char]
$game_self_switches[key] = !$game_self_switches[key]
end
end
For VX or ACE
Code:
class Game_Interpreter
def self_switch(char, ev_id=0)
ev_id = @event_id if ev_id == 0
$game_self_switches[[@map_id, ev_id, char]]
end
def set_self_switch(char, value, ev_id=0)
ev_id = @event_id if ev_id == 0
$game_self_switches[[@map_id, ev_id, char]] = value
end
def toggle_switch(char, ev_id=0)
ev_id = @event_id if ev_id == 0
key = [@map_id, ev_id, char]
$game_self_switches[key] = !$game_self_switches[key]
end
end
To get its current state:
self_switch('C')
To set it to a different state:
set_self_switch('C', false)
To toggle it:
toggle_switch('C")
toggle_switch('C", 21)
Add another parameter at the end, in both cases, to select a different map event.
The advantage is that you no longer need to include thisEvent, thus saving valuable space there. Plus you get the chance to use it for any map event...
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE