diagostimo's rgss noob questions

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

Previous topic - Next topic

diagostimo

hey guys, i have been trying to impliment an updating word on a window when the index changes, heres what i got:
def refresh
    if @index = 193
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test 1").width
     self.contents.draw_text(0, 0, cx, 32, "test 1")
     return
   end
   if @index = 174
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test 2").width
     self.contents.draw_text(0, 0, cx, 32, "test 2")
     return
     else
     self.contents.clear
   end
  end

so if the index is either of the said it should say the corisponding word, or if its else then there should be no text displayed, but say i start on index 193 when i call the scene, then change the word doesnt clear and stays the same, i want it to sort of work like the help window, but inside this window :/

G_G

This is your issue.
if @index = 193

That is setting the index's value to 193 instead of checking to see if it is equal. To see if its equal to 193, you must use two equal signs.
if @index == 193

diagostimo

ok ye i get that, i did try it like that, but the problem im having when its like that is that no text is written, i cant understand why really the code seems pretty clean  :???:

G_G

Can you post your entire script? Indexes 193 and 174 are pretty high.

diagostimo

ye sure here it is:
#-------------#
#beging config#
#-------------#
module Config
  #IMPORT ALL YOUR IMAGES TO THE PICTURES DIRECTORY!
  #your main map's image name
  MAP_NAME = "kantomap.png"
  #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
#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.text_map(index)
    return case index
    when 193 then 'pallet town'
    else ''
    end
  end
 
  def self.image_name(index)
    return case index   
    when 193 then 'pallettown.png'
#----------#
#END CONFIG#
#----------#
    else ''
    end
  end
end
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    refresh
  end
  #-------------------------------------------------------------------------
  # * def index
  #-------------------------------------------------------------------------
  def index=(index)
    @index = index
    # Update cursor rectangle
    update_cursor_rect
  end
  #-------------------------------------------------------------------------
  # * def refresh
  #-------------------------------------------------------------------------
  def refresh
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size(Config.text_map(index)).width
     self.contents.draw_text(0, 0, cx, 32, Config.text_map(index))
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
      x = 0 + @index % 19 * 32
      y = 0 + @index / 19 % 14 * 32
      self.cursor_rect.set(x, y, 32, 32)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  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
        $scene = Scene_Index.new(@index)
        $game_system.se_play($data_system.decision_se)
      end
     
    # If right directional button is pushed
    elsif Input.repeat?(Input::RIGHT)
      # If directional button pressed down is not a repeat, or
      # cursor is not positioned on the right edge
      if Input.trigger?(Input::RIGHT) or
         @index % 19 < 18
        # Move cursor to right
        $game_system.se_play($data_system.cursor_se)
        if @index % 19 < 18
          @index += 1
        end
      end
    # If left directional button is pushed
    elsif Input.repeat?(Input::LEFT)
      # If directional button pressed down is not a repeat, or
      # cursor is not positioned on the left edge
      if Input.trigger?(Input::LEFT) or
         @index % 19 > 0
        # Move cursor to left
        $game_system.se_play($data_system.cursor_se)
        if @index % 19 > 0
          @index -= 1
        end
      end
    # If down directional button is pushed
    elsif Input.repeat?(Input::DOWN)
      # Move cursor down
      if @index / 19 < 13
        @index += 19
        $game_system.se_play($data_system.cursor_se)
      end
    # If up directional button is pushed
    elsif Input.repeat?(Input::UP)
      # Move cursor up
      if @index / 19 > 0
        @index -= 19
        $game_system.se_play($data_system.cursor_se)
      end 
    end
    update_cursor_rect
  end
end
#---------------------------------------------------------------------------
# * Scene Map_Menu
#---------------------------------------------------------------------------
class Scene_MapMenu
  def initialize(index) 
    @index = index
  end
  #-------------------------------------------------------------------------
  # * MAIN
  #-------------------------------------------------------------------------
  def main
    @mapmenu_window = Window_MapMenu.new
    @mapmenu_window.index = @index
    @sprite = Sprite.new
    @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
    @mapmenu_window.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @mapmenu_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 Menu screen
      $scene = Scene_Menu.new(2)
      return
    end
  end
end
#===========================================================================
# * class Window_Index
#---------------------------------------------------------------------------
class Window_Index < Window_Base
  #-------------------------------------------------------------------------
  # * Object Initialization
  #-------------------------------------------------------------------------
  def initialize(index)
    super(*Config::WINDOW_SIZE)
    @bitmap = RPG::Cache.picture(Config.image_name(index))
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = Config::WINDOW_OPACITY
    refresh
  end
  #-------------------------------------------------------------------------
  # * refresh
  #-------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 255)
  end
end

