[XP] Teleportation Items

Started by mroedesigns, January 08, 2011, 08:38:34 am

Previous topic - Next topic

mroedesigns

January 08, 2011, 08:38:34 am Last Edit: January 09, 2011, 04:36:40 pm by mroedesigns
Teleportation Items
Authors: MRoeDesigns
Version: 1.2
Type: Custom Item System
Key Term: Custom Item System



Introduction
This script allows the player to use a certain item to be teleported to any given location. You can use script calls within events or other scripts to change the location of the teleport at any point in time.


Features

  • Allows players to be teleported using an item.




Screenshots
N/A


Demo
N/A


Script
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Teleportation Items by MRoeDesigns
# Version: 1.2
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Details ::
#
#   This script is used to create items that players can use to
#  be teleported back to certain areas.
#
# Instructions ::
#
#  Change the item number on line 50 to match the item number you want to use.
#
#   Starting at line 57, the variables control where the player is teleported
#  to. To add more locations, simply add more "when X" options.
#
#   Make sure the Item runs a common event in the database. In the common
#  event, simply put the script line "TItem.Teleport"
#
# Script Calls ::
#
#  TItem.SetLocation(ID)
#   - Sets the location ID for the item
#
#  TItem.Location?
#   - Returns the players location ID
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

class  TItem
 
  def self.SetLocation(id)
    @LocationID = id
  end
 
  def self.Location?
    return @LocationID
  end
 
  def self.Teleport
   
#   Change the Item Number here to reflect your teleport item
    if $game_party.item_number(34) == 1
     
      case TItem.Location?
   
      when 0
#      These values reflect where the player will be teleported to.
       $game_temp.player_transferring = true
       $game_temp.player_new_map_id = 01
       $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 = 02
       $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



Instructions
In the script.


Compatibility
Working on the RMX-OS controller, not yet compatible.


Credits and Thanks

  • edwardthefma for the Town Scrolls script




Author's Notes
Free to use as long as credit is given.
This is my first script, so there's bound to be bugs. Let me know if you run into any, or if you have a question about something.

G_G

This is made for RMX-OS only why?

Anyways nice job on a first script. :3

mroedesigns

Quote from: game_guy on January 09, 2011, 05:51:32 am
This is made for RMX-OS only why?

/facepalm
My bad, forgot to take that out. Originally it was used for RMX-OS, but I for some reason can't figure out how to write the controller, so that's irrelivant.
Fixed, v 1.1 :p

Quote from: game_guy on January 09, 2011, 05:51:32 am
Anyways nice job on a first script. :3

ty ^.^

G_G

Ha no problem. Also not to be a sarcastic ass, but technically there is no usable/accessible item with the id of zero. It starts at 1 and goes up. xP Just had to point that out sorry.

Futendra

I was busy eventing this o.O strange xd

Well hmm, script or event?? which would be best....

mroedesigns

Quote from: game_guy on January 09, 2011, 06:07:37 am
Ha no problem. Also not to be a sarcastic ass, but technically there is no usable/accessible item with the id of zero. It starts at 1 and goes up. xP Just had to point that out sorry.


It's not indexing through items, but rather checking the LocationID to see where it should transfer the player to.

IE in my game you have 4 different origins, or 'home towns' for players. So you can set 0 to teleport to the first hometown, 1 for the second, ect.

ForeverZer0

Good job on your first script.

One question, though. What's the point of this?
  
 def initialize
   @LocationID = 0
 end


You use singleton methods to call, so the class is never instantized, making this method worthless.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

mroedesigns

Quote from: ForeverZer0 on January 09, 2011, 04:33:07 pm
Good job on your first script.

One question, though. What's the point of this?
  
...


You use singleton methods to call, so the class is never instantized, making this method worthless.


^Shrug^ I was told to make sure I initialized it. I thought it was useless... thanks for confirming that :p

ForeverZer0

You really only need to initialize objects if they are going to be referenced in a way they have to be a specific data type.

ex.

def initialize
  @name = 'zer0'
end

def main
  if @name.length <= 3
    # Since this is calling a method of the String class, which NilClass doesn't have, it would throw an error.
  end
end


In this case you don't need to initialize it, since the method actually does that for you.


def make_name
   @name = 'zer0'
end


Unlike C languages, etc., Ruby is pretty flexible and doesn't require you to declare variables ahead of time.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

mroedesigns