¿What language you know? Is to think in what you know about programing.
Normally its better do not instantiate nothing. Thats because if you do that you have to modifiy the
scene_title to load that class, for example, and create ir globally. That sucks. If you want to use permament data for example, if you do your won class you have to modifiy the save system also.
Is better to use a module or modify a default script. Ruby modules are totally static classes. That mean that you can access its
constants variables or methods without instantiating them. If you dont need the array i suggest avoid that, because you cant modifiy its constants.
Then, dont use that class. I suggest you extending one of that global objects that already exist. Game party is the one is more interesting for you.
class Game_Party
attr_accessor :telep_item_location
alias wep_gp_mroTel_init initialize
def initialize
wep_gp_mroTel_init
@telep_item_location = 0
end
def apply_tel_item
if $game_party.item_number(34) == 1
case @telep_item_location
when 0
# These values reflect where the player will be teleported to.
$game_temp.player_transferring = true
$game_temp.player_new_map_id = 28
$game_temp.player_new_x = 8
$game_temp.player_new_y = 8
$game_temp.player_new_direction = 0
$scene = Scene_Map.new
$game_map.autoplay
return true
when 1
$game_temp.player_transferring = true
$game_temp.player_new_map_id = 28
$game_temp.player_new_x = 5
$game_temp.player_new_y = 5
$game_temp.player_new_direction = 0
$scene = Scene_Map.new
$game_map.autoplay
return true
end
end
end
end
In ruby you dont have to use set or get methods if you dont need something special. It make it automatically for you calling attr_reader :variable (for reading only), attr_writter :variable (for writing only) and attr_accessor :variable (both)
So now you can access your location variable with $game_party.telep_item_location and its still protected and encapsulated.
Also i dont know if you know what aliasing is. Its technique that overrides a method and set the original with a alias. Is useful for compatibilty and quick development. In this way you can set your variable and then call the aliased initialize method so it will add all you need without a problem. Its also better because any number of scripts can aliase consecutively this method without a problem of compatibility.
You set it with script calls. Then, you need to call that apply method in the item effect one, or in the place where its set the apply items for blizz.
Anyway, if you want to release it well, it suggest adding the teleport item id in a constant in a module. Its better than having the user move throught the script.