#---------------------------------------------------------------------------
# * Scene_Index
#---------------------------------------------------------------------------
class Scene_Index
 
  def initialize(index)
    @index = index
  end
  #-------------------------------------------------------------------------
  # * Main
  #-------------------------------------------------------------------------
  def main
    @index_window = Window_Index.new(@index)
    @sprite = Sprite.new
    @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
    @index_window.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @index_window.update
    # set text
    # 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_MapMenu.new(@index)
      return
    end
  end
end


i have actually tried implementing the text like how the images are shown but to no avail, anyway you will see :)

nathmatt

try this

#-------------------------------------------------------------------------
# * def index
#-------------------------------------------------------------------------
def index=(index)
  @index = index
  # Update cursor rectangle
  update_cursor_rect
  refresh
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


diagostimo

no still no avail, did you post that to use with the first posts refresh method or the second script where i tried implementing it into the module? tried it with both anyway, it seems that if i have self.contents.clear in an else command like so:
 def refresh
    if @index == 193
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test 1").width
     self.contents.draw_text(0, 0, cx, 32, "test 1")
    end
    if @index == 174
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test 2").width
     self.contents.draw_text(0, 0, cx, 32, "test 2")
   else
     self.contents.clear
    end
  end

then it doesnt display any text, no matter what the index is, but if its at the top like this:
 def refresh
     self.contents.clear
    if @index == 193
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test 1").width
     self.contents.draw_text(0, 0, cx, 32, "test 1")
    end
    if @index == 174
     self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test 2").width
     self.contents.draw_text(0, 0, cx, 32, "test 2")
    end
  end

then test 1 is constantly displayed no matter what the index is, my guess was that it doesnt really matter if self.contents.clear is in an else or not as it should only be doing that if the index isnt equal, but it seems to not be checking the index properly  :???:

KK20

In this part of your script:
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  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
        $scene = Scene_Index.new(@index)
        $game_system.se_play($data_system.decision_se)
      end
     
    # If right directional button is pushed
    elsif Input.repeat?(Input::RIGHT)
      # If directional button pressed down is not a repeat, or
      # cursor is not positioned on the right edge
      if Input.trigger?(Input::RIGHT) or
         @index % 19 < 18
        # Move cursor to right
        $game_system.se_play($data_system.cursor_se)
        if @index % 19 < 18
          @index += 1
        end
      end
    # If left directional button is pushed
    elsif Input.repeat?(Input::LEFT)
      # If directional button pressed down is not a repeat, or
      # cursor is not positioned on the left edge
      if Input.trigger?(Input::LEFT) or
         @index % 19 > 0
        # Move cursor to left
        $game_system.se_play($data_system.cursor_se)
        if @index % 19 > 0
          @index -= 1
        end
      end
    # If down directional button is pushed
    elsif Input.repeat?(Input::DOWN)
      # Move cursor down
      if @index / 19 < 13
        @index += 19
        $game_system.se_play($data_system.cursor_se)
      end
    # If up directional button is pushed
    elsif Input.repeat?(Input::UP)
      # Move cursor up
      if @index / 19 > 0
        @index -= 19
        $game_system.se_play($data_system.cursor_se)
      end 
    end
    update_cursor_rect
  end
end

When you are setting @index a value, use self.index instead. For example:
self.index += 1 # Assigning @index a value while also calling the method 'def index=(index)'

# However, do not change it to self.index in cases like this here:
name = Config.image_name(@index) # Leave @index alone in cases like this


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

April 17, 2012, 10:41:50 pm #8 Last Edit: April 17, 2012, 10:46:33 pm by diagostimo
@ kk20, ok i did that, so it now looks like this:
#-------------#
#beging config#
#-------------#
module Config
 #IMPORT ALL YOUR IMAGES TO THE PICTURES DIRECTORY!
 #your main map's image name
 MAP_NAME = "kantomap.png"
 #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
#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'
#----------#
#END CONFIG#
#----------#
   else ''
   end
 end
