Introduction
Introducing MapSwitch! This script will activate switches automatically on entering specified maps. It also deactivates when leaving specified maps.
Features
Activates a particular switch when entering specified maps. Also deactivates switches when entering a map not specified.
=begin
????????????????????????????????????????????????????????????????????????????????
? Map Switches ?
? By Punk ?
? http://Punkid89.b1.jcink.com ?
? 7/7/2008 ?
????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
? ? Author's Notes: ?
? ?? While I was working on an event system, I started thinking about making a ?
? script which would turn on a switch whenever the player is on a certain ?
? map. ?
? During the making of this script, I learned something new... ?
? Constants! And Aliases! ?
????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
? ? Description: ?
? ?? The game creator can set what switch would turn on whenever the player is ?
? in a certain map. ?
? ? Credits: ?
? ??? Syvkal & Digi: Talking about $game_map.map_id. ?
? ??? Kurisu & Syvkal: Helping me out with Aliases and setting them up. ?
? ??? Trickster: He told me about constants and made my code less messy. ?
????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
? ? Things to know about: ?
? ?? PUNK_MAP_IDS: Setting up which Map IDs would turn on PUNK_MAP_SWITCH_ID. ?
? ?? PUNK_MAP_SWITCH_ID: This switch would turn on if the player happens to be ?
? in a map that is in the PUNK_MAP_IDS array. If the ?
? player is in a map ID that isn't in the PUNK_MAP_IDS ?
? array, the switch would turn off. ?
????????????????????????????????????????????????????????????????????????????????
? ? Want to add another PUNK_MAP_IDS and PUNK_MAP_SWITCH_ID set of constants? ?
? ?
? ?????????????????????????????????????????????????????????????????????????? ?
? ? Below line 61, add these two lines. Be sure to append a number at the ? ?
? ? end of the constants so they can be easy to identify. (Example: _2) ? ?
? ? Use comment marks if you have to. ? ?
? ?????????????????????????????????????????????????????????????????????????? ?
? ? ? Add these below line #61. Remember to append! (Ex: _2) ? ? ?
? ? ?????????????????????????????????????????????????????????? ? ?
? ?PUNK_MAP_IDS_2 = [7,9] # Map IDs Set 2 ? ?
? ?PUNK_MAP_SWITCH_ID_2 = 3 # Switch ID Set 2 ? ?
? ?????????????????????????????????????????????????????????????????????????? ?
? ? Below line #77, add the line below this box. It's quite long. So you'll? ?
? ? have to excuse me while I stretch the instruction box below. ? ?
? ? The constants within the line you'll have to paste must be the same as ? ?
? ? the constants pasted below line #61. ? ?
? ?????????????????????????????????????????????????????????????????????????? ?
? ? ? Add this below line #77. Remember to append! (Ex: _2) ? ? ?????????
? ? ?????????????????????????????????????????????????????????? ??????????????
? ?$game_switches[PUNK_MAP_SWITCH_ID_2] = PUNK_MAP_IDS_2.include?($game_map.map_id)??
? ???????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????
=end
class Scene_Map
#==[Configuration]
PUNK_MAP_IDS = [1,2,3] # Map IDs
PUNK_MAP_SWITCH_ID = 1 # Switch ID
#--<add more>--#
#==[End Configuration]
alias punk_main main
def main
punk_switch_check
punk_main
end
alias punk_transfer_player transfer_player
def transfer_player
punk_transfer_player
punk_switch_check
end
def punk_switch_check
$game_switches[PUNK_MAP_SWITCH_ID] = PUNK_MAP_IDS.include?($game_map.map_id)
#--<add more>--#
end
end
Instructions
I hope that I worded them correctly. Hopefully the instructions are easy to follow.
Lines 26 - 31 are about the constants "PUNK_MAP_IDS" and "PUNK_MAP_SWITCH_IDS"
Lines 33 - 52 are about adding another set of constants in case one may just not be enough.
Paste the Mapswitch XP script above main.
FAQ
Awaiting question.
Compatibility & Aliases
I have not checked the SDK. I think it's highly likely to be compatible.
Aliases
main
transfer_player
Credits and Thanks Syvkal & Digi: for talking about $game_map.map_id. When they first spoke of it, I was confused. Syvkal & Kurisu: Explaining Aliases. Mac/Chrono Cry: Helping out. Trickster: Pointing out better ways to code it (code cleaning). I also learned Constants from him.
Author's Notes
When I was working on an event system, an idea just *pop* came into my head. Of course there were evented ways to track down a players map ID and (de)activate switches depending on what map s/he's in but... that takes too much time and I don't want to event something like that for an event system I was working on.
As you can probably see, I spent a little more time decorating and typing the instructions than making this short script. This is the first time I did a script "storyboard". This is my first script/resource of my fourth year being in the RPG Maker community. This is the first time I've learned and made use of aliases, arrays and constants.
Terms and Conditions
Please credit Punk. Please! In my three years in the RM community, I have not seen my handle in any credits. *goes down on his knees and begs* This would mean a lot. Thanks for using this script!