Help - Search - Members - Calendar
Full Version: Complete, but not working
RPG RPG Revolution Forums > Scripting > Script Development and Support
DUFUTA
CODE
#                          $$$$$$$$$$$$$$$$$$$$$$$$$$$$
#                              DUFUTAS_Teleportation
#                                   By: Dufuta
#                          $$$$$$$$$$$$$$$$$$$$$$$$$$$$
#
#This script will allow you to 'teleport' on the game map.  That is, you'll
#disappear from one place, and pop up in another.
#
#CUSTOMIZATION BEGIN=======================================================
#
#
module NQ
  module Telemove
  TELESWITCH = 2        #game switch which activates the teleportation
  TELERANGE = 6         #game variable which tracks max range of teleportation
  TELESOUND = "Magic"   #SE to play when teleporting
  TELEANIMATION = 5     #Animation to play when teleporting
  TELEITEMS = [1, 2, 3]        #Items which allow teleportation when located in inventory
  TELECLASS = [1, 2, 3]        #Class which gives benefit of teleportation
  TELEARMOR = [1, 2, 3]        #Armor which allows teleportation when equipped
  TELEPUT = Input::L    #Input used to teleport
end
end

#CUSTOMIZATION END===========================================================

include NQ::Telemove
#=============================================================================
class Dufuta_Teleportation

  attr_accessor :origion_x
  attr_accessor :origion_y
  attr_accessor :tempx
  attr_accessor :tempy
  attr_accessor :range
  
  def initialize_dufuta
    setup          #call setup
    @origin_x = 0   #player's map x
    @origin_y = 0   #player's map y
    @temp_x = 0      #used to determine if targetted spot's x is accessible
    @temp_y = 0      #used to determine if targetted spot's y is accessible
    @range = 0        #used to determine if targetted spot's x and y are in range
    if $game_switches[NQ::Telemove::TELESWITCH] == true    
      activate         #calls activation updating
  else
    return
  end
  
  def setup      #checks to see if conditions apply for switch to be activated
    if NQ::Telemove::TELEITEMS.include?(RPG::BaseItem(id))
      $game_switches[NQ::Telemove::TELESWITCH] = true
    elsif NQ::Telemove::TELECLASS.include?($game_actors.class_id)
      $game_switches[NQ::Telemove::TELESWITCH] = true
    elsif NQ::Telemove::TELEARMOR.include?($game_actors.armor1_id)
      $game_switches[NQ::Telemove::TELESWITCH] = true
    elsif NQ::Telemove::TELEARMOR.include?($game_actors.armor2_id)
      $game_switches[NQ::Telemove::TELESWITCH] = true
    elsif NQ::Telemove::TELEARMOR.include?($game_actors.armor3_id)
      $game_switches[NQ::Telemove::TELESWITCH] = true
    elsif NQ::Telemove::TELEARMOR.include?($game_actors.armor4_id)
      $game_switches[NQ::Telemove::TELESWITCH] = true
    end
  end
end

  
  def activate    #seeks player input and if designated key is pressed
    if Input.trigger?(Input::NQ::Telemove::TELEPUT)
      determine_origin
      set_range
      change_graphic
      allow_target
    end
  end
  
  def determine_origin     #sets original position of player
    @originx = $game_player.x
    @originy = $game_player.y
  end
  
  def set range            #sets range according to pre-defined constant
    @range = @originx + $game_variables[NQ::Telemove::TELERANGE]
  end
  
  def change_graphic          #changes graphic to display targetting graphic
    Sound.play(NQ::Telemove::TELESOUND)
    character.animation_id(NQ::Telemove::TELEANIMATION)
    $game_actor.set_graphic($game_party.members[0], '$!Teleporter', 3, 0)
    $game_player.through = true
  end
  
  def allow_target            #waits for player input and reacts
    if Input.trigger?(Input::Left)
      Sound.play('Decision1', 85, 150)
    elsif
      Input.trigger?(Input::Up)
      Sound.play('Decision1', 85, 150)
    elsif
      Input.trigger?(Input::Down)
      Sound.play('Decision1', 85, 150)
    elsif
      Input.trigger?(Input::Right)
      Sound.play('Decision1', 85, 150)
    elsif
      Input.trigger?(Input::NQ::Telemove::TELEPUT)
      compare_rangex
    elsif
      Input.trigger?(Input::B)
      Sound.play('Buzzer')
      $game_actor.set_graphic(0, @params[1], @params[2], @params[3])
      $game_player.through = false
      initialize_dufuta
    end
    
    def compare_rangex         #gets targets x
      @tempx = $game_player.x
      if $game_map.loop_horizontal?
        if @tempx.abs > $game_map.width / 2
          @tempx -= $game_map.width
        end
      end
      return @tempx
      compare_rangey
    end
    
    def compare_rangey        #gets targets y
      @tempy = $game_player.x
      if $game_map.loop_vertical?
        if @tempy.abs > $game_map.height / 2
          @tempy -= $game_map.height
        end
      end
      return @tempy
      result_comparison
    end
    
    
    def result_comparison         #compares x and y with range
      if @tempx <= @range
        if @tempy <= @range
          determine_passable
        else
          Sound.play('Buzzer2')
          $game_actor.set_graphic(0, @params[1], @params[2], @params[3])
          $game_player.through = false
          initialize_dufuta
        end
      end
    end
    
    def determine_passable            #checks for target passability
      if $game_map.passable?(x, y) == true
        reappear
      else
        Sound.play('Buzzer2')
        $game_actor.set_graphic(0, @params[1], @params[2], @params[3])
        $game_player.through = false
        initialize_dufuta
      end
    end
    
    def reappear                    #player reappears and retransforms
      Sound.play('NQ::Telemove::TELESOUND')
      character.animation_id(NQ::Telemove::TELEANIMATION)
      $game_actor.set_graphic(0, @params[1], @params[2], @params[3])
      $game_player.through = false
      initialize_dufuta
     end
   end
end
This script is supposed to activate a switch at the beginning, but it doesn't for some reason. And therefor, the rest of the script, which runs off of that switch never gets called.

On a side note, Do I have to create a call for this script, or is there a call I could already use to activate the switch?
diss
i'm not that good at scripting but couldn't you just turn that switch on with an event?
DUFUTA
QUOTE (diss @ Aug 6 2011, 11:29 AM) *
i'm not that good at scripting but couldn't you just turn that switch on with an event?



I tried the manual approach. It didn't work. I'm not doing something right. Think I might have my the script set up wrong. Not real good at it myself.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.