end
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 0, 640, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.opacity = 0
   refresh
 end
 #-------------------------------------------------------------------------
 # * def index
 #-------------------------------------------------------------------------
 def index=(index)
   @index = index
   # Update cursor rectangle
   update_cursor_rect
   refresh
 end
 #-------------------------------------------------------------------------
 # * def refresh
 #-------------------------------------------------------------------------
 def refresh
   if @index == 193
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    cx = contents.text_size("test 1").width
    self.contents.draw_text(0, 0, cx, 32, "test 1")
   end
   if @index == 174
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    cx = contents.text_size("test 2").width
    self.contents.draw_text(0, 0, cx, 32, "test 2")
  else
    self.contents.clear
   end
 end
 #--------------------------------------------------------------------------
 # * Cursor Rectangle Update
 #--------------------------------------------------------------------------
 def update_cursor_rect
     x = 0 + @index % 19 * 32
     y = 0 + @index / 19 % 14 * 32
     self.cursor_rect.set(x, y, 32, 32)
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 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
       $scene = Scene_Index.new(@index)
       $game_system.se_play($data_system.decision_se)
     end
     
   # If right directional button is pushed
   elsif Input.repeat?(Input::RIGHT)
     # If directional button pressed down is not a repeat, or
     # cursor is not positioned on the right edge
     if Input.trigger?(Input::RIGHT) or
        @index % 19 < 18
       # Move cursor to right
       $game_system.se_play($data_system.cursor_se)
       if @index % 19 < 18
         self.index += 1
       end
     end
   # If left directional button is pushed
   elsif Input.repeat?(Input::LEFT)
     # If directional button pressed down is not a repeat, or
     # cursor is not positioned on the left edge
     if Input.trigger?(Input::LEFT) or
        @index % 19 > 0
       # Move cursor to left
       $game_system.se_play($data_system.cursor_se)
       if @index % 19 > 0
         self.index -= 1
       end
     end
   # If down directional button is pushed
   elsif Input.repeat?(Input::DOWN)
     # Move cursor down
     if @index / 19 < 13
       self.index += 19
       $game_system.se_play($data_system.cursor_se)
     end
   # If up directional button is pushed
   elsif Input.repeat?(Input::UP)
     # Move cursor up
     if @index / 19 > 0
       self.index -= 19
       $game_system.se_play($data_system.cursor_se)
     end  
   end
   update_cursor_rect
 end
end
#---------------------------------------------------------------------------
# * Scene Map_Menu
#---------------------------------------------------------------------------
class Scene_MapMenu
 def initialize(index)  
   @index = index
 end
 #-------------------------------------------------------------------------
 # * MAIN
 #-------------------------------------------------------------------------
 def main
   @mapmenu_window = Window_MapMenu.new
   @mapmenu_window.index = @index
   @sprite = Sprite.new
   @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
   @mapmenu_window.dispose
   @sprite.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @mapmenu_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 Menu screen
     $scene = Scene_Menu.new(2)
     return
   end
 end
end
#===========================================================================
# * class Window_Index
#---------------------------------------------------------------------------
class Window_Index < Window_Base
 #-------------------------------------------------------------------------
 # * Object Initialization
 #-------------------------------------------------------------------------
 def initialize(index)
   super(*Config::WINDOW_SIZE)
   @bitmap = RPG::Cache.picture(Config.image_name(index))
   self.contents = Bitmap.new(width - 32, height - 32)
   self.opacity = Config::WINDOW_OPACITY
   refresh
 end
 #-------------------------------------------------------------------------
 # * refresh
 #-------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 255)
 end
end

#---------------------------------------------------------------------------
# * Scene_Index
#---------------------------------------------------------------------------
class Scene_Index
 
 def initialize(index)
   @index = index
 end
 #-------------------------------------------------------------------------
 # * Main
 #-------------------------------------------------------------------------
 def main
   @index_window = Window_Index.new(@index)
   @sprite = Sprite.new
   @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
   @index_window.dispose
   @sprite.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @index_window.update
   # set text
   # 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_MapMenu.new(@index)
     return
   end
 end
end

im now getting a "no method error for index" on the lines i changed to self.index when i press the corisponding direction  :(

KK20

Uh...give index a read method.
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
  attr_reader :index
# Continue on with the code...

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 that solved it :D im still getting the ropes on scripting so bear with me, i have also been trying to implement what is written into the module config, so it can be added easily, so i added this code to the config:
 def self.map_text(index)
    return case index   
    when 193 then [0, 0, cx, 32, "test"]

then changed refresh to look like this:
def refresh
    self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test").width
     self.contents.draw_text(Config.map_text(index))
  end

i tryed to do it like the way the images are shown if you look at my module in the last script, but cant get it to work, iv tryed doing it multiple other ways to, also how would i direct cx at the 5th part of the text config so it reads what is writen?

KK20

Well, first off, 'draw_text' needs 5 arguments (or 2 if you use a Rect) to define x-coord, y-coord, width, height, and the string. In your method 'self.map_text' you are returning an array, which would only satisfy one of the five arguments. You will most likely have to call 'self.map_text' and store its result in a temporary variable. Like such:
def refresh
    self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test").width
    a = Config.map_text(@index) # a will be our temporary array
     self.contents.draw_text(a[0], a[1], a[2], a[3], a[4])
  end
You will have to use @index instead of index as your parameter when calling 'self.map_text' by the way.

Also, cx in 'refresh' and 'self.map_text' are local variables--they don't share the same values. Not to mention, they're not even in the same class.
Rewrite your script so that 'self.map_text' doesn't use cx, but 'refresh' still does.
Spoiler: ShowHide
def self.map_text(index)
    return case index   
    when 193 then [0, 0, 32, "test"]
end

def refresh
    self.contents.clear
     self.contents.font.color = normal_color
     self.contents.font.size = 20
     cx = contents.text_size("test").width
    a = Config.map_text(@index) # a will be our temporary array
     self.contents.draw_text(a[0], a[1], cx, a[2], a[3])
  end

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

April 18, 2012, 05:06:44 pm #12 Last Edit: April 19, 2012, 05:09:17 pm by diagostimo
--------------------------
ABOVE ISSUE RESOLVED
--------------------------

cool i totaly get it now :) i understood that i had to create an argument to point it at i just didnt understand how to point at more than 1 argument if it had more in it if you get what i mean, anyway you have been a great help, thanks :D

