diagostimo's rgss noob questions

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

Previous topic - Next topic

diagostimo

hey, so iv been editing away at the menu to include my scene and call it, i have also broke the party menu into a differnt scene so its no longer viewed from the main menu, the isue is that im using blizz abs, so when i open the pre-menu when testing, then go to the main menu, quit out then try opening the pre-menu again the game crashes, i have no idea what could be causing this  :wacko:
heres my menu script as of now:
=begin
begin config-
  set the id of the varriable that will record what map you are on
=end
module Map
  MAP_VARIABLE = 1
end
#end config-

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs Party screen processing.
#==============================================================================
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = $data_system.words.item
    s2 = "Party"
    s3 = "Map"
    s4 = "Save"
    s5 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
    @command_window.index = @menu_index
    @command_window.x = 480
    @command_window.y = 0
    @spriteset = Spriteset_Map.new
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(2)
    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
    @command_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_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_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # party
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to party screen
        $scene = Scene_Party.new
      when 2
         # Play decision SE
         @index = $game_variables[Map::MAP_VARIABLE]
        $game_system.se_play($data_system.decision_se)
        # switch to map screen
          $scene = Scene_MapMenu.new(@index)
      when 3  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 4  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
end

then here is the party scene after removing it from the main menu:
class Scene_Party
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs Party screen processing.
#==============================================================================


  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = $data_system.words.skill
    s2 = $data_system.words.equip
    s3 = "Status"
    @command_window = Window_Command.new(160, [s1, s2, s3])
    @command_window.index = @menu_index
    @command_window.x = 480
    @command_window.y = 0
    @spriteset = Spriteset_Map.new
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
    end
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 0
    @status_window.y = 0
    # 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
    @command_window.dispose
    @status_window.dispose
  end
   #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # 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(1)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 2
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 1  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # skill
        # If this actor's action limit is 2 or more
        if $game_party.actors[@status_window.index].restriction >= 2
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_Skill.new(@status_window.index)
      when 1  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equipment screen
        $scene = Scene_Equip.new(@status_window.index)
      when 2  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end

anyone have any ideas what is up???

ForeverZer0

You are not disposing the @spriteset.
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.

diagostimo

ha nice one, i just chucked it in there without thinking about it :P

ForeverZer0

I learned that the hard way, too. ;)

Any time the game actually crashes, in Windows I mean, not a script crash, first thing to look for is a sprite you forgot to dispose.
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.

diagostimo

April 22, 2012, 08:49:46 pm #24 Last Edit: April 26, 2012, 05:28:55 pm by diagostimo
i should have noticed to be fair, after closing the menu it lagged like hell so i should have realised that something was still there :P
--------------------------
above issues resolved
--------------------------

diagostimo

hey, iv created a rect in my window, the code is this:
cx = contents.text_size(@wtext[2]).width
      tx = contents.text_size(@wtext[2]).height
      self.contents.fill_rect(@wtext[0] - 8, @wtext[1], cx + 16, tx, Color.new(0, 0, 0, 100))

self.contents.draw_text_full(@wtext[0], @wtext[1], cx, tx, @wtext[2])

as you can see this basicly draws a rectangle behind the text that is written, the problem is i have an image behind the rect so when i set the opacity down like seen above i notice its actually deleting the section of the image the rect covers, but i want the image to still be shown behind it, any ideas how i can sort this anyone??

ForeverZer0

April 26, 2012, 05:46:18 pm #26 Last Edit: April 26, 2012, 05:47:22 pm by ForeverZer0
Instead of using fill_rect, create the bitmap as a separate object, then blit it onto the window, like so:

      text = 'This is text'
     rect = self.contents.text_size(text)
     bitmap = Bitmap.new(rect.width, rect.height)
     bitmap.fill_rect(0, 0, rect.width, rect.height, Color.new(255, 0, 0, 60))
     self.contents.blt(0, 0, bitmap, rect)
     self.contents.draw_text(0, 0, rect.width, rect.height, text, 1)


