Creative_AUG
Member
Map Specific Variables Version: 1
By: Creative_AUG
Introduction
Basically this is a simple script that sets a variable up for each map. Depending on which in-game variable you choose to correspond to it, you can manipulate that variable using the event commands. The variable will retain it's value when you switch maps and return but a new map's variable will always be zero.
So simply put, each map will have it's own variable that you can manipulate, allowing you to cut back on usage of the in-game variables and simplifying events and event conditions. The script allows you link maps as well, allowing you to be able to retain values within a certain map group. This is useful if you map a village for example. Events inside the house maps in those villages can respond to the map specific variable and even manipulate it.
Features
Screenshots
none.
Demo
none.
Script
Instructions
The first two lines of the script:
MAP_SPECIFIC_VARIABLE_ID specifies which in-game variables manipulate the map specific ones. In-Game Variable 99 and 100 can be used to manipulate the map specific ones. to add more, simply add a comma, followed by another variable ID number.
LINKED_MAPS specifies the maps that are linked together. Map IDs 10,9 and 3 are linked together and share the same map specific variable. to add more links, be careful to add a separate array. for example:
LINKED_MAPS = [[1,2,3],[4,5],[7,3,4]]
This would indicate that map ID 1,2 & 3 are linked together. Map ID 4 and 5 are linked together and 7, 3 and 4 are linked together. Remember that having 1 map linked with 2 separate groups may cause your game to be buggy. Be careful to use separate variables for maps that are shared like that.
FAQ
none.
Compatibility
This script completely rewrites the Game_Variables class. Any script that manipulates the class or uses it, may not work.
Credits and Thanks
none.
Author's Notes
none.
Terms and Conditions
Have fun with this. I pray it's helpful.
By: Creative_AUG
Introduction
Basically this is a simple script that sets a variable up for each map. Depending on which in-game variable you choose to correspond to it, you can manipulate that variable using the event commands. The variable will retain it's value when you switch maps and return but a new map's variable will always be zero.
So simply put, each map will have it's own variable that you can manipulate, allowing you to cut back on usage of the in-game variables and simplifying events and event conditions. The script allows you link maps as well, allowing you to be able to retain values within a certain map group. This is useful if you map a village for example. Events inside the house maps in those villages can respond to the map specific variable and even manipulate it.
Features
- Allows Map Specific Variables that are unique to the map.
- Allows you to link maps that you want to share a variable with.
- Can be manipulated easily through regular in-game variable-based event calls
Screenshots
none.
Demo
none.
Script
Code:
MAP_SPECIFIC_VARIABLE_ID = [99,100]
LINKED_MAPS = [[10,9,3]]
class Game_Map
attr_accessor :variable
attr_accessor :map_id
alias map_specific initialize
alias map_specific2 setup
def initialize
@variable = []
map_specific
end
end
class Game_Variables
def [](variable_id)
id = $game_map.map_id
if variable_id <= 5000 and @data[variable_id] != nil
if MAP_SPECIFIC_VARIABLE_ID.include?(variable_id)
if $game_map.variable[id] != nil
return $game_map.variable[id]
else
$game_map.variable[id] = 0
return 0
end
else
return @data[variable_id]
end
else
return 0
end
end
def []=(variable_id, value)
id = $game_map.map_id
if variable_id <= 5000
if MAP_SPECIFIC_VARIABLE_ID.include?(variable_id)
@data[variable_id] = value
maps = []
LINKED_MAPS.each {|link|
if link.include?(id)
for i in 0...link.size
maps.push(link[i])
end
else
maps = false
end
}
#print(maps.to_s)
if maps == false
$game_map.variable[id] = value
else
for i in 0...maps.size
$game_map.variable[maps[i]] = value
end
end
else
@data[variable_id] = value
end
end
end
end
Instructions
The first two lines of the script:
Code:
MAP_SPECIFIC_VARIABLE_ID = [99,100]
LINKED_MAPS = [[10,9,3]]
MAP_SPECIFIC_VARIABLE_ID specifies which in-game variables manipulate the map specific ones. In-Game Variable 99 and 100 can be used to manipulate the map specific ones. to add more, simply add a comma, followed by another variable ID number.
LINKED_MAPS specifies the maps that are linked together. Map IDs 10,9 and 3 are linked together and share the same map specific variable. to add more links, be careful to add a separate array. for example:
LINKED_MAPS = [[1,2,3],[4,5],[7,3,4]]
This would indicate that map ID 1,2 & 3 are linked together. Map ID 4 and 5 are linked together and 7, 3 and 4 are linked together. Remember that having 1 map linked with 2 separate groups may cause your game to be buggy. Be careful to use separate variables for maps that are shared like that.
FAQ
none.
Compatibility
This script completely rewrites the Game_Variables class. Any script that manipulates the class or uses it, may not work.
Credits and Thanks
none.
Author's Notes
none.
Terms and Conditions
Have fun with this. I pray it's helpful.