diagostimo's rgss noob questions

Started by diagostimo, April 17, 2012, 06:37:29 am

Previous topic - Next topic

diagostimo

April 30, 2012, 11:49:52 pm #40 Last Edit: May 02, 2012, 08:04:03 pm by diagostimo
at the end of my config else''

heres the part that calls the window:
if Config::TELE_WINDOW == true
         tele = Config.tele_config(@index)
         if tele == ''
           $scene = Scene_Index.new(@index)
           $game_system.se_play($data_system.decision_se)
         else
           $scene = Scene_Tele.new
           $game_system.se_play($data_system.decision_se)
         end
       else
          $scene = Scene_Index.new(@index)
          $game_system.se_play($data_system.decision_se)
       end
     end

notice if  Config.tele_config == '' then it bypasses the scene, it does this corectly, the fact is im calling the scene from index 193 and im getting the error when trying to use the teleport

edit:
i have figured out why its getting the wrong values, it is going by the else condition instead of the index, here is what happens exactly in the scene:
you open the map
when you press the c button on a location(index) it checks if teleporting function is on
if teleporting function is on it creates a new command window
the command window has a teleporting selection and another to view a window of the location
when the teleporting selection is selected it should transfer you according to the index of the map window(previous window to this)

i set a value for the else and it transfered me to where i specified, even though i had accessed the transfer method from a index point specified in the config :/
----------------------------
above issue resolved
----------------------------

diagostimo

hey people, im having an issue relating to my teleporting function, i have got it to work, what im trying to do now is make it so i can disable the selection to teleport, i have tryed making it like how the save option is disabled, heres what i have got,
i added this to Game_System:
attr_accessor :tele_disabled

then i added this to the initialization in game_system:
@tele_disabled = false

then i add into my script if conditions checking if the tele option is disabled or not, and i enable and disable it in an event like so:

@>condition branch: script: $game_system.tele_disabled == true   
    @>text: enable teleport?
    @>choices: yes, no
      :  when [yes]
        @>script: $game_system.tele_disabled = false
      :  when [no]
        @>
      : branch end
    @>
  : Else     
     @>text: disable teleport?
     @>choices: yes, no
       :  when [yes]
         @>script: $game_system.tele_disabled = true
       :  when [no]
         @>
       : branch end
     @>
   : branch end
@>

------------
the problem im having with this is when the game first starts up the teleporting is enabled and works fine, then when i activate the event to enable or disable it i can disable it fine, and it disables in the menu, then when i activate the event again it reconizes that teleporting is disabled and asks if you want to enable it, when i choose the option yes i the game hangs, it does not crash just hangs :/

Ryex

I believe this is related to a bug in RMXP when setting something to false via a call script. there is a fix for that somewhere.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

diagostimo

thanks i found it, and that sorted it :)

diagostimo

hey guys, i have been trying to figure out how i could implement a way to disable teleport locations via script call, the way i have my teleport set up is i have a command window pop up asking if you want to teleport or just search the map, like this:
def main
    # Make command window
    s1 = "teleport"
    s2 = "location info"
    @tele_window = Window_Command.new(120, [s1, s2])
    @tele_window.index = @tele_index
    @tele_window.x = 0
    @tele_window.y = 0
    #new sprite (background)
    @sprite = Sprite.new
     #set sprite image
    @sprite.bitmap = RPG::Cache.picture(Config::MAP_NAME)
    if $game_system.tele_disabled
      @tele_window.disable_item(0)
    end
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @tele_window.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @tele_window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Menu.new(2)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @tele_window.index
      when 0  # teleport
        if $game_system.tele_disabled
          #buzzer here
        else
          $tele = 0
          @index = $game_variables[Menu_Config::MAP_VARIABLE]
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          #Scene_MapMenu
          $scene = Scene_MapMenu.new(@index)
        end
      when 1  #
        $tele = 1
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @index = $game_variables[Menu_Config::MAP_VARIABLE]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        #Scene_MapMenu
        $scene = Scene_MapMenu.new(@index)
      end
      return
    end
  end
end