You will need to set the coordinates as needed, but it will not clear out whats already on the "contents".
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.

diagostimo

ok this is how i got it now:
rect = self.contents.text_size(@wtext[2])
      bitmap = Bitmap.new(rect.width, rect.height)
      bitmap.fill_rect(0, 0, rect.width, rect.height, Color.new(0, 0, 0, 255))
      self.contents.blt(@wtext[0]-8, @wtext[1], bitmap, rect)
      self.contents.draw_text_full(@wtext[0], @wtext[1], rect.width, rect.height, @wtext[2], 1)

as you can see i minused the x of the blt by 8, what i wanna do is increase the rect width by 16 so it has an offset of 8 on either side, cant get my head round it  :<_<:

ForeverZer0

rect = self.contents.text_size('SOME TEXT')
highlight_rect = Rect.new(rect.x - 8, rect.y, rect.width + 16, rect.height)


Something like that?
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.

diagostimo

ye something like that, although that didnt seem to change anything, so the box should be extended giving the text some space around it so the text doesnt touch the borders, heres what the code looks like now:
cx = contents.text_size(@wtext[2]).width
      tx = contents.text_size(@wtext[2]).height
      rect = self.contents.text_size(@wtext[2])
      if Config::W_TEXT_BACK == true
        highlight_rect = Rect.new(rect.x-8, rect.y, rect.width+16, rect.height)
        bitmap = Bitmap.new(rect.width, rect.height)
        bitmap.fill_rect(0, 0, rect.width, rect.height, Color.new(0, 0, 0, 255))
        self.contents.blt(@wtext[0], @wtext[1], bitmap, rect)
      end
      if Config::W_OUTLINED_TEXT == true
        self.contents.draw_text_full(@wtext[0], @wtext[1], cx, tx, @wtext[2], 1)
      else
        self.contents.draw_text(@wtext[0], @wtext[1], cx, tx, @wtext[2], 1)
      end

ForeverZer0

It doesn't work because you never use it. You have to replace "rect" with "highlight_rect" in the fill_rect call.
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.

diagostimo

ok i edited fill rect like so:
bitmap.fill_rect(0, 0, highlight_rect.width, highlight_rect.height, Color.new(0, 0, 0, 255))
this still does nothing, but if i change blt to this:
self.contents.blt(@wtext[0], @wtext[1], bitmap, highlight_rect)
then it adds some onto the width but the x + 8??? i hate rectangles >:(

ForeverZer0

You would want to subtract from the x, this will move the left edge of the rect to the left. You then add double that amount you subtracted from the X, and add it to the width. This widens the rect to account for the space that you moved it to the left, and to add the equal amount of space on the right side.

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.

diagostimo

April 28, 2012, 10:40:54 pm #33 Last Edit: April 30, 2012, 08:25:27 pm by diagostimo
cool i got it to work the way i want it, now im trying to add a border to it by drawing a larger rectangle behind it, the problem is i want the rectangle that is drawn in front of the border one to erase what is behind like what was happerning with the image before, so if the front rectangle is transparent you cant see the border behind it, heres how i have tried implimenting it:
if Config::W_TEXT_BACK == true
       if Config::W_TEXT_BACK_BORDER == true
         rect = self.contents.text_size(@wtext[2])
         highlight_rect = Rect.new(rect.x - 12, rect.y - 8, rect.width + 36, rect.height + 24)
         bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
         bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(255, 255, 255, 255))
       self.contents.blt(@wtext[0] - 24, @wtext[1] -16, bitmap, highlight_rect)
       end
       rect = self.contents.text_size(@wtext[2])
       highlight_rect = Rect.new(rect.x - 8, rect.y - 4, rect.width + 24, rect.height + 12)
       bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
       bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(0, 0, 0, 100))
       self.contents.blt(@wtext[0] - 16, @wtext[1] - 8, bitmap, highlight_rect)
     end

