Saboporter
#1
Saboporter: Teleporting System
by Sabotender
Oct 6 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


My idea with this script, is to have teleporters around the world, once activated, you can teleport freely to them.


Try teleporting back and fourth. then destoy place 1, , go north, and try teleporting again.

Editing the game:
If you open the game in RMXP, you can look at all the things.
Notice how i activate the places with Switches, also i destroy them with Switches.
its easy to turn places on or off with the destroy switch.
dont turn places off by using the place switch you used to activate them,
this will completely remove them from you list.
It is better to use the destroy switch, so that they beceme greyed out.




The Script:
Here is the scripts, both are placed just above "main", first Window_sabocommand
this one isnt a must, if you choose to not have this, you will need to change some things in the main script though. the only reason this script exists, is because this is my first script! and i did this to learn a little more :alright:
Code:
class Window_sabocommand < Window_Selectable
def initialize(width, commands)
   super(260, 100, width, commands.size * 32 + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   self.contents.font.name = $fontface
   self.contents.font.size = $fontsize
   refresh
   self.index = 0
end
#--------------------------------------------------------------------------
def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i, normal_color)
   end
end
#--------------------------------------------------------------------------
def draw_item(index, color)
   self.contents.font.color = color
   rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index])
#     self.contents.draw_text(rect, @commands)
end
#--------------------------------------------------------------------------
def disable_item(index)
   draw_item(index, disabled_color)
end
end

Now comes the main script, Scene_Saboporter, this is the whole teleporting system:
Code:
class Scene_Saboporter
def initialize(menu_index = 0)
#  @menu_index = menu_index
   @portal = 1
main
end
def main
  @places = ["Exit"]
  if $game_switches[0001] == true
    @places.push "Place1"
  end
  if $game_switches[0002] == true
    @places.push "Place2"
  end
#  @placehash = {"Ammersia"=>[001, 013, 014], "Exit"=>"Exit"}
  @sabocommand_window = Window_sabocommand.new(140, @places)
#   @sabocommand_window.index = @menu_index
   @explode_p1 = false
   for i in 0..3
     if $game_switches[0003] == true #exploded nr1
       @explode_p1 = true
     end
   end
   # コンティニューが有効な場合、カーソルをコンティニューに合わせる
   # 無効な場合、コンティニューの文字をグレー表示にする
   if @explode_p1
     @sabocommand_window.disable_item(1)
   else
     @sabocommand_window.index = 0
   end
#--------------------------------
#--------------------------------
  Graphics.transition
  loop do
    Graphics.update
    Input.update
    update
    if @portal == 0
      break
    end
  end
  Graphics.freeze
  @sabocommand_window.dispose
end
#------------
def update
  @sabocommand_window.update
  if @sabocommand_window.active
    update_sabocommand
    return
  end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def update_sabocommand
     if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    @portal = 0
     $scene = Scene_Map.new
     return
    return
  end
  if Input.trigger?(Input::C)
    case @sabocommand_window.index
    when 0
      $game_system.se_play($data_system.buzzer_se)
      @portal = 0
      $scene = Scene_Map.new
      return
    when 1
       if @explode_p1
         $game_system.se_play($data_system.buzzer_se)
         return
       end
        $game_system.se_play($data_system.decision_se)
        $game_map.setup(001)
        $game_player.moveto(016, 006)
        $game_player.refresh
        $game_map.autoplay
        $game_map.update
        $scene = Scene_Map.new
       @portal = 0
        return
    when 2
        $game_system.se_play($data_system.decision_se)
        $game_map.setup(002)
        $game_player.moveto(015, 014)
        $game_player.refresh
        $game_map.autoplay
        $game_map.update
        $scene = Scene_Map.new
       @portal = 0
        return
    end
    return
  end
end
end

If you are a scripter you can see, i based it on one of the original menus tongue.gif
Also, you can see that i tried using Hashes, but failed


Editing the script:
to add more places, or change their names, check out this bit:
Code:
def main
  @places = ["Exit"]
  if $game_switches[0001] == true
    @places.push "Place1"
  end
  if $game_switches[0002] == true
    @places.push "Place2"
  end

This is where you add places, shouldnt be too hard to figure out :alright:

to add the ability to destroy places, check out this bit:
Code:
for i in 0..3
     if $game_switches[0003] == true #exploded nr1
       @explode_p1 = true
     end
   end

and
Code:
if @explode_p1
     @sabocommand_window.disable_item(1)
   else

item(0) is the exit button
item(1) is the first place in the list
item(2) is the second place in the list
and so on


the end:
thanks you all for everything! as i am not a scripter, i just like to experiment, this isnt a 100% perfect script, but it should work in most games. However, if someone comes accross any major problems, please say so here, and perhaps a better scripter will come and help.
Good luck, and i hope you enjoy this little script of mine ^^
}




Users browsing this thread: 1 Guest(s)