diagostimo

hey, iv now been messing with the way i call my scene, so heres where im at now:
module:
module Map
  #the variable ID which stores what map square to go to
  MAP_VARIABLE = 1
 
  def self.map_evariable(index)
    return case [Map::MAP_VARIABLE] == [Map.map_evariable(index)]
    when 1 then [193]
      else [0]
    end
  end
end

menu selection:
when 2  # map
         variable = Map.map_evariable(@index)
         # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # switch to map screen
          $scene = Scene_MapMenu.new(variable)


you can probably see what im trying to achieve, i want it to check what the variable declared at the top of the module is equal to and set the number of the index to call to, at the moment im getting the error stack level too deep, i think im nearly there  :O.o:

ForeverZer0

The brackets are not needed, the "[Map::MAP_VARIABLE] == [Map.map_evariable(index)]" would result in a boolean, not a number, and the method is recursive, meaning it calls itself. Ruby does not allow this, and it will throw an error.

Why not just set the variable of each map to its ID, or its ID + 100, etc, etc. Then you wouldn't need a method at all.

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 19, 2012, 06:11:21 pm #15 Last Edit: April 19, 2012, 06:17:13 pm by diagostimo
im not setting the varriable to the map id because some maps consist of 2 or more index points so say if x is over x then it sets the variable to 1 if its under x then it sets the variable to 2 etc, this way it just makes it easier to configure the way i want it i also just reallised i forgot to add the code for the varriable heres what it looks like as of now:
module Map
 #the variable ID which stores what map square to go to
 MAP_VARIABLE = 1
 
 def self.map_evariable(index)
   return case $game_variables[Map::MAP_VARIABLE]
   when 1 then [193]
     else [0]
   end
 end
end

so how would i get it to check the varriable properly? i know how to do it with if statments but it would be easier if it was in the module

ForeverZer0

What variable?

The above example looks okay, but I don't really know what "index points" are.
What you have will return an array depending on the value of the game variable with the ID of MAP_VARIABLE. If thats what you are aiming for, then you got it. You can add multiple conditions to each "when" in case statements, like this:

def self.get_number(index)
 case index
 when 0..5 # Returns 0 if index is between 0 and 5 (including 5)
   return 0
 when 5, 8, 9, 10, 67 # If index is any of these, it returns 3
   return 3
 when 4..40, 80..90 # Uses two ranges
   return 2
 end
 return [0]
end

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 sorted it, what i had above was dead on but it was giving me an error for writing the numbers in "[]", also thanks for letting me know how to add multiple conditions, you wouldnt be able to throw all the text comands at me would you? i noticed that some ppl have given there text black outlines etc in some scripts i have seen, iv tryed googling to see if theres a list anywhere but i have only found how to change the text to bold and change the color, having a list would prove very helpful :)

ForeverZer0

April 20, 2012, 12:01:54 am #18 Last Edit: April 20, 2012, 12:05:11 am by ForeverZer0
Outlined text is from script addons. Tons of Addons has a very nice one in it.

Aside from that, look in the RMXP help manual. It has some good scripting stuff to learn in there, and should be the Bible of anyone trying to learn RGSS. The draw_text commands are in the Bitmap class, while settings like bold and italic are in the Font class.

text = 'This is text'
bitmap = Bitmap.new(256, 32)
bitmap.font.name = 'Comic Sans'
bitmap.font.size = 22
bitmap.font.color = Color.new(255, 128, 128)
bitmap.font.bold = true
bitmap.font.italic = true
bitmap.draw_text(0, 0, 256, 32, text, 1)


It might also help to know that in the window class, "contents" is just another word for describing the window's bitmap. There is nothing special about it other than that is what it goes by.
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 21, 2012, 04:35:14 am #19 Last Edit: April 22, 2012, 07:32:16 pm by diagostimo
-----------------------------
ABOVE ISSUE RESOLVED
-----------------------------

cool thanks man, i never even knew rmxp had scripting help in the help files :o also found the code snippet to make outlined text, trawling through tons :P its actually so simple, :)