-------------------------------
above issue resolved
-------------------------------

diagostimo

hey, i have been trying to implement a teleport function into a menu, heres what i have so far:
module setup:
#set if tele windows are enabled
  TELE_WINDOW = true
  #setup teleport locations for index points [id, x, y, direction]
  def self.tele_config(index)
    return case index   
      when 193 then [2, 9, 7, 6]
      #leave else, this returns no window if no image is set 
      else ''
    end
  end

the part of my scene that calls the tele menu:
def update
    super
    # if enter is being pressed
    if Input.trigger?(Input::C)
      name = Config.image_name(@index)
      if name == ''
        $scene = Scene_MapMenu.new(@index)
      else
        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

the tele scene:
#==============================================================================
# ** Scene_Tele
#------------------------------------------------------------------------------
#  This class performs Party screen processing.
#==============================================================================
class Scene_Tele
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = "teleport"
    s2 = "location info"
    @command_window = Window_Command.new(120, [s1, s2])
    @command_window.index = @menu_index
    @command_window.x = 0
    @command_window.y = 0
    #new sprite (background)
    @sprite = Sprite.new
     #set sprite image
    @sprite.bitmap = RPG::Cache.picture(Config::MAP_NAME)
    # 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
    @command_window.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_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_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # teleport
        telesetup = Config.tele_config(@index)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # teleport
        $game_temp.player_transferring = true
        # Set player move destination
        $game_temp.player_new_map_id = telesetup[0]
        $game_temp.player_new_x = telesetup[1]
        $game_temp.player_new_y = telesetup[2]
        $game_temp.player_new_direction = telesetup[3]
        $scene = Scene_Map.new
      when 1  #
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
       
      end
      return
    end
  end
end


so depending on the index of the previous menu it will return you at the id, x, y, direction, specified for that index in the module, the problem is i get the error cant find map id 000 rx data,
i cant figure out what could be up with it  :uhm:

ForeverZer0

Looks like your Config method is not returning the correct values.

$game_temp.player_new_map_id = telesetup[0]


This is returning either 0 or nil, both of which are not valid for a map ID.
Add a "p telesetup" before this call to see what the values are.
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.

diagostimo

ok i did that, when running it i got a box with ""
im guesing this was supposed to say the value?

ForeverZer0

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.

diagostimo