when you select an option the variable $tele is set a value which is checked in the map window when selecting a location like so:
if Input.trigger?(Input::C)
      if Config::TELE_WINDOW == true
        tele = Config.tele_config(@index)
        if $tele == 0
          if tele == ''
            # Play buzzer SE
            $game_system.se_play($data_system.buzzer_se)
          else
            # Play decision SE
            $game_system.se_play($data_system.decision_se)
            #transfering is happening
            $game_temp.player_transferring = true
            # Set player move destination
            i = tele[0]
            x = tele[1]
            y = tele[2]
            d = tele[3]
            $game_temp.player_new_map_id = i
            $game_temp.player_new_x = x
            $game_temp.player_new_y = y
            $game_temp.player_new_direction = d
            $scene = Scene_Map.new
          end
        else
          name = Config.image_name(@index)
          if name == ''
            # Play buzzer SE
            $game_system.se_play($data_system.buzzer_se)
          else
             #Play decision SE
             $game_system.se_play($data_system.decision_se)
             $scene = Scene_Index.new(@index)
          end
        end
      else
        name = Config.image_name(@index)
        if name == ''
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
        else
          #Play decision SE
          $game_system.se_play($data_system.decision_se)
          $scene = Scene_Index.new(@index)
        end
      end
    end

so as you can se if the variable is set to 0 it teleports you, if the variable is 1 it opens a window with location information etc, then the location you teleport is set up in the config like so:
def self.tele_config(index)
    return case index
      when 155 then [3, 9, 7, 6]
      when 174 then [2, 9, 7, 6]
      when 193 then [1, 9, 7, 6]
      #leave else, this disables teleporting at index's unasigned
      else ''
    end
  end

so what im trying to achieve is disabling teleport locations at certain index points, i have no clue how i would go about it, i know how to disable items in a window and how to create a method to disable the selection like how the save function is enabled and disabled but doing it that way would require me to create a method for every single index point and the index goes up to 240+, even if i could add and remove teleporting locations from the config via script calls would work, but i dont even know if that is possible  :huh:

KK20

Practical way I can think of is make an accessible array that contains the index values of your map. When you want to disable teleporting to (for example) map index 100, push 100 into the array. In your script, when the cursor is located at index 100, you can use the array method 'include?' to check if 100 is in it or not. That way, you won't need a bunch of booleans for each and every index  :wacko:

On the game map, you can use script calls to this array using 'push' and 'delete' to enable/disable teleport.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

diagostimo

ok i added this to the window_mapmenu in the update:
telearray = []

then i added this to the teleporting selection:
if telearray.include?[@index]
#play buzzer
else
#teleporting happens
end

and im trying to add to the array with this script call:
$window_mapmenu.telearray.push[193]

when using the script call i get the error undefined method for telearray, thats about how far i got into testing it, am i going down the right track?

KK20

Use parentheses when calling array methods. It's include?(index), not include?[index]. Same with push.

-points to the RMXP Help File-

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

diagostimo

May 07, 2012, 08:31:32 pm #48 Last Edit: May 07, 2012, 09:37:08 pm by diagostimo
ok i changed that and i still get the same error, i even tryed def the method like so:
def telearray
 telearray = []
 @telearray = telearray
end

am i using the script call right?
$window_mapmenu.telearray.push(193)


edit:
nvm i got it to work, thanks for the help :D
---------------------------
above issues resolved
---------------------------

KK20

What I would do is create the array in Game System (also make it an attr_accessor).

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

diagostimo

ye thats exactly what i did, as for adding to game system i gues it is better to allias it rather than add it straight in? im not fully sure on what alliasing does but from what iv read i figured it adds to a class rather that replacing it? +1 for the help i really should give people + more often  :shy:

KK20

It just makes a copy of the original method and renames it, allowing you to make changes to the original without rewriting everything.
class Do_Something
 
  # The original method
  def say_something
    print "I'm cool..."
  end
 
  # Now we alias it
  alias say_something_cooler say_something
 
  # This is what the alias creates:
  def say_something_cooler
    print "I'm cool..."
  end
 
  # Now we redefine the original method
  def say_something
    say_something_cooler
    print "...just like ice cream"
  end
 
  # In essence, the modified method looks like this:
  def say_something
    print "I'm cool..."
    print "...just like ice cream"
  end
 
end

Yeah, alias made no sense to me when I first saw it. But after playing around with it, I :facepalm:

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

diagostimo

cool, that makes sense now, it will probably be easier to do it that way rather than write it into the default script so that people dont have to replace them scripts with my edits to, thanks again :D