like this:
#-------------#
#beging config#
#-------------#
module Config
  #IMPORT ALL YOUR IMAGES TO THE PICTURES DIRECTORY!
  #your main map's image name
  MAP_NAME = 'map.png'
  #here you can complete configure the text show when the cursor is at differnt
  #locations on the map
  #config whether you wish to use custom font, true or false
  CUSTOM_FONT = false
  #configure the name of the custom font
  TEXT_FONT = 'Georgia'
  #configure whether you wish to manually set the color of the text, true or false
  CUSTOM_COLOR = true #when false default is white
  # set the color of the text like so: [RED, GREEN, BLUE]min=0 max=255
  SET_COLOR = [0, 0, 0]
  #configure whether the text writen will be bold or not, true or false
  BOLD_TEXT = true
  #set the fonts size
  FONT_SIZE = 25 #maximum size = 96
  #set if you would like to use outlined text
  OUTLINED_TEXT = true
  #set if you would like to customize the color of the outline
  OUTLINED_COLOR = true #when false default is black
  # set the color of the outline: [red, green, blue]min=0 max=255
  OUTLINED_COLOR_SET = [255, 255, 255]
  #set to true to draw a box behind the text
  TEXT_BACK = true
  #set the color and opacity of the box
  TEXT_BACK_COLOR = [255, 0, 0, 150]#[red, green, blue, opacity]
  #set to true to give the box a border, only returns if back box = true
  TEXT_BACK_BORDER = true #not functional
  #set the color and opacity of the border
  TEXT_BACK_BORDER_COLOR = [0, 0, 255, 255]#[red, green, blue, opacity]
  #set to true to give the box a border
  TEXT_BACK_BORDER = true #not functional
  #set up the names that will be shown when the cursor is over locations,
  #when 193 points at the index point of the map, refer to the index refernece
  #image, config like so: when INDEX ID then [x, y , "TEXT"]
  #just simply add a new line to configure a new location
  #for index's not configured it will not return any text
  def self.map_text(index)
    return case index   
      when 193 then [6, 6, 'example text']
      when 174 then [50, 50, 'example2 text']
      #leave else, this returns no text if none is set
      else ''
    end
  end
  #here you configure the window that will show an image of the town you press
  #the action button on
  #define the windows [x, y, width, height] for your town images ect
  WINDOW_SIZE = [112, 64, 416, 352]
  #define the opacity of your towns windows(this does not effect the images)
  #255=max, 0=min
  WINDOW_OPACITY = 255
  #configure the maps name that will be shown in the window, configure
  #it exactly how you configured the text above, the index is set the same, it
  #will show the text for the index point it is called from
  def self.window_text(index)
    return case index   
      when 193 then [30, 30, "example text"]
      when 174 then [80, 50, "example text"]
      #leave else, this returns no text if none is set
      else ''
    end
  end
  #config whether you wish to use custom font, true or false
  W_CUSTOM_FONT = false
  #configure the name of the custom font
  W_TEXT_FONT = 'Georgia'
  #configure whether you wish to manually set the color of the text, true or false
  W_CUSTOM_COLOR = true #when false default is white
  # set the color of the text like so: [RED, GREEN, BLUE]min=0 max=255
  W_SET_COLOR = [0, 0, 0]
  #configure whether the text writen will be bold or not, true or false
  W_BOLD_TEXT = true
  #set the fonts size
  W_FONT_SIZE = 20 #maximum size = 96
  #set if you would like to use outlined text
  W_OUTLINED_TEXT = true
  #set if you would like to customize the color of the outline
  W_OUTLINED_COLOR = true #when false default is black
  # set the color of the outline: [red, green, blue]min=0 max=255
  W_OUTLINED_COLOR_SET = [255, 255, 255]
  #set to true to draw a box behind the text
  W_TEXT_BACK = true
  #set the color and opacity of the box
  W_TEXT_BACK_COLOR = [0, 0, 255, 100]#[red, green, blue, opacity]
  #set to true to give the box a border, only returns if back box = true
  W_TEXT_BACK_BORDER = true #not functional
  #set the color and opacity of the border
  W_TEXT_BACK_BORDER_COLOR = [255, 0, 0, 255]#[red, green, blue, opacity]
 
#to add a new image for an index point simply add a new line with the image's
#name E.G you want to add a image for index 0 you would add this:
#when 0 then 'IMAGE_NAME'
#where IMAGE_NAME is the name of the image to show, use the index reference
#image in the projects root folder for a reference of how the index is set-up
  def self.image_name(index)
    return case index   
      when 193 then 'pallettown.png'
      when 174 then 'pallettown.png'
      #leave else, this returns no window if no image is set 
      else ''
    end
  end
  #set the [x, y, opacity] of the images, opacity max=255 min=0
  IMAGE_XY = [0, 0, 255]
 
  #set if tele windows are enabled
  TELE_WINDOW = true
  #setup teleport locations for index points [id, x, y, direction]
  def self.tele_config(index)
    return case index   
      when 193 then [2, 9, 7, 6]
      #leave else, this returns no window if no image is set 
      else ''
    end
  end
end

the config for the teleport is at the bottom

ForeverZer0

At the very end...
  def self.tele_config(index)
    return case index   
      when 193 then [2, 9, 7, 6]
      #leave else, this returns no window if no image is set 
      else ''
    end
  end


You only have one thing defined.
If you try to call this and @index does not equal 193, you are going to get an error.
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.