Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: G_G on March 04, 2009, 12:14:28 am

Title: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 04, 2009, 12:14:28 am
General RGSS/RGSS2 Help





Introduction

Here is a general RGSS/RGSS2/RGSS3 Help Topic. You're welcome to ask any question about either scripting language to help you be a scripter.


Instructions

First search the topic for your question.  It might have already been answered, so please search first.


Notes

If we don't answer right away, just wait a day or two then bump it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Landith on March 04, 2009, 12:19:44 am
Maybe have an if branch to see if the player is pressing left, right, up, or down then refresh the window to prevent lag? I would check out Ccoa's HUD tutorial on rpgrevolution, it has a solution to this. Don't have a link at the present time because I'm on my phone, I might be able to get one in a little bit though
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on March 04, 2009, 07:06:39 am
How's your update method like? Could you post it?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 04, 2009, 09:34:27 am
Coordinate Window: ShowHide
class Window_Coordinate < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, "X: " + $game_player.x.to_s)
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 120, 32, "Y: " + $game_player.y.to_s)
  end
end


Scene_Map: ShowHide
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make sprite set
    @coordinate = Window_Coordinate.new
    @spriteset = Spriteset_Map.new
    # Make message window
    @message_window = Window_Message.new
    # Transition run
    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 sprite set
    @spriteset.dispose
    @coordinate.dispose
    # Dispose of message window
    @message_window.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Loop
    loop do
      # Update map, interpreter, and player order
      # (this update order is important for when conditions are fulfilled
      # to run any event, and the player isn't provided the opportunity to
      # move in an instant)
      $game_map.update
      $game_system.map_interpreter.update
      @coordinate.update
      $game_player.update
     
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    @message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    # If encounter list isn't empty, and encounter count is 0
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # If troop is valid
        if $data_troops[troop_id] != nil
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Battle Call
  #--------------------------------------------------------------------------
  def call_battle
    # Clear battle calling flag
    $game_temp.battle_calling = false
    # Clear menu calling flag
    $game_temp.menu_calling = false
    $game_temp.menu_beep = false
    # Make encounter count
    $game_player.make_encounter_count
    # Memorize map BGM and stop BGM
    $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Straighten player position
    $game_player.straighten
    # Switch to battle screen
    $scene = Scene_Battle.new
  end
  #--------------------------------------------------------------------------
  # * Shop Call
  #--------------------------------------------------------------------------
  def call_shop
    # Clear shop call flag
    $game_temp.shop_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to shop screen
    $scene = Scene_Shop.new
  end
  #--------------------------------------------------------------------------
  # * Name Input Call
  #--------------------------------------------------------------------------
  def call_name
    # Clear name input call flag
    $game_temp.name_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to name input screen
    $scene = Scene_Name.new
  end
  #--------------------------------------------------------------------------
  # * Menu Call
  #--------------------------------------------------------------------------
  def call_menu
    # Clear menu call flag
    $game_temp.menu_calling = false
    # If menu beep flag is set
    if $game_temp.menu_beep
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Clear menu beep flag
      $game_temp.menu_beep = false
    end
    # Straighten player position
    $game_player.straighten
    # Switch to menu screen
    $scene = Scene_Menu.new
  end
  #--------------------------------------------------------------------------
  # * Save Call
  #--------------------------------------------------------------------------
  def call_save
    # Straighten player position
    $game_player.straighten
    # Switch to save screen
    $scene = Scene_Save.new
  end
  #--------------------------------------------------------------------------
  # * Debug Call
  #--------------------------------------------------------------------------
  def call_debug
    # Clear debug call flag
    $game_temp.debug_calling = false
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Straighten player position
    $game_player.straighten
    # Switch to debug screen
    $scene = Scene_Debug.new
  end
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.player_transferring = false
    # If move destination is different than current map
    if $game_map.map_id != $game_temp.player_new_map_id
      # Set up a new map
      $game_map.setup($game_temp.player_new_map_id)
    end
    # Set up player position
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # Set player direction
    case $game_temp.player_new_direction
    when 2  # down
      $game_player.turn_down
    when 4  # left
      $game_player.turn_left
    when 6  # right
      $game_player.turn_right
    when 8  # up
      $game_player.turn_up
    end
    # Straighten player position
    $game_player.straighten
    # Update map (run parallel process event)
    $game_map.update
    # Remake sprite set
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    # If processing transition
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      Graphics.transition(20)
    end
    # Run automatic change for BGM and BGS set on the map
    $game_map.autoplay
    # Frame reset
    Graphics.frame_reset
    # Update input information
    Input.update
  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on March 04, 2009, 09:41:25 am
OK. In Scene_Map#update, here's how you're updating the coordinate window:

if @coordinate.visible == true
      update_coordinate
    end


But update_coordinate is not defined. Besides, if you want to update the coordinate window, you should use:


@coordinate.update


That will call the update method in Window_Coordinate IF that method is defined in Window_Coordinate, which is not. You only defined initialize and refresh. Make an update method and check if the player's X and Y coordinates have changed. If they have, call refresh. Do all of this in Window_Coordinate#update. Then all you have to do in Scene_Map#update is:


if @coordinate.visible == true
  @coordinate.update
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on March 04, 2009, 09:50:26 am
    if @coordinate.visible
      update_coordinate
    end


Optimized. :P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 04, 2009, 11:41:34 am
Ha. Both of ya is wrong.


@coordinate.update if @coordinate.visible
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on March 04, 2009, 11:51:23 am
HAHA! YOU FELL RIGHT INTO MY TRAP!


@coordinate.update if @coordinate.visible && @coordinate.active


Also, it being in one line instead of 3 doesn't change the performance.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 04, 2009, 06:11:46 pm
It still doesnt work. I used
@coordinate.update if @coordinate.visible && @coordinate.active

And still no luck. Also I added this under @coordinate = Window_Coordinate.new

def initialize
  @coordinate = Window_Coordinate.new
  @coordiante.visible = true
  @coordinate.active = true
end


Still no luck. Its not updating at all.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Tazero on March 04, 2009, 06:32:39 pm
Should 2 &'s be there?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 04, 2009, 06:35:37 pm
Yes; one ampersand is a bitwise operator. Two ampersands is the same as using the keyword "and," but since there is a bug with that that Blizz found a year or two ago, we always use "&&" here if possible.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 04, 2009, 06:41:18 pm
Okay I realized that I totally forgot something. In Window_Coordinate I didn't add a def update in it so it wasnt really updating the window. So its all figured out and done!!! Still need to know this

One more question is it possible to display a picture in the window? Like normally i've been using
RPG::Cache.picture("")
But that displays a picture in the whole scene and I just want it in a window if possible.

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 04, 2009, 09:37:36 pm
What folder is the picture in?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 04, 2009, 09:46:31 pm
What? I'm not having problems display pictures.

I want to display a picture in the window without having to set x and y coordinates and RPG::Cache.picture("")
Like is there a line of code I can add in a window that displays a picture in the window?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on March 04, 2009, 10:21:21 pm
you are confusing people because you have no idea what you are talking about.

RPG::Cache.picture("filename.png") get the image of the filename.

Then, you have to either set it to a background or display it some other way.

HOW do you want it in the window?  As a background?  or just inside its bounds?  either way, it should be pretty obvious...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 04, 2009, 10:22:25 pm
I think you'd need this:

window.contents = Bitmap.new(path_to_file)


OR


window.contents = RPG::Cache.<pick_ur_method>(filename)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 04, 2009, 10:49:37 pm
Thanks WcW yea I had no idea what I was talking about. I had it prefectly said right in my head but hey we all think differently right?

EDIT: Wait I tried both methods, then it jsut displays the picture for like half a second then dissappears, then it shows two arrows, one pointing down, and one points right.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 05, 2009, 08:15:35 am
Oh, you probably don't have the window's size set right :P

Another method that you might want to use is


src = Rect.new(0, 0, <width>, <height>)
dst = Rect.new(<ur x>, <ur y>, <width>, <height>)
window.contents.blt(src, Bitmap.new(<filename>), dst) # takes the image at <src> from the bitmap and draws it at <dst>


Or something like that; it's in the help file, under Bitmap.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 12, 2009, 07:45:11 pm
New question:

How would you go making a Horizontal command window for a menu? Instead of a normal command window one that has the selections side by side: Items, Skills, etc. Could someone tell me or guide me on my way or something.

If you need to contact me, my msn is gameguy27@hotmail.com
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 13, 2009, 11:58:10 pm
*bump*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on March 14, 2009, 04:18:51 am
Change the @column_max variable to @item_max in Window_Selectable. You might have to tinker with update_cursor_rect.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 14, 2009, 09:14:07 am
Thanks fantasist now I can make my cms I had in mind.
Okay it works but I still dont know how to lay the choices together.
Instead of
Items
Skills
Etc.

I want this but I dont know how to do this
Items Skills Etc.

The window selectable thing works but I started up title screen and it showed all three options the same but the selection was different.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on March 14, 2009, 09:40:51 am
you need to change the dimensions of the window (in the constructor, where it says 'def initialize), then change draw_item.  Or whatever that method is called.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 14, 2009, 09:55:26 am
Well I still dont know exactly what to change. I tried changing a few things just now but it started only showing the New Game option. So then I changed it back.

EDIT: Okay I just made a new window based off of ShopCommand so I got it now.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 16, 2009, 06:18:42 pm
New question:
is it possible to have a message thing have to use more than one letter? Like the name thing is \n[1] but I need to know if its possible to have something like \sd[1] and if so how?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on March 16, 2009, 07:31:54 pm
yes.  Just search for the string like you would any other.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 16, 2009, 09:17:02 pm
well I wouldnt know what to do. I had the thing setup in the code like this
[SDsd] but that didnt work and I wouldnt know what else to try.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on March 16, 2009, 10:33:30 pm
its in Blizz-ABS.  here, let me find it...

event.name.clone.gsub!('\spc') {''}


thats how it looks through event names in blizzabs.

For messages, replace event.name with whatever you get the message text from.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 16, 2009, 10:44:40 pm
It doesnt work :( heres the code I have
Spoiler: ShowHide
class Window_Message < Window_Selectable
  alias message_system_later refresh
  def refresh
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      # Everything related to Actors
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      # Everything related to Skills
      text.gsub!(/\\[Ss]\[([0-9]+)\]/) do
        $data_skills[$1.to_i] != nil ? $data_skills[$1.to_i].name : ""
      end
      text.gsub!(/\\[Ii]\[([0-9]+)\]/) do
        $data_items[$1.to_i] != nil ? $data_items[$1.to_i].name : ""
      end
      text.gsub!(/\\[Aa]\[([0-9]+)\]/) do
        $data_armors[$1.to_i] != nil ? $data_armors[$1.to_i].name : ""
      end
      text.gsub!(/\\[Ww]\[([0-9]+)\]/) do
        $data_weapons[$1.to_i] != nil ? $data_weapons[$1.to_i].name : ""
      end
      text.gsub!(/\\[Ee]\[([0-9]+)\]/) do
        $data_enemies[$1.to_i] != nil ? $data_enemies[$1.to_i].name : ""
      end
      text.gsub!('\ah') {$game_actors[$1.to_i].hp}
      text.gsub!('\amh') {$game_actors[$1.to_i].maxhp}
    end
    message_system_later
  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on March 17, 2009, 02:28:20 am
That's for "\spc", not for "[spc]".
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 17, 2009, 04:14:42 pm
What do you mean its for "\spc"?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 17, 2009, 04:30:23 pm
Two things:

1) He meant that it checked the event's name for \spc, not [spc].

2) I'm fairly sure you can just use

event.name.gsub('[spc]') do '' end

Since regular gsub copies on its own 0_o
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 17, 2009, 05:44:51 pm
I dont want to see what an events name is its for a message system. The message system uses this \n[1] to display a name. I want this
\ah[1] to display Game_actor 1's hp.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: shdwlink1993 on March 17, 2009, 07:57:09 pm
Like this?

text.gsub!(/\\[Aa][Hh]\[([0-9]+)\]/) { $game_actors[$1.to_i].hp.to_s }
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 17, 2009, 09:33:09 pm
Will that work? I'll try it once rpg maker xp is re-installed.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 17, 2009, 09:36:34 pm
Good luck. And yes, that will almost definitely work just by glancing at the code.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 17, 2009, 09:41:06 pm
YES IT WORKS FINALLY!!!! I've been trying to get it to work forever thank you shdwlink!! *powers up*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 20, 2009, 02:02:50 pm
Another question  :^_^':
How do we check an events x or y coordinate through script call?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Landith on March 20, 2009, 02:07:14 pm
$game_map.events[@event_id].x

$game_map.events[@event_id].y

I think... :/
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 20, 2009, 03:01:49 pm
it doesnt work :(
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on March 20, 2009, 03:34:50 pm
Here's a tip:

Look in the Scene_Map class. You'll find a variable for events there. Find out what class is being stored there.
Next, go find either a) that class's source in the scripts or b) that class's documentation in the help file.
Finally, look for something with 'x' in it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 22, 2009, 11:17:31 pm
Gots a new question I am making a status menu for my ABS Arcade game and I want the enemies to be animated in the menu so it looks like they are walking in place. How would I go doing this?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on March 23, 2009, 06:36:11 am
Use sprites and link them to the window as needed. For example, window.visible=false will also do sprite.visible = false. Check out STCMS and see how Blizz did it. That, or you could constantly use contents.blt to paste the graphic, which I don't recommend (but I mentioned this cause it might be considerable).
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 24, 2009, 01:58:59 pm
I didnt quite get it working  :^_^': But anyways new question :P Of course :)
How do I transfer a player using script call?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: shdwlink1993 on March 24, 2009, 02:17:08 pm
You'd use:

$game_temp.player_new_map_id = <<New Map>>
$game_temp.player_new_x = <<New X>>
$game_temp.player_new_y = <<New Y>>
$game_temp.player_new_direction = <<New Direction to face>>
$scene.transfer_player


while on the map.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 27, 2009, 05:11:11 pm
Another question :^_^':
I have something setup for a font changing size and and font changer. My script does what its supposed to do. This is the part thats not working I have the class game_system set up heres my script can someone help please?
class Game_System
  attr_accessor :font                    # font
  attr_accessor :size                    # size
  alias re_init initialize
  def initialize
    @font = "Arial"
    @size = 20
    re_init
  end
end

class Font
  alias change_font initialize
  def initialize
    change_font
    self.name = $game_system.font
    self.size = $game_system.size
  end
end


When I use $game_system.font = "Arial Black" it doesnt work. the $game_system.size = 10 doesnt work eitehr can someone help?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 28, 2009, 11:46:26 pm
Quote from: game_guy on March 27, 2009, 05:11:11 pm
Another question :^_^':
I have something setup for a font changing size and and font changer. My script does what its supposed to do. This is the part thats not working I have the class game_system set up heres my script can someone help please?
class Game_System
  attr_accessor :font                    # font
  attr_accessor :size                    # size
  alias re_init initialize
  def initialize
    @font = "Arial"
    @size = 20
    re_init
  end
end

class Font
  alias change_font initialize
  def initialize
    change_font
    self.name = $game_system.font
    self.size = $game_system.size
  end
end


When I use $game_system.font = "Arial Black" it doesnt work. the $game_system.size = 10 doesnt work eitehr can someone help?


*bumps*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Landith on March 29, 2009, 01:21:29 am
Make the class font part to module font and try calling it with change_font, after you set the $game_system.font = "Arial Black"

So like an example would be:


$game_system.font = "Arial Black"
change_font


and your code would be

class Game_System
  attr_accessor :font                    # font
  attr_accessor :size                    # size
  alias re_init initialize
  def initialize
    @font = "Arial"
    @size = 20
    re_init
  end
end

module Font
  alias change_font initialize
  def initialize
    change_font
    self.name = $game_system.font
    self.size = $game_system.size
  end
end


You can try that.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on March 29, 2009, 08:41:22 am
I suggest you rather use something like my Ultimate Font Override.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 29, 2009, 12:18:53 pm
Quote from: Blizzard on March 29, 2009, 08:41:22 am
I suggest you rather use something like my Ultimate Font Override.


Normally I would but this isn't for changing the font :P
I'm trying to learn to be a better scripter. More knowledge of RGSS the better.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on March 30, 2009, 11:30:58 am
You could learn from Ultimate Font Override, if not use it. I did the same. But in the end, my version came out pretty much the same.

PS: btw, doesn't Font#initialize have arguments? Shouldn't it be like:

alias re_init initialize
def initialize(*args)
  #stuff
  re_init(args)
end


*args will simply pass all the given arguments to the aliases method. You use this when you're not sure about the number of arguments or you don't want to handle them again when you don't need to.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 30, 2009, 11:54:27 pm
How do we cut image script wise. I seen it in Berans Ipod Script.
(http://i307.photobucket.com/albums/nn318/bahumat27/bluenumbers.png)

I want to be able to cut that up in a script so I can use it or something. But how would I go like "cutting" it up like make it display only one section of the image?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 04, 2009, 09:20:47 am
Quote from: game_guy on March 30, 2009, 11:54:27 pm
How do we cut image script wise. I seen it in Berans Ipod Script.
(http://i307.photobucket.com/albums/nn318/bahumat27/bluenumbers.png)

I want to be able to cut that up in a script so I can use it or something. But how would I go like "cutting" it up like make it display only one section of the image?

*bump*

It is a whole image. All the numbers are put together.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: shdwlink1993 on April 04, 2009, 11:47:01 pm
Something like this would work (I think):

self.bitmap = RPG::Cache.picture('Numbers', 0)
self.ox = bitmap.width / 10
self.oy = bitmap.height
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on April 05, 2009, 04:41:39 am
That won't cut the image, it'll only set the ox. For cutting the image, you'd need self.src_rect.set(x, y, w, h). Check it out in Arrow_Actor class, see how it selects the cursor parts from the windowskin.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Reno-s--Joker on April 05, 2009, 08:14:03 am
Wow, now that is a handy thing I did not know. <333
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 08, 2009, 09:22:04 pm
I need some major help and it involves my new script with the background changer. I am so stuck on this and can't figure it out.
Here's my script.

module GameGuy
  Tilesets_Apply          = [1]
  Terrain1                = "001-Grassland01"
  Terrain2                = "002-Woods01"
  Terrain3                = "003-Forest01"
  Terrain4                = "004-Mountain01"
  Terrain5                = "004-Mountain01"
  Terrain6                = "004-Mountain01"
  Terrain7                = "004-Mountain01"
end
class Scene_Map
  alias re_update update
  def update
    re_update
    if GameGuy::Tilesets_Apply.include?($data_tilesets[$game_map.tileset_name])
      if $game_map.terrain_tag($game_player.x, $game_player.y) == 1
        $game_map.battleback_name = GameGuy::Terrain1
      elsif $game_map.terrain_tag($game_player.x, $game_player.y) == 2
        $game_map.battleback_name = GameGuy::Terrain2
      elsif $game_map.terrain_tag($game_player.x, $game_player.y) == 3
        $game_map.battleback_name = GameGuy::Terrain3
      elsif $game_map.terrain_tag($game_player.x, $game_player.y) == 4
        $game_map.battleback_name = GameGuy::Terrain4
      elsif $game_map.terrain_tag($game_player.x, $game_player.y) == 5
        $game_map.battleback_name = GameGuy::Terrain5
      elsif $game_map.terrain_tag($game_player.x, $game_player.y) == 6
        $game_map.battleback_name = GameGuy::Terrain6
      elsif $game_map.terrain_tag($game_player.x, $game_player.y) == 7
        $game_map.battleback_name = GameGuy::Terrain7
      end
    end
  end
end


Its an unreleased non working version. Anyways I want to make it so you have to enter the tileset id's in the
Tilesets_Apply so that the background changer only works on the tileset id's you entered in there
but I am having troubles getting to that.

Please someone help :(
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on April 09, 2009, 05:44:29 am
Tilesets_Apply          = [1]


if GameGuy::Tilesets_Apply.include?($data_tilesets[$game_map.tileset_name])


I'm not sure, but I don't think $data_tilesets[$game_map.tileset_name] is a number, it has to be one of those RPG:: objects. Try checking that out. If that IS the case, something like this might work:
if GameGuy::Tilesets_Apply.include?($data_tilesets[$game_map.tileset_name].id)

PS: This is all off my head, there is every chance I could be wrong.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 09, 2009, 09:53:13 am
actually this works tested

Spoiler: ShowHide
module GameGuy
  Tilesets_Apply          = [1, 3]
  Terrain1                = "001-Grassland01"
  Terrain2                = "002-Woods01"
  Terrain3                = "003-Forest01"
  Terrain4                = "004-Mountain01"
  Terrain5                = "004-Mountain01"
  Terrain6                = "004-Mountain01"
  Terrain7                = "004-Mountain01"
end
class Scene_Map
  alias re_update update
  def update
    re_update
   if GameGuy::Tilesets_Apply.include?($game_map.map_id)
      if $game_player.terrain_tag == 1
        $game_map.battleback_name = GameGuy::Terrain1
      elsif $game_player.terrain_tag == 2
        $game_map.battleback_name = GameGuy::Terrain2
      elsif $game_player.terrain_tag == 3
        $game_map.battleback_name = GameGuy::Terrain3
      elsif $game_player.terrain_tag == 4
        $game_map.battleback_name = GameGuy::Terrain4
      elsif $game_player.terrain_tag == 5
        $game_map.battleback_name = GameGuy::Terrain5
      elsif $game_player.terrain_tag == 6
        $game_map.battleback_name = GameGuy::Terrain6
      elsif $game_player.terrain_tag == 7
        $game_map.battleback_name = GameGuy::Terrain7
      end
    end
  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on April 09, 2009, 11:49:19 am
lol nathmatt! I only made things complicated >.< *powers up*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 09, 2009, 05:21:14 pm
Quote from: nathmatt on April 09, 2009, 09:53:13 am
actually this works tested

Spoiler: ShowHide
module GameGuy
  Tilesets_Apply          = [1, 3]
  Terrain1                = "001-Grassland01"
  Terrain2                = "002-Woods01"
  Terrain3                = "003-Forest01"
  Terrain4                = "004-Mountain01"
  Terrain5                = "004-Mountain01"
  Terrain6                = "004-Mountain01"
  Terrain7                = "004-Mountain01"
end
class Scene_Map
  alias re_update update
  def update
    re_update
   if GameGuy::Tilesets_Apply.include?($game_map.map_id)
      if $game_player.terrain_tag == 1
        $game_map.battleback_name = GameGuy::Terrain1
      elsif $game_player.terrain_tag == 2
        $game_map.battleback_name = GameGuy::Terrain2
      elsif $game_player.terrain_tag == 3
        $game_map.battleback_name = GameGuy::Terrain3
      elsif $game_player.terrain_tag == 4
        $game_map.battleback_name = GameGuy::Terrain4
      elsif $game_player.terrain_tag == 5
        $game_map.battleback_name = GameGuy::Terrain5
      elsif $game_player.terrain_tag == 6
        $game_map.battleback_name = GameGuy::Terrain6
      elsif $game_player.terrain_tag == 7
        $game_map.battleback_name = GameGuy::Terrain7
      end
    end
  end
end



Yea but I wanted it for tilesets not maps.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 09, 2009, 06:58:32 pm
there for tilesets but it goes by the name of it not the id
Spoiler: ShowHide
module GameGuy
  Tilesets_Apply          = [001-Grassland01]
  Terrain1                = "001-Grassland01"
  Terrain2                = "002-Woods01"
  Terrain3                = "003-Forest01"
  Terrain4                = "004-Mountain01"
  Terrain5                = "004-Mountain01"
  Terrain6                = "004-Mountain01"
  Terrain7                = "004-Mountain01"
end
class Scene_Map
  alias re_update update
  def update
    re_update
   if GameGuy::Tilesets_Apply.include?($game_map.tileset_name)
      if $game_player.terrain_tag == 1
        $game_map.battleback_name = GameGuy::Terrain1
      elsif $game_player.terrain_tag == 2
        $game_map.battleback_name = GameGuy::Terrain2
      elsif $game_player.terrain_tag == 3
        $game_map.battleback_name = GameGuy::Terrain3
      elsif $game_player.terrain_tag == 4
        $game_map.battleback_name = GameGuy::Terrain4
      elsif $game_player.terrain_tag == 5
        $game_map.battleback_name = GameGuy::Terrain5
      elsif $game_player.terrain_tag == 6
        $game_map.battleback_name = GameGuy::Terrain6
      elsif $game_player.terrain_tag == 7
        $game_map.battleback_name = GameGuy::Terrain7
      end
    end
  end
end

& blizz"s unofficial h window
Spoiler: ShowHide
Quote from: Doris on March 25, 2008, 11:35:30 am
Damn, I thought I had the code. This is what I am using:

#==============================================================================
# Window_Horizontal
#==============================================================================

class Window_Horizontal < Window_Base
 
  attr_reader :commands
 
  def initialize(w, commands)
    super(0, 0, 3 * w + 32, 64)
    @item_max = commands.size
    @commands = commands
    if @item_max > 0
      self.contents = Bitmap.new((@item_max + 4) * w, height - 32)
    else
      self.contents = Bitmap.new(32, height - 32)
    end
    @dir = 0
    self.contents.font.name, self.contents.font.size = 'Brush Script', 26
    self.opacity = self.index = 0
    refresh
  end
 
  def refresh
    self.contents.clear
    (0...@item_max+4).each {|i| draw_item(i, (i + @item_max - 2) % @item_max)}
  end
 
  def get_command
    return @commands[(@index + @item_max) % @item_max]
  end
 
  def draw_item(i, index, color = nil)
    rect = Rect.new((self.width - 32)/3 * i, 0, (self.width - 32)/3, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    if color.is_a?(Color)
      self.contents.font.color = color
    else
      self.contents.font.color = case @commands[index]
      when 'And again!', 'Und nochmal!' then text_color(3)
      when 'Warrior', 'Krieger' then text_color(6)
      when 'Exerion' then text_color(2)
      when 'Options', 'Optionen' then text_color(1)
      when 'Debug Room' then text_color(8)
      when 'Lost Memories', 'Erinnerungen' then text_color(9)
      when 'Hexahax' then Color.new(0, 192, 255)
      when 'Lexima One' then Color.new(0, 255, 96)
      else
        normal_color
      end
    end
    self.contents.draw_text_outline(rect, @commands[index], 1)
  end
 
  def disable_item(index)
    draw_item((index + 2) % @item_max, index, disabled_color)
    draw_item((index + 2) % @item_max + @item_max, index, disabled_color)
    draw_item((index + 2) % @item_max + @item_max*2, index, disabled_color)
  end
 
  def size
    return @commands.size
  end
 
  def update
    super
    if moving?
      case @dir.abs
      when 1 then self.ox -= 5 * @dir.sgn
      when 2 then self.ox -= 10 * @dir.sgn
      when 3 then self.ox -= 20 * @dir.sgn
      when 4 then self.ox -= 45 * @dir.sgn
      when 5 then self.ox -= 45 * @dir.sgn
      when 6 then self.ox -= 20 * @dir.sgn
      when 7 then self.ox -= 10 * @dir.sgn
      when 8 then self.ox -= 5 * @dir.sgn
      end
      @dir -= @dir.sgn
    end
    if !moving? && self.active && @item_max > 0
      if Input.repeat?($controls.right)
        $game_system.se_play($data_system.cursor_se)
        @index = @index % @item_max + 1
        if self.ox == (@item_max + 1)* (self.width - 32)/3
          self.ox -= @item_max * (self.width - 32)/3
          @index = 1
        end
        @dir = -8
      elsif Input.repeat?($controls.left)
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + @item_max - 2) % @item_max + 1
        if self.ox == (self.width - 32)/3
          self.ox += @item_max * (self.width - 32)/3
          @index = @item_max - 1
        end
        @dir = 8
      end
    end
    update_cursor_rect
  end
 
  def moving?
    return (@dir != 0)
  end
     
  def index=(index)
    @index = index
    self.ox = (index + 1) * (self.width - 32)/3
    update_help if self.active && @help_window != nil
    update_cursor_rect
  end
 
  def update_cursor_rect
    self.cursor_rect.set((self.width - 32)/3, 0, (self.width - 32)/3, 32)
  end
 
end


But it's the command window that moves around as well. Hm... I remember somebody posting a horizontal command window at the old CP forum. You could try looking for it there.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 10, 2009, 04:23:36 am
I posted a version for public use of a horizontal window several times already and that's not the one. -_-
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 25, 2009, 02:08:14 pm
Okay nother question guys sorry :^_^':

How do we check if an item has an element checked? I'm making this Augmentation system like off of fable. Also how do we add an element or remove it from an item?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on April 25, 2009, 02:14:39 pm
The Help File Helps
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 25, 2009, 02:17:59 pm
I see how to add elements but I still dont see how to check if it has an element checked.'

Ok I still dont know how to add them or see if one is checked. I only know how to set the elements in an array
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 28, 2009, 06:05:05 pm
More help :<_<: probably getting sick of me huh? >.<

Anyways couple of questions

How do I wait frames in rgss and how do I randomize variables in rgss?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 28, 2009, 06:13:45 pm
there is no wait command in rgss ur best bet is to use a variable so put in update that if  @wait_count > 0 @wait_count = - 1 and for random u use rand(n)  so u use n as the range
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 28, 2009, 06:19:50 pm
There has to be a wait command because The event editor has a Wait command and it waits the amount of frames you put in.
Spoiler: ShowHide
(http://i307.photobucket.com/albums/nn318/bahumat27/eventcommands.png)

Each event command has a line of script behind it.

But for the random thing use
Rnd(8)

and it'll randomize a number between 0-8?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 28, 2009, 06:33:47 pm
yea put
rand(8)


& thats how they do the wait command the have a @wait_count in there update method
look at the update method in scene battle
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 14, 2009, 06:01:49 pm
New question.

I want to be able to find the percentage of somethign how would I do so? Wouldnt i use this?
$value = 1000 %

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on May 14, 2009, 06:03:45 pm
A percent in math is...

Value / Max Value * 100

Gosh... so simple math =X
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on May 14, 2009, 06:05:22 pm
This will be always 0 if Value and MaxValue are both integers. Better use

Value  * 100 / MaxValue
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 14, 2009, 06:06:02 pm
There is no max value. I want to be able to find what 1% = compared to a number. Like so...

1% of 100 = 1
1% of 1000 = 10
etc....

There is no ma value to divide by thats why I was asking.....
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on May 14, 2009, 06:09:12 pm
DON'T YOU KNOW YOUR MATH!?!? >8U

1% = 0.01
10% = 0.1
etc
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 14, 2009, 06:14:42 pm
That's only for the number 1. Try getting the single percent for this than

23385
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on May 14, 2009, 06:18:01 pm
You mean 23385% of something?

233.85
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 14, 2009, 06:28:29 pm
Oh so I just move the decimal is all?

Thank you aqua thats all I wanted to know but

What if I dont know what the value will be? How would I get that mathematical in RGSS. I'm going to make Gold Boosting Equipments

and I wanted an equation that did that so than I can take the percentage from the armor and add it to the gold amount
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on May 14, 2009, 06:33:58 pm
Where val = the % of the gold increase you want

gold_increase_percent = val.to_f / 100


Then add that as a % modifier to the amount of gold you receive.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 14, 2009, 06:35:25 pm
Thank you so much aqua. *powers up*

Just what I needed to finish this. If I do release the script (might be private for my game not sure) You'll be on the special thanks.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 20, 2009, 09:11:41 pm
How do we setup
$game_temp.shop_goods


I need to figure this out for a script for my game.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: legacyblade on May 20, 2009, 11:10:57 pm
long answer:

Spoiler: ShowHide
Not sure how to set it up, but try and find out what is inside $game_temp.shop_goods to find out, use


p $game_temp.shop_goods


When the shop scene is called. I'm guessing that it just needs an array of the IDs of which items will be for sale, but you should check. It would get this information from the interpreter script, which would get information from the data files. You're best bet is to find out what kind of data is stored in $game_temp.shop_goods, and what information the shop scene needs.


short answer:

Spoiler: ShowHide

$game_temp.shop_goods = something


It is most likely an array of the IDs of the items the shop will have.



Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 20, 2009, 11:24:19 pm
$game_temp.shop_goods is an array that looks like this
[[x, y], [x, y], [x, y], [x, y]]


where x is the item type
case x
when 0
  item is a $data_items
when 1
  item is a $data_weapons
when 2
item is a $data_armors
end

and y is the items ID
so...
[[0, 1], [1, 1], [2, 1]]

would create a shop where you could buy a potion, bronze sword, and bronze shield in that order

hope this helps!

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 20, 2009, 11:44:51 pm
Quote from: Ryexander on May 20, 2009, 11:24:19 pm
$game_temp.shop_goods is an array that looks like this
[[x, y], [x, y], [x, y], [x, y]]


where x is the item type
case x
when 0
  item is a $data_items
when 1
  item is a $data_weapons
when 2
item is a $data_armors
end

and y is the items ID
so...
[[0, 1], [1, 1], [2, 1]]

would create a shop where you could buy a potion, bronze sword, and bronze shield in that order

hope this helps!




Thanks Rye *powers up*

And lb of course
$game_temp.shop_goods is going to equal something xD thanks anyways lb *powers up*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 20, 2009, 11:53:23 pm
yay I need power!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: legacyblade on May 21, 2009, 12:09:17 am
yay, power! And Game_Guy, that is how I find out what I need about certain data structures, print them when they're in use. It's how I figured out the move picture command in RGSS. I was just giving you my standard process.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 21, 2009, 12:57:41 am
Quote from: legacyblade on May 20, 2009, 11:10:57 pm
short answer
Spoiler: ShowHide

$game_temp.shop_goods = something


It is most likely an array of the IDs of the items the shop will have.






I was referring to the short answer. $game_temp.shop_goods = something of course it'll equal something xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: legacyblade on May 21, 2009, 01:42:07 am
oh, lol. My short answers are usually a sarcastic literal answer of the question :P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 22, 2009, 10:06:29 pm
Ok I want to be able to have each item have rarity stars. Now I have the icon but how would I go making this icon be display 1, 2, 3, 4, or 5 times on that item line?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 23, 2009, 05:34:22 pm

n.times do |i|
  src_rect = Rect.new(0, 0, 24, 24)
  <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 23, 2009, 05:51:18 pm
so do I replace the i or the n with the number of times?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on May 23, 2009, 06:04:17 pm
Quote from: Ryexander on May 23, 2009, 05:34:22 pm
where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever



You could also do...

for i in item.rarity
 src_rect = Rect.new(0, 0, 24, 24)
 <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

This way you don't have to use conditions nor the n.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 23, 2009, 06:11:07 pm
Quote from: Aqua on May 23, 2009, 06:04:17 pm
Quote from: Ryexander on May 23, 2009, 05:34:22 pm
where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever



You could also do...

for i in item.rarity
 src_rect = Rect.new(0, 0, 24, 24)
 <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

This way you don't have to use conditions nor the n.


I just replaced the n with item.rarity and it worked so there was no need to have branches.... thanks guys (lvs up aqua and ryex)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 23, 2009, 08:10:30 pm
Quote from: Aqua on May 23, 2009, 06:04:17 pm
Quote from: Ryexander on May 23, 2009, 05:34:22 pm
where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever



You could also do...

for i in item.rarity
 src_rect = Rect.new(0, 0, 24, 24)
 <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

This way you don't have to use conditions nor the n.

You COULD  use a 'for i in' but you SHOULDN'T it's slow and  'n.times do |i| end' is much faster WcW taught me that
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 23, 2009, 08:48:29 pm
Either way this question is resolved but could someone just explain how i would call a bitmap like the one ryex told me through the window.

I just want to know what everything in the line does.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 23, 2009, 08:55:46 pm
in a window
n.times do |i|
  src_rect = Rect.new(0, 0, 24, 24)
  self.contents.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

self.contents IS a Bitmap instance

but elsewhere

bitmap = Bitmap.new(width, height)
n.times do |i|
  src_rect = Rect.new(0, 0, 24, 24)
  bitmap.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 23, 2009, 08:57:27 pm
Ok that makes a bit more sense now what exactly does src_rect do/mean?

Just trying to learn as much as I can
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 23, 2009, 09:11:14 pm
src_rect is a compressed form of source_rectangle it is an instenct of the Rect class the Rect class simply stores a rectangle
so
src_rect = Rect.new(0, 0, 24, 24)
creates a Rect instance with the dimensions 24 by 24 at the co-ordanets (0, 0)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on May 23, 2009, 09:25:32 pm
You should probably just add the Rect.new parts inside the argument list, skip over storing then reloading the variable.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 23, 2009, 09:26:03 pm
Thanks both of you *lv's both up*

Any bit of RGSS I can learn the better.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 03, 2009, 10:29:27 pm
Another question...

How would we turn an events Self Switches off via script call?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 04, 2009, 03:50:28 am
$game_self_switches[[MAP_ID, EVENT_ID, 'ID']] = false


MAP_ID = a number
EVENT_ID = a number
ID = A, B, C or D
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on June 05, 2009, 05:08:45 pm
Quote from: Blizzard on June 04, 2009, 03:50:28 am
$game_self_switches[[MAP_ID, EVENT_ID, 'ID']] = false
$game_map.need_refresh = true


MAP_ID = a number
EVENT_ID = a number
ID = A, B, C or D


Fixed :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 05, 2009, 05:18:51 pm
He didn't say he wanted to apply it to the map immediately. :P *hides*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 05, 2009, 05:19:35 pm
Hmm very true thanks both of you guys *double lv up*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 07, 2009, 06:38:52 pm
Another question guys.

How would we go deleting a save file via script?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on June 07, 2009, 08:05:40 pm
File.delete('Filename.rxdata')


:)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 07, 2009, 08:06:06 pm
Thanks aqua *lv's up*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 10, 2009, 04:11:11 am
Another question....well ok two.

First one. How do we change the player's speed via script?

Second. Could someone explain how the zoom_x and zoom_y works and tell me how to use it please?

Thanks guys in advance!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 03:50:47 pm
Another Question....
How is everything setup in the Enemie's Element Ranks? Or the Element Efficiancy is what its called in teh database.
I tried printing it and it didnt work just printed <Table0xsome random numbers here>
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 04:57:48 pm
print it for me an i'll interpret , just up load a screen shot of the print
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 05:40:14 pm
Here it is
(http://i307.photobucket.com/albums/nn318/bahumat27/print.png)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 06:08:41 pm
oh... well never mind that means nothing to me. how are you printing it?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 06:12:58 pm
print $data_enemies[1].element_ranks

then I tried
print $data_enemies[1].element_ranks.to_s

And that still didnt work :P I dont know what else to do
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on June 20, 2009, 06:16:42 pm
It might be that there's too much stuff to print and can't fit on a print window?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 06:37:39 pm
p $data_enemies[1].element_ranks[1]

tell me what that dose
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 06:39:14 pm
Well see in the thing right here

This is the script that controls $data_enemies
Spoiler: ShowHide
module RPG
 class Enemy
   def initialize
     @id = 0
     @name = ""
     @battler_name = ""
     @battler_hue = 0
     @maxhp = 500
     @maxsp = 500
     @str = 50
     @dex = 50
     @agi = 50
     @int = 50
     @atk = 100
     @pdef = 100
     @mdef = 100
     @eva = 0
     @animation1_id = 0
     @animation2_id = 0
     @element_ranks = Table.new(1)
     @state_ranks = Table.new(1)
     @actions = [RPG::Enemy::Action.new]
     @exp = 0
     @gold = 0
     @item_id = 0
     @weapon_id = 0
     @armor_id = 0
     @treasure_prob = 100
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :battler_name
   attr_accessor :battler_hue
   attr_accessor :maxhp
   attr_accessor :maxsp
   attr_accessor :str
   attr_accessor :dex
   attr_accessor :agi
   attr_accessor :int
   attr_accessor :atk
   attr_accessor :pdef
   attr_accessor :mdef
   attr_accessor :eva
   attr_accessor :animation1_id
   attr_accessor :animation2_id
   attr_accessor :element_ranks
   attr_accessor :state_ranks
   attr_accessor :actions
   attr_accessor :exp
   attr_accessor :gold
   attr_accessor :item_id
   attr_accessor :weapon_id
   attr_accessor :armor_id
   attr_accessor :treasure_prob
 end
end


I wanted to find out how to add elements into there element ranks and change the efficiency and stuff. I wanted to make a boss in my game where once you hit it with whatever element it'll change to that element and absorb all of that element until its hit with a different element.

EDIT: @reyx you posted before me :P

EDIT 2: It printed one which doesnt seem right...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 06:49:26 pm
now fell me what this dose
p $data_enemies[1].element_ranks[2]


if it prints 3 this i know how it works
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 06:50:00 pm
yup it prints 3 if you can help me with this I'd be so grateful ryex!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 06:54:54 pm
ok so  it is a table class, Don't ask me whay they just did it that way it works like this p

$data_enemies[<id>].element_ranks[<elamit id>] => rank
where rank is 0, 1, 2, 3, 4, or 5 which means A, B, C, D, E, or F from the database
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 07:00:38 pm
exactly how is it layed out though?
[1 => 3, 4=> 4]


Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 07:01:48 pm
it's in an array but stupid enterbrain decided to but the array in a table so you can really print it
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 07:04:33 pm
yea but I wanna know how to set it up still
[1 => 3, 4=> 4] is this what you mean in your post before?

And then how would I change an efficiancy of an element?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 07:10:39 pm
it is layed out in and array where the position is the elamit id and the value is the rank
so
for the default ghost his array look like this

[ 0, 2, 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3]

1 => A
2 => B
3 => C
4 => D
5 => E
6 => F

EDIT: sorry had the data wrong now it is right
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 07:17:08 pm
ah ok so the first one, nil, is element id 0 which there isnt one
then it goes on I see ok thanks ryex *lv's up* will level you up again when I can this'll help out alot for this boss
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 20, 2009, 07:17:55 pm
edit recheck my post i had the data wrong
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 20, 2009, 07:18:28 pm
Ah ok still thank you ryex
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 21, 2009, 06:35:15 am
Iteration through tables:

(0...table.xsize).each {|x| (0...table.ysize).each {|y| (0...table.zsize).each {|z| table[x, y, z]}}}


Keep in mind that your table might be 2 dimensional so you would have to use table[x, y] and only 2 loops.
Also, tables cannot be printed like other things. They are internally defined in a different way and nobody implemented a proper inspect method in them. :/
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 21, 2009, 01:58:02 pm
Quote from: Blizzard on June 21, 2009, 06:35:15 am
Iteration through tables:

(0...table.xsize).each {|x| (0...table.ysize).each {|y| (0...table.zsize).each {|z| table[x, y, z]}}}


Keep in mind that your table might be 2 dimensional so you would have to use table[x, y] and only 2 loops.
Also, tables cannot be printed like other things. They are internally defined in a different way and nobody implemented a proper inspect method in them. :/


this is why i think it is stupid that they are using a table for this; its a ONE dimensional table, EXACTLY like an array but no! they had to make it more complex than it should be.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on June 21, 2009, 02:02:26 pm
Quote from: Ryexander on June 21, 2009, 01:58:02 pm
Quote from: Blizzard on June 21, 2009, 06:35:15 am
Iteration through tables:

(0...table.xsize).each {|x| (0...table.ysize).each {|y| (0...table.zsize).each {|z| table[x, y, z]}}}


Keep in mind that your table might be 2 dimensional so you would have to use table[x, y] and only 2 loops.
Also, tables cannot be printed like other things. They are internally defined in a different way and nobody implemented a proper inspect method in them. :/


this is why i think it is stupid that they are using a table for this; its a ONE dimensional table, EXACTLY like an array but no! they had to make it more complex than it should be.


Okay, okay, I can take a hint! I need to sublcass Array, gotcha. >_>
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 21, 2009, 02:04:43 pm
wait what?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 21, 2009, 02:11:00 pm
There's a reason Table exists. It's much faster than multidimensional arrays.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on June 21, 2009, 03:37:36 pm
that may be true but why in the world would you use a ONE dimensional table?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 21, 2009, 03:49:11 pm
Again, speed. But tables are fixed sized and they only support integers from -32768 to 32767. That's the limitation.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on June 21, 2009, 04:25:09 pm
Quote from: Blizzard on June 21, 2009, 03:49:11 pm
Again, speed. But tables are fixed sized and they only support integers from -32768 to 32767. That's the limitation.


Any particular reason it's 16-bit?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 21, 2009, 04:26:18 pm
Probably because most data in tables doesn't need to have such a big range and probably for performance reasons. Table was made due to performance problems after all.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on June 21, 2009, 04:37:30 pm
How much of an increase could it really get over 32-bit (that's usually just a signed int, right?) It seems like the millions of more values would make it more than worth it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 22, 2009, 10:04:06 am
Ok, now slowly reread my post from before and this time please don't skip the part where I said that a table is not resizable (realloc is an expensive operation, hint, hint -_- ). Along with that I would assume that there are other tweaks for faster access. It's very probable that Ruby's Array class is actually an implementation of a list. Tables in that case would be even faster since they seem to definitely be arrays.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 02, 2009, 02:05:25 am
Another question......

How do I call up the message screen via script call? At the beginning of every battle I want a message to display that shows what the terrain is like
"Desert ~ Fire Power increased etc."

So at the beginning of every battle I want it to show a message all I need to know how is to call the message screen. I already ahve everything else setup.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 02, 2009, 04:43:47 am
Use a variable where you assign the player's terrain tag to. Just check the variable and you will know which tag it is. Then you simply do a conditional branch with text at the beginning of a battle.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 02, 2009, 11:27:26 am
I already have the terrain thing but i dont want to put a message and branch in a page on every troop I have. So I wanted to call the message easier so I could place it in the beginning of Scene_Battle.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: matte012 on July 02, 2009, 11:43:26 am
Common Events are a mans best thing y'know. Of course, I am not that advanced I know that common events can be used for such things, as long as the area provides the variables *is somewhat new to RPGXP*

(and now that I realized..are you using the default battle system (or at least not ABS). Because you can arrange the events to play when the battle starts using the nifty little thing on the troops section)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 02, 2009, 11:45:26 am
Yea but then at teh beginning of every battle I'd still have to place the common event on the first page of every troop. Where I just want to call the message or common event in the battle so its easier.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: matte012 on July 02, 2009, 11:49:03 am
As I spoke before, I do think you should either call the common event in the troop section (possibly with condition branches if X is in the party) or you can call through eventing. Either way is possible.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 02, 2009, 11:51:25 am
Look all I need is a message to display at the beginning of every battle. I dont want to place a text on one page in every single troop that would take to long. So heres what I have right now
module GameGuy
  def self.terrain_message
    case $game_player.terrain_tag
    when 1 then return "Battle Effects:\nIce power is increased.\nEarth power is weakened."
    when 2 then return "Battle Effects:\nFire power is increased.\nWater power is weakened."
    when 3 then return "Battle Effects:\nWater power is increased.\nThunder power is increased.\nFire power is weakened."
    end
    return "Battle Effects:\nNormal"
  end
end


All I want now is to call a message using GameGuy.terrain_message at the beginning of a battle in the actualy Scene_Battle so I can type it one time and not paste it in all my troops.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 02, 2009, 11:53:45 am
Just make a common event and call it on the beginning of battles. :P

EDIT: matte beat me to it. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 02, 2009, 12:00:23 pm
;__; how would I call it at the beginning of the battle without putting it in every troop.......nvm I'll figure it out myself.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 02, 2009, 12:01:54 pm
Call the common event at beginning of the battle scene (after the troop has being set up). Just use my common-event-by-script code.

EDIT: Even better. Find $game_troop.setup_battle_event. Do it there. In fact, you could code it right into Game_Troop#setup_battle_event. Screw events. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: matte012 on July 03, 2009, 02:15:14 am
As much as I cannot script, Blizz makes a point. There might be some kind of terrain tags somewhere that displays message but most likely not. Of course, calling a common even and copy and pasting on every troop wouldn't be too time consuming. Even Blizzards demo has around 40 troops (I hacked it, not for cheating, for reference O-O), setting the common even to a copy and paste would make adding it as easy as click on eventing troops add-on and hiting the nifty Ctrl+V button and moving on. Takes about 5 seconds on each troop..

But, possibly go for Blizz's technique. And maybe if you ask nicely, make a shrine of him in Toronto, pray to him and give him bribes he might script it for you. Okay, maybe if you ask nicely. It seems like a small script, still to big for my understanding. Makes me wish there was a 'RGSS For Dummies' eh?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on July 03, 2009, 02:18:07 am
If you edit the Game_Troops scripts, you wouldn't need to copy paste events :P
^That's what Blizz means.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: matte012 on July 03, 2009, 02:21:56 am
Still of course looking from a 'if you cannot script' point of view, like me ^_^

(Edit: That is relating to the 'why copy and paste' not the comment about Game_Troop.)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 03, 2009, 02:28:55 am
Yea but who knows how many troops I'm going to have? I'd rather just get it out of the way. Anyways I already have the terrain tags store a message into a variable. I have a common event that displays that variable in a text. And I followed blizz's way and now I have it all setup.

In my above config it checks the id of the player's terrain tag then returns a message instead.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: matte012 on July 03, 2009, 02:33:52 am
...I see. Not much else I could provide on the topic. Good luck man on your game. Lucky you have an idea how to script, right now I am a leecher. And, if you wouldn't mind. I am available for criticism on everything, if I could come up with 5 wrong things with the beta of Chaos Project, I think all gamers should fear my review.

(Edit: I somewhat had an idea of what it does. I'm just using the 'I cannot script' route)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on July 03, 2009, 02:37:52 am
Off-topic
@Matte:
The version of CP demo you downloaded is veeeerrrrry old; lots of things have changed since its release.
If you want the newer version, then ask Blizz to sign up to be a Beta Tester here (http://forum.chaos-project.com/index.php?topic=1591.0)
It's even unencrypted, so you can use it to learn
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 03, 2009, 05:13:03 am
Yeah, I was just going to say that. ^_^ In the beta there are over 260 troops.
I was suggesting the copy-paste idea because it's probably not necessary to script it if you can't script. I would use a script because making one would take me a few minutes and it would be automatic while somebody else would spend way less time copy-pasting each event. Sure, my method would be more error proof, but it also requires to know scripting.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 03, 2009, 02:58:31 pm
anyways I got the common event thign by script to work and its all setup in Game_Troops so now its over and done with. Any troop I make just has to have enemies dealt in it (putting aside cutscenes and whatnot) :) *thnx blizzy* 

So heres how it works. In my module GameGuy I have two methods. One that has the battle effects message and then the other who actually changes the skills power.

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 21, 2009, 04:49:44 pm
Another Question *sighs*

Is there a way to dispose a blt in a window?

If not is it possible to draw a bitmap in a window a different way then dispose of it later?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 22, 2009, 03:15:53 am
blt draws one bitmap on another, self.contents IS a bitmap. You can use .clear to clear the entire bitmap or ".fill_rect(x, y, width, height, Color.new(0, 0, 0, 0))" to clear just a specific area.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 24, 2009, 11:59:35 pm
Yet another question. Is it possible to create a folder using rgss?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on July 25, 2009, 12:39:51 am
have you tried to write to a path that dose not exist yet? because it might create them automatically
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 25, 2009, 06:19:25 am
Nope. You need FileUtils or you need to use an API call.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 25, 2009, 08:31:02 am
could you post the FileUtils? or link me where they would be?

EDIT: Found it but now how do I make a folder with it?

Spoiler: ShowHide
# 
# = fileutils.rb
#
# Copyright (c) 2000-2005 Minero Aoki <aamine@loveruby.net>
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
#
# == module FileUtils
#

module FileUtils

  def self.private_module_function(name)   #:nodoc:
    module_function name
    private_class_method name
  end

  OPT_TABLE = {}   #:nodoc: internal use only
 
  def copy(src, dest, options = {})
    fu_check_options options, :preserve, :noop, :verbose
    fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    fu_each_src_dest(src, dest) do |s, d|
      copy_file s, d, options[:preserve]
    end
  end
  module_function :copy

  OPT_TABLE['copy'] = %w( noop verbose preserve )

  def fu_check_options(options, *optdecl)   #:nodoc:
    h = options.dup
    optdecl.each do |name|
      h.delete name
    end
    raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
  end
  private_module_function :fu_check_options
 
  def fu_each_src_dest(src, dest)   #:nodoc:
    fu_each_src_dest0(src, dest) do |s, d|
      raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
      yield s, d
    end
  end
  private_module_function :fu_each_src_dest

  def fu_each_src_dest0(src, dest)   #:nodoc:
    if src.is_a?(Array)
      src.each do |s|
        s = s.to_str
        yield s, File.join(dest, File.basename(s))
      end
    else
      src = src.to_str
      if File.directory?(dest)
        yield src, File.join(dest, File.basename(src))
      else
        yield src, dest.to_str
      end
    end
  end
  private_module_function :fu_each_src_dest0

  def fu_same?(a, b)   #:nodoc:
    if fu_have_st_ino?
      st1 = File.stat(a)
      st2 = File.stat(b)
      st1.dev == st2.dev && st1.ino == st2.ino
    else
      File.expand_path(a) == File.expand_path(b)
    end
  rescue Errno::ENOENT
    return false
  end
  private_module_function :fu_same?

  def fu_have_st_ino?   #:nodoc:
    !fu_windows?
  end
  private_module_function :fu_have_st_ino?

  def copy_file(src, dest, preserve = false, dereference = true)
    ent = Entry_.new(src, nil, dereference)
    ent.copy_file dest
    ent.copy_metadata dest if preserve
  end
  module_function :copy_file

  module StreamUtils_
 
    private
   
    def fu_windows?
      /mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
    end
 
    def fu_copy_stream0(src, dest, blksize)   #:nodoc:
      # FIXME: readpartial?
      while s = src.read(blksize)
        dest.write s
      end
    end

    def fu_blksize(st)
      s = st.blksize
      return nil unless s
      return nil if s == 0
      s
    end

    def fu_default_blksize
      1024
    end

  end

  include StreamUtils_
  extend StreamUtils_

  class Entry_   #:nodoc: internal use only
    include StreamUtils_

    def initialize(a, b = nil, deref = false)
      @prefix = @rel = @path = nil
      if b
        @prefix = a
        @rel = b
      else
        @path = a
      end
      @deref = deref
      @stat = nil
      @lstat = nil
    end
   
    def copy_file(dest)
      st = stat()
      File.open(path(),  'rb') {|r|
        File.open(dest, 'wb', st.mode) {|w|
          fu_copy_stream0 r, w, (fu_blksize(st) || fu_default_blksize())
        }
      }
    end

    def copy_metadata(path)
      st = lstat()
      File.utime st.atime, st.mtime, path
      begin
        File.chown st.uid, st.gid, path
      rescue Errno::EPERM
        # clear setuid/setgid
        File.chmod st.mode & 01777, path
      else
        File.chmod st.mode, path
      end
    end
 
    def stat
      return @stat if @stat
      if lstat() && lstat().symlink?
        @stat = File.stat(path())
      else
        @stat = lstat()
      end
      @stat
    end
   
    def lstat
      if dereference?
        @lstat ||= File.stat(path())
      else
        @lstat ||= File.lstat(path())
      end
    end

    def dereference?
      @deref
    end
   
    def path
      if @path
        @path.to_str
      else
        join(@prefix, @rel)
      end
    end

   
  end

end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 26, 2009, 08:15:36 am
That's not FileUtils. That's the shortened version I use in CP. -_-
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on July 26, 2009, 08:18:16 am
*cough*


Dir.mkdir "<name>"
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 26, 2009, 08:49:44 am
I'm not sure if that works in RGSS, that's why I didn't mention it. >.<

EDIT: In case it doesn't work, here:

Spoiler: ShowHide
# 
# = fileutils.rb
#
# Copyright (c) 2000-2005 Minero Aoki <aamine@loveruby.net>
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
#
# == module FileUtils
#
# Namespace for several file utility methods for copying, moving, removing, etc.
#
# === Module Functions
#
#   cd(dir, options)
#   cd(dir, options) {|dir| .... }
#   pwd()
#   mkdir(dir, options)
#   mkdir(list, options)
#   mkdir_p(dir, options)
#   mkdir_p(list, options)
#   rmdir(dir, options)
#   rmdir(list, options)
#   ln(old, new, options)
#   ln(list, destdir, options)
#   ln_s(old, new, options)
#   ln_s(list, destdir, options)
#   ln_sf(src, dest, options)
#   cp(src, dest, options)
#   cp(list, dir, options)
#   cp_r(src, dest, options)
#   cp_r(list, dir, options)
#   mv(src, dest, options)
#   mv(list, dir, options)
#   rm(list, options)
#   rm_r(list, options)
#   rm_rf(list, options)
#   install(src, dest, mode = <src's>, options)
#   chmod(mode, list, options)
#   chmod_R(mode, list, options)
#   chown(user, group, list, options)
#   chown_R(user, group, list, options)
#   touch(list, options)
#
# The <tt>options</tt> parameter is a hash of options, taken from the list
# <tt>:force</tt>, <tt>:noop</tt>, <tt>:preserve</tt>, and <tt>:verbose</tt>.
# <tt>:noop</tt> means that no changes are made.  The other two are obvious.
# Each method documents the options that it honours.
#
# All methods that have the concept of a "source" file or directory can take
# either one file or a list of files in that argument.  See the method
# documentation for examples.
#
# There are some `low level' methods, which do not accept any option:
#
#   copy_entry(src, dest, preserve = false, dereference = false)
#   copy_file(src, dest, preserve = false, dereference = true)
#   copy_stream(srcstream, deststream)
#   remove_entry(path, force = false)
#   remove_entry_secure(path, force = false)
#   remove_file(path, force = false)
#   compare_file(path_a, path_b)
#   compare_stream(stream_a, stream_b)
#   uptodate?(file, cmp_list)
#
# == module FileUtils::Verbose
#
# This module has all methods of FileUtils module, but it outputs messages
# before acting.  This equates to passing the <tt>:verbose</tt> flag to methods
# in FileUtils.
#
# == module FileUtils::NoWrite
#
# This module has all methods of FileUtils module, but never changes
# files/directories.  This equates to passing the <tt>:noop</tt> flag to methods
# in FileUtils.
#
# == module FileUtils::DryRun
#
# This module has all methods of FileUtils module, but never changes
# files/directories.  This equates to passing the <tt>:noop</tt> and
# <tt>:verbose</tt> flags to methods in FileUtils.
#

module FileUtils

  def self.private_module_function(name)   #:nodoc:
    module_function name
    private_class_method name
  end

  # This hash table holds command options.
  OPT_TABLE = {}   #:nodoc: internal use only

  #
  # Options: (none)
  #
  # Returns the name of the current directory.
  #
  def pwd
    Dir.pwd
  end
  module_function :pwd

  alias getwd pwd
  module_function :getwd

  #
  # Options: verbose
  #
  # Changes the current directory to the directory +dir+.
  #
  # If this method is called with block, resumes to the old
  # working directory after the block execution finished.
  #
  #   FileUtils.cd('/', :verbose => true)   # chdir and report it
  #
  def cd(dir, options = {}, &block) # :yield: dir
    fu_check_options options, :verbose
    fu_output_message "cd #{dir}" if options[:verbose]
    Dir.chdir(dir, &block)
    fu_output_message 'cd -' if options[:verbose] and block
  end
  module_function :cd

  alias chdir cd
  module_function :chdir

  OPT_TABLE['cd']    =
  OPT_TABLE['chdir'] = %w( verbose )

  #
  # Options: (none)
  #
  # Returns true if +newer+ is newer than all +old_list+.
  # Non-existent files are older than any file.
  #
  #   FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
  #       system 'make hello.o'
  #
  def uptodate?(new, old_list, options = nil)
    raise ArgumentError, 'uptodate? does not accept any option' if options

    return false unless File.exist?(new)
    new_time = File.mtime(new)
    old_list.each do |old|
      if File.exist?(old)
        return false unless new_time > File.mtime(old)
      end
    end
    true
  end
  module_function :uptodate?

  #
  # Options: mode noop verbose
  #
  # Creates one or more directories.
  #
  #   FileUtils.mkdir 'test'
  #   FileUtils.mkdir %w( tmp data )
  #   FileUtils.mkdir 'notexist', :noop => true  # Does not really create.
  #   FileUtils.mkdir 'tmp', :mode => 0700
  #
  def mkdir(list, options = {})
    fu_check_options options, :mode, :noop, :verbose
    list = fu_list(list)
    fu_output_message "mkdir #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
    return if options[:noop]

    list.each do |dir|
      fu_mkdir dir, options[:mode]
    end
  end
  module_function :mkdir

  OPT_TABLE['mkdir'] = %w( noop verbose mode )

  #
  # Options: mode noop verbose
  #
  # Creates a directory and all its parent directories.
  # For example,
  #
  #   FileUtils.mkdir_p '/usr/local/lib/ruby'
  #
  # causes to make following directories, if it does not exist.
  #     * /usr
  #     * /usr/local
  #     * /usr/local/lib
  #     * /usr/local/lib/ruby
  #
  # You can pass several directories at a time in a list.
  #
  def mkdir_p(list, options = {})
    fu_check_options options, :mode, :noop, :verbose
    list = fu_list(list)
    fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
    return *list if options[:noop]

    list.map {|path| path.sub(%r</\z>, '') }.each do |path|
      # optimize for the most common case
      begin
        fu_mkdir path, options[:mode]
        next
      rescue SystemCallError
        next if File.directory?(path)
      end

      stack = []
      until path == stack.last   # dirname("/")=="/", dirname("C:/")=="C:/"
        stack.push path
        path = File.dirname(path)
      end
      stack.reverse_each do |path|
        begin
          fu_mkdir path, options[:mode]
        rescue SystemCallError => err
          raise unless File.directory?(path)
        end
      end
    end

    return *list
  end
  module_function :mkdir_p

  alias mkpath    mkdir_p
  alias makedirs  mkdir_p
  module_function :mkpath
  module_function :makedirs

  OPT_TABLE['mkdir_p']  =
  OPT_TABLE['mkpath']   =
  OPT_TABLE['makedirs'] = %w( noop verbose )

  def fu_mkdir(path, mode)   #:nodoc:
    path = path.sub(%r</\z>, '')
    if mode
      Dir.mkdir path, mode
      File.chmod mode, path
    else
      Dir.mkdir path
    end
  end
  private_module_function :fu_mkdir

  #
  # Options: noop, verbose
  #
  # Removes one or more directories.
  #
  #   FileUtils.rmdir 'somedir'
  #   FileUtils.rmdir %w(somedir anydir otherdir)
  #   # Does not really remove directory; outputs message.
  #   FileUtils.rmdir 'somedir', :verbose => true, :noop => true
  #
  def rmdir(list, options = {})
    fu_check_options options, :noop, :verbose
    list = fu_list(list)
    fu_output_message "rmdir #{list.join ' '}" if options[:verbose]
    return if options[:noop]
    list.each do |dir|
      Dir.rmdir dir.sub(%r</\z>, '')
    end
  end
  module_function :rmdir

  OPT_TABLE['rmdir'] = %w( noop verbose )

  #
  # Options: force noop verbose
  #
  # <b><tt>ln(old, new, options = {})</tt></b>
  #
  # Creates a hard link +new+ which points to +old+.
  # If +new+ already exists and it is a directory, creates a link +new/old+.
  # If +new+ already exists and it is not a directory, raises Errno::EEXIST.
  # But if :force option is set, overwrite +new+.
  #
  #   FileUtils.ln 'gcc', 'cc', :verbose => true
  #   FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
  #
  # <b><tt>ln(list, destdir, options = {})</tt></b>
  #
  # Creates several hard links in a directory, with each one pointing to the
  # item in +list+.  If +destdir+ is not a directory, raises Errno::ENOTDIR.
  #
  #   include FileUtils
  #   cd '/sbin'
  #   FileUtils.ln %w(cp mv mkdir), '/bin'   # Now /sbin/cp and /bin/cp are linked.
  #
  def ln(src, dest, options = {})
    fu_check_options options, :force, :noop, :verbose
    fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    fu_each_src_dest0(src, dest) do |s,d|
      remove_file d, true if options[:force]
      File.link s, d
    end
  end
  module_function :ln

  alias link ln
  module_function :link

  OPT_TABLE['ln']   =
  OPT_TABLE['link'] = %w( noop verbose force )

  #
  # Options: force noop verbose
  #
  # <b><tt>ln_s(old, new, options = {})</tt></b>
  #
  # Creates a symbolic link +new+ which points to +old+.  If +new+ already
  # exists and it is a directory, creates a symbolic link +new/old+.  If +new+
  # already exists and it is not a directory, raises Errno::EEXIST.  But if
  # :force option is set, overwrite +new+.
  #
  #   FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
  #   FileUtils.ln_s 'verylongsourcefilename.c', 'c', :force => true
  #
  # <b><tt>ln_s(list, destdir, options = {})</tt></b>
  #
  # Creates several symbolic links in a directory, with each one pointing to the
  # item in +list+.  If +destdir+ is not a directory, raises Errno::ENOTDIR.
  #
  # If +destdir+ is not a directory, raises Errno::ENOTDIR.
  #
  #   FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
  #
  def ln_s(src, dest, options = {})
    fu_check_options options, :force, :noop, :verbose
    fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    fu_each_src_dest0(src, dest) do |s,d|
      remove_file d, true if options[:force]
      File.symlink s, d
    end
  end
  module_function :ln_s

  alias symlink ln_s
  module_function :symlink

  OPT_TABLE['ln_s']    =
  OPT_TABLE['symlink'] = %w( noop verbose force )

  #
  # Options: noop verbose
  #
  # Same as
  #   #ln_s(src, dest, :force)
  #
  def ln_sf(src, dest, options = {})
    fu_check_options options, :noop, :verbose
    options = options.dup
    options[:force] = true
    ln_s src, dest, options
  end
  module_function :ln_sf

  OPT_TABLE['ln_sf'] = %w( noop verbose )

  #
  # Options: preserve noop verbose
  #
  # Copies a file content +src+ to +dest+.  If +dest+ is a directory,
  # copies +src+ to +dest/src+.
  #
  # If +src+ is a list of files, then +dest+ must be a directory.
  #
  #   FileUtils.cp 'eval.c', 'eval.c.org'
  #   FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
  #   FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
  #   FileUtils.cp 'symlink', 'dest'   # copy content, "dest" is not a symlink
  #
  def cp(src, dest, options = {})
    fu_check_options options, :preserve, :noop, :verbose
    fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    fu_each_src_dest(src, dest) do |s, d|
      copy_file s, d, options[:preserve]
    end
  end
  module_function :cp

  alias copy cp
  module_function :copy

  OPT_TABLE['cp']   =
  OPT_TABLE['copy'] = %w( noop verbose preserve )

  #
  # Options: preserve noop verbose dereference_root
  #
  # Copies +src+ to +dest+. If +src+ is a directory, this method copies
  # all its contents recursively. If +dest+ is a directory, copies
  # +src+ to +dest/src+.
  #
  # +src+ can be a list of files.
  #
  #   # Installing ruby library "mylib" under the site_ruby
  #   FileUtils.rm_r site_ruby + '/mylib', :force
  #   FileUtils.cp_r 'lib/', site_ruby + '/mylib'
  #
  #   # Examples of copying several files to target directory.
  #   FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
  #   FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
  #
  #   # If you want to copy all contents of a directory instead of the
  #   # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
  #   # use following code.
  #   FileUtils.cp_r 'src/.', 'dest'     # cp_r('src', 'dest') makes src/dest,
  #                                      # but this doesn't.
  #
  def cp_r(src, dest, options = {})
    fu_check_options options, :preserve, :noop, :verbose, :dereference_root
    fu_output_message "cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    options[:dereference_root] = true unless options.key?(:dereference_root)
    fu_each_src_dest(src, dest) do |s, d|
      copy_entry s, d, options[:preserve], options[:dereference_root]
    end
  end
  module_function :cp_r

  OPT_TABLE['cp_r'] = %w( noop verbose preserve dereference_root )

  #
  # Copies a file system entry +src+ to +dest+.
  # If +src+ is a directory, this method copies its contents recursively.
  # This method preserves file types, c.f. symlink, directory...
  # (FIFO, device files and etc. are not supported yet)
  #
  # Both of +src+ and +dest+ must be a path name.
  # +src+ must exist, +dest+ must not exist.
  #
  # If +preserve+ is true, this method preserves owner, group, permissions
  # and modified time.
  #
  # If +dereference_root+ is true, this method dereference tree root.
  #
  def copy_entry(src, dest, preserve = false, dereference_root = false)
    Entry_.new(src, nil, dereference_root).traverse do |ent|
      destent = Entry_.new(dest, ent.rel, false)
      ent.copy destent.path
      ent.copy_metadata destent.path if preserve
    end
  end
  module_function :copy_entry

  #
  # Copies file contents of +src+ to +dest+.
  # Both of +src+ and +dest+ must be a path name.
  #
  def copy_file(src, dest, preserve = false, dereference = true)
    ent = Entry_.new(src, nil, dereference)
    ent.copy_file dest
    ent.copy_metadata dest if preserve
  end
  module_function :copy_file

  #
  # Copies stream +src+ to +dest+.
  # +src+ must respond to #read(n) and
  # +dest+ must respond to #write(str).
  #
  def copy_stream(src, dest)
    fu_copy_stream0 src, dest, fu_stream_blksize(src, dest)
  end
  module_function :copy_stream

  #
  # Options: force noop verbose
  #
  # Moves file(s) +src+ to +dest+.  If +file+ and +dest+ exist on the different
  # disk partition, the file is copied instead.
  #
  #   FileUtils.mv 'badname.rb', 'goodname.rb'
  #   FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true  # no error
  #
  #   FileUtils.mv %w(junk.txt dust.txt), '/home/aamine/.trash/'
  #   FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
  #
  def mv(src, dest, options = {})
    fu_check_options options, :force, :noop, :verbose
    fu_output_message "mv#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    fu_each_src_dest(src, dest) do |s, d|
      destent = Entry_.new(d, nil, true)
      begin
        if destent.exist?
          if destent.directory?
            raise Errno::EEXIST, dest
          else
            destent.remove_file if rename_cannot_overwrite_file?
          end
        end
        begin
          File.rename s, d
        rescue Errno::EXDEV
          copy_entry s, d, true
        end
      rescue SystemCallError
        raise unless options[:force]
      end
    end
  end
  module_function :mv

  alias move mv
  module_function :move

  OPT_TABLE['mv']   =
  OPT_TABLE['move'] = %w( noop verbose force )

  def rename_cannot_overwrite_file?   #:nodoc:
    /djgpp|cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
  end
  private_module_function :rename_cannot_overwrite_file?

  #
  # Options: force noop verbose
  #
  # Remove file(s) specified in +list+.  This method cannot remove directories.
  # All StandardErrors are ignored when the :force option is set.
  #
  #   FileUtils.rm %w( junk.txt dust.txt )
  #   FileUtils.rm Dir.glob('*.so')
  #   FileUtils.rm 'NotExistFile', :force => true   # never raises exception
  #
  def rm(list, options = {})
    fu_check_options options, :force, :noop, :verbose
    list = fu_list(list)
    fu_output_message "rm#{options[:force] ? ' -f' : ''} #{list.join ' '}" if options[:verbose]
    return if options[:noop]

    list.each do |path|
      remove_file path, options[:force]
    end
  end
  module_function :rm

  alias remove rm
  module_function :remove

  OPT_TABLE['rm']     =
  OPT_TABLE['remove'] = %w( noop verbose force )

  #
  # Options: noop verbose
  #
  # Equivalent to
  #
  #   #rm(list, :force => true)
  #
  def rm_f(list, options = {})
    fu_check_options options, :noop, :verbose
    options = options.dup
    options[:force] = true
    rm list, options
  end
  module_function :rm_f

  alias safe_unlink rm_f
  module_function :safe_unlink

  OPT_TABLE['rm_f']        =
  OPT_TABLE['safe_unlink'] = %w( noop verbose )

  #
  # Options: force noop verbose secure
  #
  # remove files +list+[0] +list+[1]... If +list+[n] is a directory,
  # removes its all contents recursively. This method ignores
  # StandardError when :force option is set.
  #
  #   FileUtils.rm_r Dir.glob('/tmp/*')
  #   FileUtils.rm_r '/', :force => true          #  :-)
  #
  # WARNING: This method causes local vulnerability
  # if one of parent directories or removing directory tree are world
  # writable (including /tmp, whose permission is 1777), and the current
  # process has strong privilege such as Unix super user (root), and the
  # system has symbolic link.  For secure removing, read the documentation
  # of #remove_entry_secure carefully, and set :secure option to true.
  # Default is :secure=>false.
  #
  # NOTE: This method calls #remove_entry_secure if :secure option is set.
  # See also #remove_entry_secure.
  #
  def rm_r(list, options = {})
    fu_check_options options, :force, :noop, :verbose, :secure
    # options[:secure] = true unless options.key?(:secure)
    list = fu_list(list)
    fu_output_message "rm -r#{options[:force] ? 'f' : ''} #{list.join ' '}" if options[:verbose]
    return if options[:noop]
    list.each do |path|
      if options[:secure]
        remove_entry_secure path, options[:force]
      else
        remove_entry path, options[:force]
      end
    end
  end
  module_function :rm_r

  OPT_TABLE['rm_r'] = %w( noop verbose force secure )

  #
  # Options: noop verbose secure
  #
  # Equivalent to
  #
  #   #rm_r(list, :force => true)
  #
  # WARNING: This method causes local vulnerability.
  # Read the documentation of #rm_r first.
  #
  def rm_rf(list, options = {})
    fu_check_options options, :noop, :verbose, :secure
    options = options.dup
    options[:force] = true
    rm_r list, options
  end
  module_function :rm_rf

  alias rmtree rm_rf
  module_function :rmtree

  OPT_TABLE['rm_rf']  =
  OPT_TABLE['rmtree'] = %w( noop verbose secure )

  #
  # This method removes a file system entry +path+.  +path+ shall be a
  # regular file, a directory, or something.  If +path+ is a directory,
  # remove it recursively.  This method is required to avoid TOCTTOU
  # (time-of-check-to-time-of-use) local security vulnerability of #rm_r.
  # #rm_r causes security hole when:
  #
  #   * Parent directory is world writable (including /tmp).
  #   * Removing directory tree includes world writable directory.
  #   * The system has symbolic link.
  #
  # To avoid this security hole, this method applies special preprocess.
  # If +path+ is a directory, this method chown(2) and chmod(2) all
  # removing directories.  This requires the current process is the
  # owner of the removing whole directory tree, or is the super user (root).
  #
  # WARNING: You must ensure that *ALL* parent directories are not
  # world writable.  Otherwise this method does not work.
  # Only exception is temporary directory like /tmp and /var/tmp,
  # whose permission is 1777.
  #
  # WARNING: Only the owner of the removing directory tree, or Unix super
  # user (root) should invoke this method.  Otherwise this method does not
  # work.
  #
  # For details of this security vulnerability, see Perl's case:
  #
  #   http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
  #   http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
  #
  # For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
  #
  def remove_entry_secure(path, force = false)
    unless fu_have_symlink?
      remove_entry path, force
      return
    end
    fullpath = File.expand_path(path)
    st = File.lstat(fullpath)
    unless st.directory?
      File.unlink fullpath
      return
    end
    # is a directory.
    parent_st = File.stat(File.dirname(fullpath))
    unless fu_world_writable?(parent_st)
      remove_entry path, force
      return
    end
    unless parent_st.sticky?
      raise ArgumentError, "parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{'%o' % parent_st.mode})"
    end
    # freeze tree root
    euid = Process.euid
    File.open(fullpath + '/.') {|f|
      unless fu_stat_identical_entry?(st, f.stat)
        # symlink (TOC-to-TOU attack?)
        File.unlink fullpath
        return
      end
      f.chown euid, -1
      f.chmod 0700
    }
    # ---- tree root is frozen ----
    root = Entry_.new(path)
    root.preorder_traverse do |ent|
      if ent.directory?
        ent.chown euid, -1
        ent.chmod 0700
      end
    end
    root.postorder_traverse do |ent|
      begin
        ent.remove
      rescue
        raise unless force
      end
    end
  rescue
    raise unless force
  end
  module_function :remove_entry_secure

  def fu_world_writable?(st)
    (st.mode & 0002) != 0
  end

  def fu_have_symlink?   #:nodoc
    File.symlink nil, nil
  rescue NotImplementedError
    return false
  rescue
    return true
  end
  private_module_function :fu_have_symlink?

  def fu_stat_identical_entry?(a, b)   #:nodoc:
    a.dev == b.dev and a.ino == b.ino
  end
  private_module_function :fu_stat_identical_entry?

  #
  # This method removes a file system entry +path+.
  # +path+ might be a regular file, a directory, or something.
  # If +path+ is a directory, remove it recursively.
  #
  # See also #remove_entry_secure.
  #
  def remove_entry(path, force = false)
    Entry_.new(path).postorder_traverse do |ent|
      begin
        ent.remove
      rescue
        raise unless force
      end
    end
  rescue
    raise unless force
  end
  module_function :remove_entry

  #
  # Removes a file +path+.
  # This method ignores StandardError if +force+ is true.
  #
  def remove_file(path, force = false)
    Entry_.new(path).remove_file
  rescue
    raise unless force
  end
  module_function :remove_file

  #
  # Removes a directory +dir+ and its contents recursively.
  # This method ignores StandardError if +force+ is true.
  #
  def remove_dir(path, force = false)
    remove_entry path, force   # FIXME?? check if it is a directory
  end
  module_function :remove_dir

  #
  # Returns true if the contents of a file A and a file B are identical.
  #
  #   FileUtils.compare_file('somefile', 'somefile')  #=> true
  #   FileUtils.compare_file('/bin/cp', '/bin/mv')    #=> maybe false
  #
  def compare_file(a, b)
    return false unless File.size(a) == File.size(b)
    File.open(a, 'rb') {|fa|
      File.open(b, 'rb') {|fb|
        return compare_stream(fa, fb)
      }
    }
  end
  module_function :compare_file

  alias identical? compare_file
  alias cmp compare_file
  module_function :identical?
  module_function :cmp

  #
  # Returns true if the contents of a stream +a+ and +b+ are identical.
  #
  def compare_stream(a, b)
    bsize = fu_stream_blksize(a, b)
    sa = sb = nil
    while sa == sb
      sa = a.read(bsize)
      sb = b.read(bsize)
      unless sa and sb
        if sa.nil? and sb.nil?
          return true
        end
      end
    end
    false
  end
  module_function :compare_stream

  #
  # Options: mode noop verbose
  #
  # If +src+ is not same as +dest+, copies it and changes the permission
  # mode to +mode+.  If +dest+ is a directory, destination is +dest+/+src+.
  #
  #   FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
  #   FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
  #
  def install(src, dest, options = {})
    fu_check_options options, :mode, :preserve, :noop, :verbose
    fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
    return if options[:noop]
    fu_each_src_dest(src, dest) do |s, d|
      unless File.exist?(d) and compare_file(s, d)
        remove_file d, true
        st = File.stat(s) if options[:preserve]
        copy_file s, d
        File.utime st.atime, st.mtime, d if options[:preserve]
        File.chmod options[:mode], d if options[:mode]
      end
    end
  end
  module_function :install

  OPT_TABLE['install'] = %w( noop verbose preserve mode )

  #
  # Options: noop verbose
  #
  # Changes permission bits on the named files (in +list+) to the bit pattern
  # represented by +mode+.
  #
  #   FileUtils.chmod 0755, 'somecommand'
  #   FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
  #   FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
  #
  def chmod(mode, list, options = {})
    fu_check_options options, :noop, :verbose
    list = fu_list(list)
    fu_output_message sprintf('chmod %o %s', mode, list.join(' ')) if options[:verbose]
    return if options[:noop]
    list.each do |path|
      Entry_.new(path).chmod mode
    end
  end
  module_function :chmod

  OPT_TABLE['chmod'] = %w( noop verbose )

  #
  # Options: noop verbose force
  #
  # Changes permission bits on the named files (in +list+)
  # to the bit pattern represented by +mode+.
  #
  #   FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
  #
  def chmod_R(mode, list, options = {})
    fu_check_options options, :noop, :verbose, :force
    list = fu_list(list)
    fu_output_message sprintf('chmod -R%s %o %s',
                              (options[:force] ? 'f' : ''),
                              mode, list.join(' ')) if options[:verbose]
    return if options[:noop]
    list.each do |root|
      Entry_.new(root).traverse do |ent|
        begin
          ent.chmod mode
        rescue
          raise unless options[:force]
        end
      end
    end
  end
  module_function :chmod_R

  OPT_TABLE['chmod_R'] = %w( noop verbose )

  #
  # Options: noop verbose
  #
  # Changes owner and group on the named files (in +list+)
  # to the user +user+ and the group +group+.  +user+ and +group+
  # may be an ID (Integer/String) or a name (String).
  # If +user+ or +group+ is nil, this method does not change
  # the attribute.
  #
  #   FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
  #   FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
  #
  def chown(user, group, list, options = {})
    fu_check_options options, :noop, :verbose
    list = fu_list(list)
    fu_output_message sprintf('chown %s%s',
                              [user,group].compact.join(':') + ' ',
                              list.join(' ')) if options[:verbose]
    return if options[:noop]
    uid = fu_get_uid(user)
    gid = fu_get_gid(group)
    list.each do |path|
      Entry_.new(path).chown uid, gid
    end
  end
  module_function :chown

  OPT_TABLE['chown'] = %w( noop verbose )

  #
  # Options: noop verbose force
  #
  # Changes owner and group on the named files (in +list+)
  # to the user +user+ and the group +group+ recursively.
  # +user+ and +group+ may be an ID (Integer/String) or
  # a name (String).  If +user+ or +group+ is nil, this
  # method does not change the attribute.
  #
  #   FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
  #   FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :verbose => true
  #
  def chown_R(user, group, list, options = {})
    fu_check_options options, :noop, :verbose, :force
    list = fu_list(list)
    fu_output_message sprintf('chown -R%s %s%s',
                              (options[:force] ? 'f' : ''),
                              [user,group].compact.join(':') + ' ',
                              list.join(' ')) if options[:verbose]
    return if options[:noop]
    uid = fu_get_uid(user)
    gid = fu_get_gid(group)
    return unless uid or gid
    list.each do |root|
      Entry_.new(root).traverse do |ent|
        begin
          ent.chown uid, gid
        rescue
          raise unless options[:force]
        end
      end
    end
  end
  module_function :chown_R

  OPT_TABLE['chown_R'] = %w( noop verbose )

  begin
    require 'etc'

    def fu_get_uid(user)   #:nodoc:
      return nil unless user
      user = user.to_s
      if /\A\d+\z/ =~ user
      then user.to_i
      else Etc.getpwnam(user).uid
      end
    end
    private_module_function :fu_get_uid

    def fu_get_gid(group)   #:nodoc:
      return nil unless group
      if /\A\d+\z/ =~ group
      then group.to_i
      else Etc.getgrnam(group).gid
      end
    end
    private_module_function :fu_get_gid

  rescue LoadError
    # need Win32 support???

    def fu_get_uid(user)   #:nodoc:
      user    # FIXME
    end
    private_module_function :fu_get_uid

    def fu_get_gid(group)   #:nodoc:
      group   # FIXME
    end
    private_module_function :fu_get_gid
  end

  #
  # Options: noop verbose
  #
  # Updates modification time (mtime) and access time (atime) of file(s) in
  # +list+.  Files are created if they don't exist.
  #
  #   FileUtils.touch 'timestamp'
  #   FileUtils.touch Dir.glob('*.c');  system 'make'
  #
  def touch(list, options = {})
    fu_check_options options, :noop, :verbose
    list = fu_list(list)
    fu_output_message "touch #{list.join ' '}" if options[:verbose]
    return if options[:noop]
    t = Time.now
    list.each do |path|
      begin
        File.utime(t, t, path)
      rescue Errno::ENOENT
        File.open(path, 'a') {
          ;
        }
      end
    end
  end
  module_function :touch

  OPT_TABLE['touch'] = %w( noop verbose )

  private

  module StreamUtils_
    private

    def fu_windows?
      /mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
    end

    def fu_copy_stream0(src, dest, blksize)   #:nodoc:
      # FIXME: readpartial?
      while s = src.read(blksize)
        dest.write s
      end
    end

    def fu_stream_blksize(*streams)
      streams.each do |s|
        next unless s.respond_to?(:stat)
        size = fu_blksize(s.stat)
        return size if size
      end
      fu_default_blksize()
    end

    def fu_blksize(st)
      s = st.blksize
      return nil unless s
      return nil if s == 0
      s
    end

    def fu_default_blksize
      1024
    end
  end

  include StreamUtils_
  extend StreamUtils_

  class Entry_   #:nodoc: internal use only
    include StreamUtils_

    def initialize(a, b = nil, deref = false)
      @prefix = @rel = @path = nil
      if b
        @prefix = a
        @rel = b
      else
        @path = a
      end
      @deref = deref
      @stat = nil
      @lstat = nil
    end

    def inspect
      "\#<#{self.class} #{path()}>"
    end

    def path
      if @path
        @path.to_str
      else
        join(@prefix, @rel)
      end
    end

    def prefix
      @prefix || @path
    end

    def rel
      @rel
    end

    def dereference?
      @deref
    end

    def exist?
      lstat! ? true : false
    end

    def file?
      s = lstat!
      s and s.file?
    end

    def directory?
      s = lstat!
      s and s.directory?
    end

    def symlink?
      s = lstat!
      s and s.symlink?
    end

    def chardev?
      s = lstat!
      s and s.chardev?
    end

    def blockdev?
      s = lstat!
      s and s.blockdev?
    end

    def socket?
      s = lstat!
      s and s.socket?
    end

    def pipe?
      s = lstat!
      s and s.pipe?
    end

    S_IF_DOOR = 0xD000

    def door?
      s = lstat!
      s and (s.mode & 0xF000 == S_IF_DOOR)
    end

    def entries
      Dir.entries(path())\
          .reject {|n| n == '.' or n == '..' }\
          .map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
    end

    def stat
      return @stat if @stat
      if lstat() and lstat().symlink?
        @stat = File.stat(path())
      else
        @stat = lstat()
      end
      @stat
    end

    def stat!
      return @stat if @stat
      if lstat! and lstat!.symlink?
        @stat = File.stat(path())
      else
        @stat = lstat!
      end
      @stat
    rescue SystemCallError
      nil
    end

    def lstat
      if dereference?
        @lstat ||= File.stat(path())
      else
        @lstat ||= File.lstat(path())
      end
    end

    def lstat!
      lstat()
    rescue SystemCallError
      nil
    end

    def chmod(mode)
      if symlink?
        File.lchmod mode, path() if have_lchmod?
      else
        File.chmod mode, path()
      end
    end

    def chown(uid, gid)
      if symlink?
        File.lchown uid, gid, path() if have_lchown?
      else
        File.chown uid, gid, path()
      end
    end

    def copy(dest)
      case
      when file?
        copy_file dest
      when directory?
        begin
          Dir.mkdir dest
        rescue
          raise unless File.directory?(dest)
        end
      when symlink?
        File.symlink File.readlink(path()), dest
      when chardev?
        raise "cannot handle device file" unless File.respond_to?(:mknod)
        mknod dest, ?c, 0666, lstat().rdev
      when blockdev?
        raise "cannot handle device file" unless File.respond_to?(:mknod)
        mknod dest, ?b, 0666, lstat().rdev
      when socket?
        raise "cannot handle socket" unless File.respond_to?(:mknod)
        mknod dest, nil, lstat().mode, 0
      when pipe?
        raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
        mkfifo dest, 0666
      when door?
        raise "cannot handle door: #{path()}"
      else
        raise "unknown file type: #{path()}"
      end
    end

    def copy_file(dest)
      st = stat()
      File.open(path(),  'rb') {|r|
        File.open(dest, 'wb', st.mode) {|w|
          fu_copy_stream0 r, w, (fu_blksize(st) || fu_default_blksize())
        }
      }
    end

    def copy_metadata(path)
      st = lstat()
      File.utime st.atime, st.mtime, path
      begin
        File.chown st.uid, st.gid, path
      rescue Errno::EPERM
        # clear setuid/setgid
        File.chmod st.mode & 01777, path
      else
        File.chmod st.mode, path
      end
    end

    def remove
      if directory?
        remove_dir1
      else
        remove_file
      end
    end

    def remove_dir1
      platform_support {
        Dir.rmdir path().sub(%r</\z>, '')
      }
    end

    def remove_file
      platform_support {
        File.unlink path
      }
    end

    def platform_support
      return yield unless fu_windows?
      first_time_p = true
      begin
        yield
      rescue Errno::ENOENT
        raise
      rescue => err
        if first_time_p
          first_time_p = false
          begin
            File.chmod 0700, path()   # Windows does not have symlink
            retry
          rescue SystemCallError
          end
        end
        raise err
      end
    end

    def preorder_traverse
      stack = [self]
      while ent = stack.pop
        yield ent
        stack.concat ent.entries.reverse if ent.directory?
      end
    end

    alias traverse preorder_traverse

    def postorder_traverse
      if directory?
        entries().each do |ent|
          ent.postorder_traverse do |e|
            yield e
          end
        end
      end
      yield self
    end

    private

    $fileutils_rb_have_lchmod = nil

    def have_lchmod?
      # This is not MT-safe, but it does not matter.
      if $fileutils_rb_have_lchmod == nil
        $fileutils_rb_have_lchmod = check_have_lchmod?
      end
      $fileutils_rb_have_lchmod
    end

    def check_have_lchmod?
      return false unless File.respond_to?(:lchmod)
      File.lchmod 0
      return true
    rescue NotImplementedError
      return false
    end

    $fileutils_rb_have_lchown = nil

    def have_lchown?
      # This is not MT-safe, but it does not matter.
      if $fileutils_rb_have_lchown == nil
        $fileutils_rb_have_lchown = check_have_lchown?
      end
      $fileutils_rb_have_lchown
    end

    def check_have_lchown?
      return false unless File.respond_to?(:lchown)
      File.lchown nil, nil
      return true
    rescue NotImplementedError
      return false
    end

    def join(dir, base)
      return dir.to_str if not base or base == '.'
      return base.to_str if not dir or dir == '.'
      File.join(dir, base)
    end
  end   # class Entry_

  def fu_list(arg)   #:nodoc:
    [arg].flatten.map {|path| path.to_str }
  end
  private_module_function :fu_list

  def fu_each_src_dest(src, dest)   #:nodoc:
    fu_each_src_dest0(src, dest) do |s, d|
      raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
      yield s, d
    end
  end
  private_module_function :fu_each_src_dest

  def fu_each_src_dest0(src, dest)   #:nodoc:
    if src.is_a?(Array)
      src.each do |s|
        s = s.to_str
        yield s, File.join(dest, File.basename(s))
      end
    else
      src = src.to_str
      if File.directory?(dest)
        yield src, File.join(dest, File.basename(src))
      else
        yield src, dest.to_str
      end
    end
  end
  private_module_function :fu_each_src_dest0

  def fu_same?(a, b)   #:nodoc:
    if fu_have_st_ino?
      st1 = File.stat(a)
      st2 = File.stat(b)
      st1.dev == st2.dev and st1.ino == st2.ino
    else
      File.expand_path(a) == File.expand_path(b)
    end
  rescue Errno::ENOENT
    return false
  end
  private_module_function :fu_same?

  def fu_have_st_ino?   #:nodoc:
    not fu_windows?
  end
  private_module_function :fu_have_st_ino?

  def fu_check_options(options, *optdecl)   #:nodoc:
    h = options.dup
    optdecl.each do |name|
      h.delete name
    end
    raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
  end
  private_module_function :fu_check_options

  def fu_update_option(args, new)   #:nodoc:
    if args.last.is_a?(Hash)
      args[-1] = args.last.dup.update(new)
    else
      args.push new
    end
    args
  end
  private_module_function :fu_update_option

  @fileutils_output = $stderr
  @fileutils_label  = ''

  def fu_output_message(msg)   #:nodoc:
    @fileutils_output ||= $stderr
    @fileutils_label  ||= ''
    @fileutils_output.puts @fileutils_label + msg
  end
  private_module_function :fu_output_message

  METHODS = singleton_methods() - ['private_module_function']

  #
  # Returns an Array of method names which have any options.
  #
  #   p FileUtils.commands  #=> ["chmod", "cp", "cp_r", "install", ...]
  #
  def FileUtils.commands
    OPT_TABLE.keys
  end

  #
  # Returns an Array of option names.
  #
  #   p FileUtils.options  #=> ["noop", "force", "verbose", "preserve", "mode"]
  #
  def FileUtils.options
    OPT_TABLE.values.flatten.uniq
  end

  #
  # Returns true if the method +mid+ have an option +opt+.
  #
  #   p FileUtils.have_option?(:cp, :noop)     #=> true
  #   p FileUtils.have_option?(:rm, :force)    #=> true
  #   p FileUtils.have_option?(:rm, :perserve) #=> false
  #
  def FileUtils.have_option?(mid, opt)
    li = OPT_TABLE[mid.to_s] or raise ArgumentError, "no such method: #{mid}"
    li.include?(opt.to_s)
  end

  #
  # Returns an Array of option names of the method +mid+.
  #
  #   p FileUtils.options(:rm)  #=> ["noop", "verbose", "force"]
  #
  def FileUtils.options_of(mid)
    OPT_TABLE[mid.to_s]
  end

  #
  # Returns an Array of method names which have the option +opt+.
  #
  #   p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
  #
  def FileUtils.collect_method(opt)
    OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt.to_s) }
  end

  #
  # This module has all methods of FileUtils module, but it outputs messages
  # before acting.  This equates to passing the <tt>:verbose</tt> flag to
  # methods in FileUtils.
  #
  module Verbose
    include FileUtils
    @fileutils_output  = $stderr
    @fileutils_label   = ''
    ::FileUtils.collect_method('verbose').each do |name|
      module_eval(<<-EOS, __FILE__, __LINE__ + 1)
        def #{name}(*args)
          super(*fu_update_option(args, :verbose => true))
        end
        private :#{name}
      EOS
    end
    extend self
    class << self
      ::FileUtils::METHODS.each do |m|
        public m
      end
    end
  end

  #
  # This module has all methods of FileUtils module, but never changes
  # files/directories.  This equates to passing the <tt>:noop</tt> flag
  # to methods in FileUtils.
  #
  module NoWrite
    include FileUtils
    @fileutils_output  = $stderr
    @fileutils_label   = ''
    ::FileUtils.collect_method('noop').each do |name|
      module_eval(<<-EOS, __FILE__, __LINE__ + 1)
        def #{name}(*args)
          super(*fu_update_option(args, :noop => true))
        end
        private :#{name}
      EOS
    end
    extend self
    class << self
      ::FileUtils::METHODS.each do |m|
        public m
      end
    end
  end

  #
  # This module has all methods of FileUtils module, but never changes
  # files/directories, with printing message before acting.
  # This equates to passing the <tt>:noop</tt> and <tt>:verbose</tt> flag
  # to methods in FileUtils.
  #
  module DryRun
    include FileUtils
    @fileutils_output  = $stderr
    @fileutils_label   = ''
    ::FileUtils.collect_method('noop').each do |name|
      module_eval(<<-EOS, __FILE__, __LINE__ + 1)
        def #{name}(*args)
          super(*fu_update_option(args, :noop => true, :verbose => true))
        end
        private :#{name}
      EOS
    end
    extend self
    class << self
      ::FileUtils::METHODS.each do |m|
        public m
      end
    end
  end

end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 26, 2009, 07:19:05 pm
I got the directory making thing work. But how do I check to see if it exists? Because I get an error if the directory exists already.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on July 26, 2009, 08:06:33 pm
Quote from: game_guy on July 26, 2009, 07:19:05 pm
I got the directory making thing work. But how do I check to see if it exists? Because I get an error if the directory exists already.



FileTest.directory? "<dir_name>"


Geez, Ruby standard library anyone? 0_o
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 27, 2009, 03:45:57 am
Ruby != RGSS. You can't expect everything that works in Ruby to work in RGSS. Now stop being a smartass. I'd rather not receive help from somebody at all than having to bear somebody acting like a mega ass for every single piece of information.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on July 27, 2009, 07:42:46 pm
Sorry 0_0 I meant that this is all readily available if you just Google the Dir class.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 30, 2009, 02:56:34 pm
@longfellow: in case you havent noticed I'm not the best googler

@blizz: could you help me with your gradient bars? I'm making a Blizz abs HUD with the following
HP
SP
Exp
Stamina(to run, sneak, and jump)

All I really need to know is how to make a gradient bar thanks for help if anyone can help
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on July 30, 2009, 03:25:45 pm
*points to e-book that has an example*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on July 30, 2009, 09:44:35 pm
*points to my battle system thread in general RPG maker section for fully commented bar code"
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 12, 2009, 06:48:43 pm
Another question. Okay so I have this thing setup in an array
blah = [1 => 2, 2 => 3, 4 => 5]


I wanna know how this can be used and how can I access the two different numbers.
Like so 1 => 2

I wanna be able to access the first number at one time and the 2nd number at a different time.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 12, 2009, 06:52:59 pm
Look at hashes in the help doc... XD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 12, 2009, 06:56:49 pm
I did and I dont really understand how to call the different numbers
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 12, 2009, 06:59:32 pm
1 => 2
1 is the Key
2 is the Value

I think...

So just look at the help manual for stuff on Keys and Values
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 12, 2009, 07:08:08 pm
Well here's what I have,
$blah = {1 => 2}

so how am I supposed to call that? I dont really get it. I tried this

print $blah[0]
print $blah{0}
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on August 12, 2009, 07:48:26 pm
just a question are you sure you need to use a hash y not an array then would just be $blah = [1,2] $blah[0] would = 1 but im sure you know this and probably need to use hashes

edit fixed lol was on my psp
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 12, 2009, 07:51:41 pm
Arrays use [], not ()
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 12, 2009, 08:02:53 pm
I cant tell much but it has to do with items.

[1 => 2]

1 is the item id
and
well its like this

I'm making a cooking script, so its going to be like this
when recipe_id then return [item_id => amount, item_id => amount]

that way it requires multiple items and multiple amounts of the item
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on August 12, 2009, 08:49:32 pm
y not a combination so say
case recipe_id
when 1 then item_id[1 => 2]


i dont know anything about hashes so what do you think
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 12, 2009, 08:56:47 pm
whats that suppose to do? thats exactly how I have it setup but I dont know how to access the 1 andc 2 at different times
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on August 12, 2009, 09:03:03 pm
ok it heres what i found

index(val) 
Returns the key corresponding to val. If there is no corresponding element, returns nil.

If there are multiple corresponding keys, arbitrarily returns one of them.


self[key] 
Returns the value mapped to key. If the corresponding key is not registered, returns the default value (or nil if not specified).


that's the only thing i can find not sure how you implement them so looks like index(val) would get 1 from 2

and self[key] would get 2 from 1 in {1=> 2}

edit does that help at all because i don't think there is a way to get the key without using the val or the val without the key there might be but i don't see it in the help file
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 12, 2009, 10:17:40 pm
$hash = {1 => 2, 3 => 4}

$hash[KEY]
$hash[1] would return 2
$hash[3] would return 4

And look at the other methods for more info and stuff.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 13, 2009, 12:03:36 am
okay so we wouldnt be able to get the actual 1 then would we by using 0? Dangit oh well.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on August 13, 2009, 03:52:09 am
You can get the key from the value as well.

hash.index(value) # returns the mapped key


Remember my config methods?

case id
when 5 then return 'Test 1'
when 7 then return 19
end


It's almost the same like a hash, but only one-way.

$hash = {}
$hash[5] = 'Test 1'
$hash[7] = 19


Why are hashes useful? The key and the value can be anything while in an array the "key" (actually index) can only be a number. Also, in hashes you can use any number as key while in an array the indices start from 0. Hashes are usually used to connect two values (i.e. like in Blizz-ABS actor action observation subsystem the actor is the key and the damage is the value).
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 13, 2009, 10:48:18 am
yea but is it possible at all to get the first key? Because I'm making a cooking script, So the first key in the hash might be 5 or 33. I plan on releasing it so I dont know if someone else is going to put 33 as the first ingredient.

So is it possible to access the first one without inputing the key?

EDIT:
can we at least put an array inside an array? so its like this
when recipe_id then return [[item_id, amount], [item_id, amount]]
and if so how would I access the first array andc the numbers in it?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 13, 2009, 11:28:50 am
$array = [[5, 1], [2, 2]]

$array[0] = [5, 1]
$array[1] = [2, 2,]

$array[0][0] = 5
$array[0][1] = 1


Unless my mind is still sleeping, and I messed up :P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on August 13, 2009, 12:13:03 pm
no you not sleeping you got it right Aqua
@game_guy
also note that you can add as many levels to your array as you want

$bla = [[[5, 6], [4, 3]], [[2, 7], [8, 1]]]


$bla[0][0][0] => 5
$bla[0][1][1] => 3
$bla[1][0][1] => 7
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 22, 2009, 12:23:44 pm
Need help sorting an array. I tried the example from the help file but it didnt work...I want it for my skillshop so like how would I sort it alphabetical, reverse alphabetical, or by id?

Here's my window I just need to sort the @data array.
Spoiler: ShowHide
class Window_SkillBuy < Window_Selectable
  def initialize(shop_goods)
    super(0, 128, 368, 352)
    @skill_shop_goods = shop_goods
    self.active = false
    refresh
    self.index = 0
  end
  def skill
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@skill_shop_goods.size
      skill = $data_skills[@skill_shop_goods[i]]
      if skill != nil
        @data.push(skill)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  def draw_item(index)
    skill = @data[index]
    price = skill.price
    enabled = (price <= $game_party.gold)
    if enabled
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
  def update_help
    @help_window.set_text(skill == nil ? "" : skill.description)
  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on August 22, 2009, 12:26:59 pm
STCMS, just find where I sort the items by ID, name and quantity. After you sort, you can simply use .reverse or reverse! to reverse the order of all elements.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 22, 2009, 12:28:56 pm
I tried that and I get a wrong number of arguments (0 of 1) thing...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on August 22, 2009, 12:52:38 pm
Make sure you know what you are sorting.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 22, 2009, 12:57:55 pm
Yea skills, it pushes $data_skills in it, and I figured the a.name, and b.name would be great so I tried copying that and I kept getting an error. I'll try again.

EDIT: I'm retarded, I kept calling my skill shop wrong, nothing was wrong at all XD

EDIT 2: Okay I know how to actually create a new weapon using this
new_weapon = RPG::Weapon.new
new_weapon.id = x
ect.


Now is there anyway to dump that weapon into the Weapons.rxdata without erasing all the other weapons?

EDIT 3:
Okay I got it. It dumps the weapon into $data_weapons[id] then it dumps $data_weapons into Weapons.rxdata

One more question, say I create another .rxdata file and store it in the Data folder. When the game's encrypted will the game be able to still read it?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on August 23, 2009, 12:40:20 am
this thread now has so many answers to basic scripting questions it could be called a tut! lol
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 23, 2009, 12:42:17 am
I declare this the General RGSS/RGSS2 Help Topic *hint hint sticky sticky*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 23, 2009, 12:46:35 am
Make the 1st post look better, and I'll sticky it for you. XD

Not a lot of us know how to RGSS2 though... o.o
Not sure how many could actually help with that XD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 23, 2009, 12:51:58 am
how's that?

oh and I could probably help :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 23, 2009, 12:55:03 am
After fixing some grammar issues...
*stickies*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 23, 2009, 12:57:44 am
Yea I know a bit about rgss2 enough to get me by anyways.

But I still need this question answered.
say I create another .rxdata file and store it in the Data folder. When the game's encrypted will the game be able to still read it?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on August 23, 2009, 12:59:21 am
Why don't you just test it out yourself...? XD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on August 23, 2009, 12:59:54 am
Because I dunno...lazyness der xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on August 23, 2009, 04:47:29 am
Quote from: game_guy on August 22, 2009, 12:57:55 pm
Now is there anyway to dump that weapon into the Weapons.rxdata without erasing all the other weapons?

EDIT: 3
Okay I got it. It dumps the weapon into $data_weapons[id] then it dumps $data_weapons into Weapons.rxdata


Lol, I posted the script snippet in the screenshot thread. Just be sure to have RMXP closed while you are doing this because RMXP will overwrite your file with the file it loaded in the first place if you save it.

Quote from: game_guy on August 22, 2009, 12:57:55 pm
One more question, say I create another .rxdata file and store it in the Data folder. When the game's encrypted will the game be able to still read it?


Yes. You need to use load_data and everything will work fine. load_data is usually loading a file through Marshal serialization, but it can also read such files from the encrypted RGSSAD archive. Blizz-ABS does the same with "MapData.abs" and CP with "MapData.cpx".

I use my own encryption for CP Beta 2. >:3 <3 <3 <3
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: shdwlink1993 on August 24, 2009, 09:03:32 pm
Quote from: Aqua on August 23, 2009, 12:46:35 am
Not a lot of us know how to RGSS2 though... o.o


When you look at it, RGSS and RGSS2 aren't all that different. Granted, a lot of the RTP Scripts are different, but the core language is the same.

Quote from: Blizzard on August 23, 2009, 04:47:29 am
Yes. You need to use load_data and everything will work fine. load_data is usually loading a file through Marshal serialization, but it can also read such files from the encrypted RGSSAD archive. Blizz-ABS does the same with "MapData.abs" and CP with "MapData.cpx".

I use my own encryption for CP Beta 2. >:3 <3 <3 <3


Well, we all know how you think that Marshal is beneath you, Blizz. xD Regardless, I look forward to breaking said encryption. (Look, when you release CP, I'd love to make a Save File Editor for it. ^_^)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on August 24, 2009, 11:09:45 pm
props to the first person to use cheat engine on the final release of CP XD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on August 25, 2009, 05:46:23 am
Quote from: shdwlink1993 on August 24, 2009, 09:03:32 pm
Well, we all know how you think that Marshal is beneath you, Blizz. xD Regardless, I look forward to breaking said encryption. (Look, when you release CP, I'd love to make a Save File Editor for it. ^_^)


Oh no, that's not it. I meant encryption instead of rgssad. This also makes patching the game files so much easier since they aren't all embedded in the rgssad archive and people who upgrade don't need to download 40MB again. :/ The save files will stay DREAM encrypted.

Also, Marshal is a way to serialize data, not an encryption. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on September 01, 2009, 02:54:56 pm
im trying to turn on a self switch via script but i keep getting an error
im using $game_self_switches[$game_map.map_id, event_id, key] = value
key as in 'A' "B" "C" or "D" value as true or false
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Zeriab on September 01, 2009, 04:06:58 pm
load_data decrypts the relevant portion of the RGSSAD archive before deserializing it. I.e. Marshal deserialization.
It's not like Blizz don't know how to decrypt the encrypted archive though XD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 02, 2009, 03:10:56 am
<3

@nathmatt:

$game_self_switches[[$game_map.map_id, event_id, key]] = value
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on September 02, 2009, 01:53:39 pm
that worked just had to make sure i refreshed the map
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 03, 2009, 04:08:27 am
Yeah, you need to use "$game_map.need_refresh = true" as well.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on September 03, 2009, 02:56:45 pm
i used $game_map.refesh

edit well actually i was going to use that but just aliased game_map update and made a script very usefull so i could open and close my cell doors without 2 switches per cell see

Spoiler: ShowHide
#-------------------------------------------------------------------------------
#
# Door Opener
#
#-------------------------------------------------------------------------------

class Scene_Map
 
  alias door_update update
  def update
    door_update
    if $door_cheker == true
    case $game_variables[8]
    when 1 then $game_self_switches[[$game_map.map_id, 21, "A"]] = true
    $game_self_switches[[$game_map.map_id, 1, "A"]] = true
    when 2 then $game_self_switches[[$game_map.map_id, 23, "A"]] = true
    $game_self_switches[[$game_map.map_id, 2, "A"]] = true
    when 3 then $game_self_switches[[$game_map.map_id, 24, "A"]] = true
    $game_self_switches[[$game_map.map_id, 3, "A"]] = true
    when 4 then $game_self_switches[[$game_map.map_id, 25, "A"]] = true
    $game_self_switches[[$game_map.map_id, 4, "A"]] = true
    when 5 then $game_self_switches[[$game_map.map_id, 26, "A"]] = true
    $game_self_switches[[$game_map.map_id, 5, "A"]] = true
    when 6 then $game_self_switches[[$game_map.map_id, 27, "A"]] = true
    $game_self_switches[[$game_map.map_id, 6, "A"]] = true
    when 7 then $game_self_switches[[$game_map.map_id, 28, "A"]] = true
    $game_self_switches[[$game_map.map_id, 7, "A"]] = true
    when 8 then $game_self_switches[[$game_map.map_id, 29, "A"]] = true
    $game_self_switches[[$game_map.map_id, 8, "A"]] = true
    when 9 then $game_self_switches[[$game_map.map_id, 30, "A"]] = true
    $game_self_switches[[$game_map.map_id, 9, "A"]] = true
    when 10 then $game_self_switches[[$game_map.map_id, 31, "A"]] = true
    $game_self_switches[[$game_map.map_id, 10, "A"]] = true
    when 11 then $game_self_switches[[$game_map.map_id, 32, "A"]] = true
    $game_self_switches[[$game_map.map_id, 11, "A"]] = true
    when 12 then $game_self_switches[[$game_map.map_id, 33, "A"]] = true
    $game_self_switches[[$game_map.map_id, 12, "A"]] = true
   end
  $door_cheker = false
  end
  if $door_closer == true
    case $game_variables[8]
    when 1 then $game_self_switches[[$game_map.map_id, 21, "A"]] = false
    $game_self_switches[[$game_map.map_id, 1, "C"]] = true
    when 2 then $game_self_switches[[$game_map.map_id, 23, "A"]] = false
    $game_self_switches[[$game_map.map_id, 2, "C"]] = true
    when 3 then $game_self_switches[[$game_map.map_id, 24, "A"]] = false
    $game_self_switches[[$game_map.map_id, 3, "C"]] = true
    when 4 then $game_self_switches[[$game_map.map_id, 25, "A"]] = false
    $game_self_switches[[$game_map.map_id, 4, "C"]] = true
    when 5 then $game_self_switches[[$game_map.map_id, 26, "A"]] = false
    $game_self_switches[[$game_map.map_id, 5, "C"]] = true
    when 6 then $game_self_switches[[$game_map.map_id, 27, "A"]] = false
    $game_self_switches[[$game_map.map_id, 6, "C"]] = true
    when 7 then $game_self_switches[[$game_map.map_id, 28, "A"]] = false
    $game_self_switches[[$game_map.map_id, 7, "C"]] = true
    when 8 then $game_self_switches[[$game_map.map_id, 29, "A"]] = false
    $game_self_switches[[$game_map.map_id, 8, "C"]] = true
    when 9 then $game_self_switches[[$game_map.map_id, 30, "A"]] = false
    $game_self_switches[[$game_map.map_id, 9, "C"]] = true
    when 10 then $game_self_switches[[$game_map.map_id, 31, "A"]] = false
    $game_self_switches[[$game_map.map_id, 10, "C"]] = true
    when 11 then $game_self_switches[[$game_map.map_id, 32, "A"]] = false
    $game_self_switches[[$game_map.map_id, 11, "C"]] = true
    when 12 then $game_self_switches[[$game_map.map_id, 33, "A"]] = false
    $game_self_switches[[$game_map.map_id, 12, "C"]] = true
    end
  $door_closer = false
   end
  end
end


then had my event run the open door animation when "A" was on then turn b on so the door would stay open then when "C" was on it would show the door close and turn "D" on with would torn off the switches that i had not turned off yet
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 03, 2009, 04:07:19 pm
My thing just queues this call at an appropriate time. It shouldn't cause problems either way.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on September 06, 2009, 03:56:22 pm
I'm attempting to write a custom 'break damage/level/stat barrier' script. I think the caps are set in Game_Battler1, correct? I'm not sure if these are the enemy or actor values... Are actors stored separately?

Though it's mainly an aesthetic thing, I want level values up to 255, HP up to 99999, and stats up to 9999...

I'm not sure whether I need to change the setups in Game_Actor or Game_Battler1... GB1 has an HP value up to 999999, so I'm assuming that's the enemy setup. The GA setup seems to be setup differently though... and I'm not sure how to go about changing this...



Also, as I mentioned in another thread, I want to know how to interface weapons with status effects... or scripts... I want weapons/equipment to change the actor's state permanently, on equip and on unequip...

EDIT: Ok I changed the setups in those  two places but it doesn't seem to work...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 07, 2009, 03:35:10 am
RMXP'S default database settings don't allow to have more than the defaults. But if you change the scripts, you can have more stats ingame. It might be easier to simply go with an already existing script.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 07, 2009, 02:39:44 pm
Okay so I'm making a neat oblivion like saving script. So what I'm doing is make one file hold all save files. That way this file can keep track of how many saves have been done. Now the save slots is an array and I can have a multi array. So its like this.

@save_slots = []

and when I go to save a game it'll dump all the important data into another array then dump that array into another array which will be in the save slots array. Is that possible? or will it cause errors or is it just a plain bad idea.
@vars = [$game_system, $game_actors, ect.]
@temp = ["Save #{$ggloadsave.saves}, @vars]
@save_slots.push(@temp)

That'd be right right?

Then I'd access the variables using this I think
@temp2 = $ggloadsave.saveslots[index]
$game_system = @temp2[1][0]


I think anyways can someone help me out here?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 07, 2009, 03:07:17 pm
High chance of inconsistent data. Don't do it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on September 07, 2009, 06:39:10 pm
would a hash be better for this? that way you could save the data like so

@vars = {}
@vars['Game_System'] = $game_system
@vars['Game_Actors'] = $game_actors
ect.
@save_slots['slot_id'] = @vars
save_data(@save_slots, 'path.rxdata)



and retrieve like

@save_slots = load_data('path.rxdata')
$game_system = @save_slots['slot_id']['Game_System']
$game_actors = @save_slots['slot_id']['Game_Actors']
ect.


that way there is no messing around with indexes, no inconsistent data. right blizz?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 07, 2009, 09:16:26 pm
Quote from: Ryexander on September 07, 2009, 06:39:10 pm
would a hash be better for this? that way you could save the data like so

@vars = {}
@vars['Game_System'] = $game_system
@vars['Game_Actors'] = $game_actors
ect.
@save_slots['slot_id'] = @vars
save_data(@save_slots, 'path.rxdata)



and retrieve like

@save_slots = load_data('path.rxdata')
$game_system = @save_slots['slot_id']['Game_System']
$game_actors = @save_slots['slot_id']['Game_Actors']
ect.


that way there is no messing around with indexes, no inconsistent data. right blizz?


Epic waste of space. Instead of one file for all saves, why not use an index file for the saves? You could make a simple class for it and marshall it into SaveIndex.rxdata.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on September 08, 2009, 12:05:02 am
even better! that way is saves the path to all the save files in the saveindex.rxdata!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 08, 2009, 03:58:58 am
With inconsistent data I meant that you take some data from before 10 seconds and some from now. This won't work because that combination of data never existed. i.e. There was no moment where the party had 5000 Gold and all characters were level 11. There was a moment where they were level 10 and had 5000 Gold and there was a moment where they had level 11 and they had 5500 Gold. You took the party state from before and the current state of the actors and so you got 5000 Gold with everybody on level 11 which actually never existed. Even worse, you SAVED that data. That is inconsistent data.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 11, 2009, 11:58:03 am
I've been trying to keep myself busy seeing I'm sick, I tried doing all sorts of things but its too boring...anyways I was looking at all the scripts I made and then this idea just popped in my head.

I want to make a tileset creator. You import pictures and stuff into the pictures folder, use this command window showing all the options, you click one of your pictures, then you drag it on a layed out tileset sheet. I think its a great idea but I'm missing a few things. Mouse script and a resolution script (for larger tileset)

Okay so I found this resolution script but I dont really understand how to use it..maybe you guys can help me with it.
#==============================================================================
# ■ Resolution
#------------------------------------------------------------------------------
#  created by Selwyn
#  selwyn@rmxp.ch
#
#  released on the 19th of June 2006
#
#  allows to change the game window's resolution to 800 by 600.
#==============================================================================

module Resolution
  #--------------------------------------------------------------------------
  # ● instance variables
  #--------------------------------------------------------------------------
  attr_reader :state
  #--------------------------------------------------------------------------
  # ● initialize
  #--------------------------------------------------------------------------
  def initialize
    title = "\0" * 256
    Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L').call("Game", "Title", "", title, 256, ".\\Game.ini")
    title.delete!("\0")
    @set_resolution  = Win32API.new('Display.dll', 'SetResolution', 'III', 'I')
    @set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
    @set_window_pos  = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @gsm             = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    @gcr             = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
    @kbe             = Win32API.new('user32', 'keybd_event', 'LLLL', '')
    @gaks            = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'I')
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call("RGSS Player", title)
    @default_size = size
    if size[0] < 800 or size[1] < 600
      print("A minimum screen resolution of [800 by 600] is required in order to play #{title}")
      exit
    end
    @state = "default"
    self.default
  end
  #--------------------------------------------------------------------------
  # ● fullscreen
  #--------------------------------------------------------------------------
  def fullscreen
    @default_size = size
    @set_window_long.call(@window, -16, 0x14000000)
    @set_window_pos.call(@window, -1, 0, 0, 802, 602, 64)
    @set_resolution.call(800, 600, 4)
    @state = "fullscreen"
  end
  #--------------------------------------------------------------------------
  # ● default
  #--------------------------------------------------------------------------
  def default
    x = @default_size[0] / 2 - 403
    y = @default_size[1] / 2 - 316
    @set_window_long.call(@window, -16, 0x14CA0000)
    @set_window_pos.call(@window, 0, x, y, 808, 627, 0)
    @set_resolution.call(@default_size[0], @default_size[1], 0)
    @state = "default"
  end
  #--------------------------------------------------------------------------
  # ● trigger?(key)
  #--------------------------------------------------------------------------
  def trigger?(key)
    return @gaks.call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  # ● private
  #--------------------------------------------------------------------------
  private :fullscreen
  private :default
  private :trigger?
  #--------------------------------------------------------------------------
  # ● size
  #--------------------------------------------------------------------------
  def size
    width = @gsm.call(0)
    height = @gsm.call(1)
    return width, height
  end
  #--------------------------------------------------------------------------
  # ● change
  #--------------------------------------------------------------------------
  def change
    if @state == "default"
      self.fullscreen
    else
      self.default
    end
  end
  #--------------------------------------------------------------------------
  # ● update
  #--------------------------------------------------------------------------
  def update
    if trigger?(121) # F10
      self.change
    end
    if Input.trigger?(Input::ALT) or Input.press?(Input::ALT)
      @kbe.call(18, 0, 2, 0)
    end
  end
  #--------------------------------------------------------------------------
  # ● module functions
  #--------------------------------------------------------------------------
  module_function :initialize
  module_function :fullscreen
  module_function :default
  module_function :trigger?
  module_function :size
  module_function :change
  module_function :update
end


And maybe ideas on a mouse script that detects the holding down of the left button, detects input of both right and left clicks and can detect mouse x and y. So help is appreciated
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 11, 2009, 12:39:17 pm
Tons' input module handles mouse buttons. o.o; I'm just too lazy right now to release the mouse controller. It just needs one last component to be coded. Man. ._.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 11, 2009, 01:05:11 pm
But I needed the mouse controller O_O but I guess I can code everything else for now, wait or can i? DUH DUH DUH DUH!!!!!

Anyways what about that resolution script up there?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 11, 2009, 01:27:14 pm
I might finish it then. ;>_>

Higher resolution = more lag, that's all I can say. You need to call Resolution.fullscreen, but first change the parameters in that method. The script is coded quite inconsistently. "Resolution" is conceptually not suited to be a module. -_- "Screen" should be the module and the most important method should be "set_resolution(x = 640, y = 480)" which obviously uses 640x480 as default parameters. -_-
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 11, 2009, 11:28:42 pm
Okay I'm using the bitmap.blt method in a scene. And its not showing any images. Am I supposed to be updating the bitmap?

@tile = Bitmap.new(256, 600)
@tile.blt(0, 0, bitmap, Rect.new(0, 0, 256, 600))
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 12, 2009, 09:15:52 am
Nope. Just make sure "bitmap" is not nil.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 12, 2009, 10:42:33 am
its not nil I even printed it but its not showing anything.

so here's my entire code right now,
Resolution.initialize
class TileCreator
  def main
    #@back = Sprite.new
    @back = RPG::Cache.tileset("Back")
    @grid = Sprite.new
    @grid.bitmap = RPG::Cache.tileset("Grid")
    @commands = ["New", "Insert", "Export", "Exit"]
    @names = []
    dir = Dir.new('Graphics/Pictures/')
    dir.entries.each {|file| next unless file.include?('.png')
    @names.push(file); RPG::Cache.picture(file)}
    @command = Window_Command.new(160, @commands)
    @graphics = Window_Command.new(160, @names)
    @graphics.active = false
    @graphics.visible = false
    @active = false
    @tile = Bitmap.new(256, 600)
    @tile.blt(0, 0, @back, Rect.new(0, 0, 256, 600))
    @command.x = 800-@command.width
    @graphics.x = @command.x-@graphics.width
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    @graphics.dispose
    @back.dispose
    @grid.dispose
    @commands.dispose
    @mouse.dispose if @mouse != nil
  end
  def update
    @graphics.update
    @command.update
    if @command.active
      update_command
      return
    end
    if @graphics.active
      update_graphics
      return
    end
    if @active
      update_active
      return
    end
  end
  def update_command
    if Input.trigger?(Input::B)
      @command.index = 4
      $game_system.se_play($data_system.cancel_se)
      return
    end
    if Input.trigger?(Input::C)
      case @command.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @tile.dispose
        @tile = nil
        @tile = Bitmap.new(256, 600)
      when 1
        $game_system.se_play($data_system.decision_se)
        @graphics.active = true
        @command.active = false
        @graphics.visible = true
      when 2
        @tile.make_png("CustomTile")
        $game_system.se_play($data_system.decision_se)
      when 3
        $scene = nil
      end
      return
    end
  end
  def update_graphics
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @graphics.active = false
      @graphics.visible = false
      @command = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @mouse = Sprite.new
      @mouse.bitmap = RPG::Cache.picture("#{@names[@graphics.index]}")
      @mouse.x = Input.mouse_x? if Input.mouse_x? != nil
      @mouse.y = Input.mouse_y? if Input.mouse_y? != nil
      @active = true
      @graphics.active = false
    end
   
  end
  def update_active
    @mouse.x = Input.mouse_x? if Input.mouse_x? != nil
    @mouse.y = Input.mouse_y? if Input.mouse_y? != nil
    if Input.trigger?(Input::MOUSE_L)
      rect = Rect.new(0, 0, 256, 600)
      @tile.blt(Input.mouse_x?, Input.mouse_y?, @mouse.bitmap, rect)
      @mouse.dispose
      @mouse = nil
      @active = false
      @graphics.active = true
    end
   
  end
 
end


bitmap in the code is actually @mouse.bitmap
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on September 12, 2009, 02:04:36 pm
shouldn't it be' @mouse.Bitmap '?

I'm not positive, I'm still new to sprite calls... but it seems like that might be the problem...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 12, 2009, 02:13:30 pm
Quote from: Satoh on September 12, 2009, 02:04:36 pm
shouldn't it be' @mouse.Bitmap '?

I'm not positive, I'm still new to sprite calls... but it seems like that might be the problem...


No, the @bitmap variable is lowercase.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 12, 2009, 08:59:03 pm
Well I know for sure its placing the bitmap on the screen because I can export it into an actual tile but I cant see where I'm placing it... man this is just stumping me...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on September 12, 2009, 09:10:17 pm
try commenting out the current coordinate assignment method you're using and give it absolute coords directly... if you can see the bitmap then your coordinate method is the issue... if not, then your issue is that the bitmap call isn't working properly (or as you would expect it to work rather)...

Did that make sense?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 12, 2009, 09:22:18 pm
Yea I tried that, I made it go to 0,0 and it still not working. So maybe if I make it a window? Yea I'll try that

EDIT:
Okay if I made it a window would I still be able to add contents to it? like
@window_tile.contents.blt?

Thanks in advance

EDIT 2:
w00tness I got it. I tried my above idea but I added a method that added a blt method so w00t I got it now. Yes a tilesetcreator is coming!!!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on September 13, 2009, 12:43:25 am
Quote from: game_guy on September 12, 2009, 09:22:18 pm
Yea I tried that, I made it go to 0,0 and it still not working. So maybe if I make it a window? Yea I'll try that

EDIT:
Okay if I made it a window would I still be able to add contents to it? like
@window_tile.contents.blt?

Thanks in advance

EDIT 2:
w00tness I got it. I tried my above idea but I added a method that added a blt method so w00t I got it now. Yes a tilesetcreator is coming!!!


Grats on the whole winning @ life thing... but what exactly is the purpose of the tileset creator... (not to go off topic or anything)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 13, 2009, 12:45:50 am
Well now that you say that I'm finding it more useless than I imagined >_>

but anyways you import little pics and tiles and stuff you want in a tileset into the pictures folder. Run the game, and you can places those pictures you imported onto a grid. Theres an option turning Snap To Grid on/off, and then when you're all done, you press Export then type in a name for it and it'll save it into a tileset.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on September 13, 2009, 01:52:39 am
basically a better way than using MSPaint, but without the hassle of waiting for Photoshop to take its Adobe freaking time to load... right?

I've not messed with file exporting before, but it sounds like it could be useful... if I ever find a way for it to be...


The real irony of me making a CMS, is that it will most likely be useless if I release it, as it's tailored to my needs and probably isn't versatile... and I'll probably never make a Star Ocean spinoff... because I simply lack the battle system, plot, and sprites necessary to do so...

However, every little bit that I get working, makes me feel a little more confident in my abilities... so I'm not quitting just yet...

I am still having difficulty deciding the best method for iterating through separate windows that are meant to be a single menu to scroll through...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 13, 2009, 02:56:45 am
yup it even deals with transparency ;)

okay another question, I'm going to add a few more features like saving and loading a tileset from a .rxdata to make it so you can work on it later. Could I just dump the bitmap into a .rxdata and still load it?

How would I go doing it?

EDIT
One question as well, how high can the hue go? Like when your getting a character
RPG::Cache.character(file, hue)

how hue can it go to?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 13, 2009, 04:51:38 pm
Quote from: game_guy on September 13, 2009, 02:56:45 am
yup it even deals with transparency ;)

okay another question, I'm going to add a few more features like saving and loading a tileset from a .rxdata to make it so you can work on it later. Could I just dump the bitmap into a .rxdata and still load it?

How would I go doing it?

EDIT
One question as well, how high can the hue go? Like when your getting a character
RPG::Cache.character(file, hue)

how hue can it go to?


11.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 14, 2009, 05:57:27 am
Technically hue goes from 0 to 359. If you use more than 359, it will just cycle it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 17, 2009, 08:40:36 pm
Okay so how do we draw a rectangle?

One thats just an outline? And then one thats just filled?

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 17, 2009, 08:51:40 pm
Quote from: game_guy on September 17, 2009, 08:40:36 pm
Okay so how do we draw a rectangle?

One thats just an outline? And then one thats just filled?




Wait, you honestly don't know Bitmap#fill_rect?

bitmap.fill_rect(<x>, <y>, <w>, <h>, <color>)


To draw an outline, you just draw lines using fill_rect:

bitmap.fill_rect(<x>, <y>, <w>, 1, <color>)
bitmap.fill_rect(<x> + <w>, <y>, 1, <h>, <color>)
bitmap.fill_rect(<x>, <y> + <h>, <w>, 1, <color>)
bitmap.fill_rect(<x>, <y>, 1, <h>, <color>)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 17, 2009, 08:52:45 pm
thanks LF *lv's up* I know you hate it but you've helped me out alot
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 17, 2009, 08:55:23 pm
Quote from: game_guy on September 17, 2009, 08:52:45 pm
thanks LF *lv's up* I know you hate it but you've helped me out alot


Just for the record, I was trying to offend you above, but I thought that fill_rect was one of the things most scripters learned right off the bat. 0_o

Apparently, I was wrong...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 17, 2009, 08:58:23 pm
Well yea you'd think I'd know but I've never been the one to really mess with bitmaps so thanks again
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 18, 2009, 03:31:06 am
Quote from: Longfellow on September 17, 2009, 08:51:40 pm
To draw an outline, you just draw lines using fill_rect:

bitmap.fill_rect(<x>, <y>, <w>, 1, <color>)
bitmap.fill_rect(<x> + <w>, <y>, 1, <h>, <color>)
bitmap.fill_rect(<x>, <y> + <h>, <w>, 1, <color>)
bitmap.fill_rect(<x>, <y>, 1, <h>, <color>)



Redundancy.

bitmap.fill_rect(x, y, w, h, c)
bitmap.fill_rect(x + b / 2, y + b / 2, w - b, h - b, Color.new(0, 0, 0, 0))
# x: x coordinate
# x: y coordinate
# c: color
# w: width
# h: height
# b: border width, use an even number

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 18, 2009, 09:59:13 am
Wow. I can't believe I didn't think of that. You know, since I've actually written huge scripts using that exact method before. ><
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 20, 2009, 03:31:17 pm
Don't worry about it. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 24, 2009, 06:34:06 pm
Okay for this all I need is an answer to this. Its got nothing to do with rgss help but more of a "Is it worth scripting" question.

My friend relies on me when it comes to scripts...anyways he had this idea for his game called
Skill Equipping

Well what is exactly is each actor has ability points. For example
Aluxes: AP 10/10
Instead of being able to use all of your skills at once he wants to be able to equip skills to his actor. Each skill costs ap so when the ap's gone you cant equip anymore. The actor also gains some ap after every level up. He thought it was a great idea but is it really worth scripting?

I told him I might make it. But I want to know if theres a non sdk system like that already out there? Or if its even a good idea to script something. I thought it was a cool idea but I dont want to make it if its not worth it or if theres an already existing script like it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on September 24, 2009, 07:37:21 pm
Definitely a good idea, a unique system that could add to a game.  I don't know if there's systems already out there, but I think you could make a better one anyways.  :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 24, 2009, 08:07:55 pm
k thanks winkio I'll start working on it now and another question

Just some more bitmap stuff.
okay so I now know how to draw a rectangle but how do I make the inside clrea? Like transparent?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 26, 2009, 12:28:26 pm
Quote from: game_guy on September 24, 2009, 08:07:55 pm
k thanks winkio I'll start working on it now and another question

Just some more bitmap stuff.
okay so I now know how to draw a rectangle but how do I make the inside clrea? Like transparent?


Use the alpha layer of the Color class:

# 24-bit (RGB) Color, doesn't have transparency
c = Color.new(<red value>, <green value>, <blue value>)

# 32-bit (RGBA) Color, transparency layer is called "alpha"
c = Color.new(<red value>, <green value>, <blue value>, <alpha value>)


And simply use that color along with Bitmap#fill_rect.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 28, 2009, 08:05:48 pm
another question....dang whats with all the questions? I'm going to count how many questions I asked in this thread lol

Okay anyways in a message window you can use commands like these
\n
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on September 28, 2009, 08:11:57 pm
ccoa's UMS does stuff like that.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 28, 2009, 08:15:30 pm
well that doesnt help with the first question, I want to put
\ commands in the item name in teh database then later
it does a command
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 28, 2009, 10:10:57 pm
Quote from: game_guy on September 28, 2009, 08:15:30 pm
well that doesnt help with the first question, I want to put
\ commands in the item name in teh database then later
it does a command


Regular expressions.


# Code to print a number specified with \p[<x>] inside the name of an item with ID @item_id
if $data_items[@item_id].name =~ /\\p\[([0-9]*?)\]/i # << Here be the regular expressions
    # Print the number they added in the name
    print "Your number is #{$1}, foo!"
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on September 28, 2009, 10:19:13 pm
will that get rid of the \ command from the skill name?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 28, 2009, 10:29:54 pm
Quote from: game_guy on September 28, 2009, 10:19:13 pm
will that get rid of the \ command from the skill name?




...I forgot that, dangit.


class RPG::Item
  alias real_name name
  alias real_name= name=

  def name
    return real_name.gsub /\\p\[([0-9]*?)\]/i, ''
  end
 
  def name= str
    if real_name =~ /\\p\[([0-9]*?)\]/i
      real_name = "#{str} #{$1}"
    else
      real_name = str
  end
end


Methods FTW!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on September 29, 2009, 01:15:06 am
A question for thee (all of thee):

I am using events to create custom regen/poison/drain/osmosis blah blah blah etc. etc.  So far, all of it works, but there's one problem: no numbers pop up for the damage or healing done.  Of course, they wouldn't, seeing as I am only using events to do this, but I was wondering if there was a way to arbitrarily make the damage pop in battle using the Call Script command in the eventing window.  If so, is there a way I can specify which target it shows up on and also specify the number it displays as a certain variable that I set in the RPG Maker's database (not a variable I set in a script)?

Thank you.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on September 29, 2009, 01:17:50 am
don't know if you want to use this instead or just borrow code from it, but: http://forum.chaos-project.com/index.php?topic=2481.0 (http://forum.chaos-project.com/index.php?topic=2481.0)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on September 29, 2009, 02:07:10 am
I've tried to use that, but it doesn't seem to work.

If I put it below RTAB 1.6 (which I am using) and I go into battle and use the Regen skill, it returns this error:

Script 'Real Time Active Battle' line 2671: NoMethodError occurred.
undefined method 'each' for 686:Fixnum

And when I go into the script editor, it points me to this method:

Spoiler: ShowHide

#--------------------------------------------------------------------------
  # * Remaining HP estimate
  #--------------------------------------------------------------------------
  def rest_hp
    # Substituting reality HP to rest_hp
    rest_hp = @hp
    # All damage which the battler receives is made to reflect on rest_hp
    for pre_damage in @damage
      if pre_damage[1].is_a?(Numeric)
        rest_hp -= pre_damage[1]
      end
    end
    return rest_hp
  end


I'm not sure where 'each' is or what to do about it, really.  So, I tried putting the HoT DoT script above RTAB, and I go into battle and it works, with one strange exception: no matter what I specify in the HoT DoT database, the spell consistently deals about 200 points of damage over time.  I tried changing the positives and negatives, the damage numbers and the type of damage and it always will deal 200 points every turn or so.  I'm thinking that something in RTAB is overriding its functionality partially so that it's getting mixed signals, but I have no idea what to do about it.

Any thoughts?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 29, 2009, 08:11:23 am
Quote from: samsonite789 on September 29, 2009, 02:07:10 am
I've tried to use that, but it doesn't seem to work.

If I put it below RTAB 1.6 (which I am using) and I go into battle and use the Regen skill, it returns this error:

Script 'Real Time Active Battle' line 2671: NoMethodError occurred.
undefined method 'each' for 686:Fixnum

And when I go into the script editor, it points me to this method:

Spoiler: ShowHide

#--------------------------------------------------------------------------
  # * Remaining HP estimate
  #--------------------------------------------------------------------------
  def rest_hp
    # Substituting reality HP to rest_hp
    rest_hp = @hp
    # All damage which the battler receives is made to reflect on rest_hp
    for pre_damage in @damage
      if pre_damage[1].is_a?(Numeric)
        rest_hp -= pre_damage[1]
      end
    end
    return rest_hp
  end


I'm not sure where 'each' is or what to do about it, really.  So, I tried putting the HoT DoT script above RTAB, and I go into battle and it works, with one strange exception: no matter what I specify in the HoT DoT database, the spell consistently deals about 200 points of damage over time.  I tried changing the positives and negatives, the damage numbers and the type of damage and it always will deal 200 points every turn or so.  I'm thinking that something in RTAB is overriding its functionality partially so that it's getting mixed signals, but I have no idea what to do about it.

Any thoughts?


Your problem is that HoT DoT is specifying @damage as a number, while RTAB requires an array. I'm not sure how to fix it off the top of my head, but if you'll look at some of the RTAB compatibility code in Blizzard's Tons of Add-Ons I'm sure you'll find what you need.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on September 29, 2009, 01:11:34 pm
QuoteYour problem is that HoT DoT is specifying @damage as a number, while RTAB requires an array. I'm not sure how to fix it off the top of my head, but if you'll look at some of the RTAB compatibility code in Blizzard's Tons of Add-Ons I'm sure you'll find what you need.


What RTAB compatibility code are you referring to?  I looked in Tons of Addons and didn't find anything that seemed like that specifically.  Come to think of it, another one of my big gripes is that Tons of Addons is not working well with RTAB.  The only way I can get it to avoid that stupid "wrong arguments (2 for 1)" error is to put the scripts above RTAB.  The problem, though, is that then RTAB overwrites all of the goodies that Tons of Addons provides. 

Any thoughtses?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 29, 2009, 02:11:32 pm
Well, Tons does have compatibility code for RTAB included so it should go below.
The compatibility code mostly includes things like method definitions with the battler parameter that is usually used in RTAB. That's what he meant. This usually gets rid of the argument error.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on September 29, 2009, 07:05:37 pm
Quote from: Blizzard on September 29, 2009, 02:11:32 pm
Well, Tons does have compatibility code for RTAB included so it should go below.
The compatibility code mostly includes things like method definitions with the battler parameter that is usually used in RTAB. That's what he meant. This usually gets rid of the argument error.


Exactly what I meant.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on September 30, 2009, 05:02:07 am
I know. It wasn't just that clear from your post. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on October 01, 2009, 03:19:02 am
But when I put it below RTAB, it still gives me the arguments error.  Is there a specific block of code I should be activating having to do with RTAB compatibility?

P.S.  Thanks for the help so far.  Much appreciated.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 01, 2009, 03:57:06 am
No, there isn't. Which line is giving the error?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on October 02, 2009, 01:57:25 pm
When I place Tons of Addons below RTAB, soon after I go into battle it gives me the following error message:

Script 'Real Time Active Battle' line 1683: ArgumentError occurred
wrong number of arguments (1 for 0)

The script it refers to is the following method in the massive Scene_Battle class of the RTAB script:
Spoiler: ShowHide

def update_phase4_step2(battler)
    # If it is not forced action
    unless battler.current_action.forcing
      # When restriction [ the enemy is attacked ] [ friend attacks ] usually usually
      if battler.restriction == 2 or battler.restriction == 3
        # Setting attack to action
        battler.current_action.kind = 0
        battler.current_action.basic = 0
      end
    end
    # It diverges with classification of action
    case battler.current_action.kind
    when 0  # Basis
      if fin?
        battler.phase = 6
        return
      end
      make_basic_action_result(battler)
    when 1  # Skill
      if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2
        battler.phase = 6
        return
      end
      make_skill_action_result(battler)  <-----  **THIS LINE**
    when 2  # Item
      if fin? and $data_items[battler.current_action.item_id].scope == 1..2
        battler.phase = 6
        return
      end
      make_item_action_result(battler)
    end
    if battler.phase == 2
      # It moves to step 3
      battler.phase = 3
    end
  end


I'm befuzzled...

On a side note, I have another simpler question about RGSS if'n ya don't mind.  How would one call a check to see if an actor has learned a certain skill?  Something like $game_data.skill_learned? or something like that...I'm trying to fix up one of my scripts to add a check to see if an actor has learned the skill and I'm not sure how to call it.

Thanks!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 03, 2009, 07:14:41 am
"$game_actors[ID].skill_learn?" is the call.

I'll take a look at that RTAB problem later.

EDIT: Fixed. Get the newest version of Tons. It was G_G's HP Consuming Skills. I forgot to make the script compatible with RTAB. Now it should be fine.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on October 04, 2009, 11:32:21 am
wait was the error in the script my fault? If so sorry :(

Anyways question, is it possible to have rmxp load a script from a text file and run it? Like say I have this text file just for example and its got a config in it like so
module GameGuy
  Stuff = "Blah"
end


Now would it be possible to make one of the script slots load that text file and run it? This goes back to what I was asking blizz whether how to load rxdata through c# and reading and writing so seeing my friend is lazy....he like wants a config for everything so anyways instead of actually using c# to read and write I use it instead to generate this code that rmxp loads into a script that makes the rxdata.

So I just wanted to know if thats possible or not. So hopefully it is and I know its probably a stupid idea to be doing it like this but I want to experiment and stuff.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on October 04, 2009, 01:16:21 pm
Thank you so much for all your help!  I'll try it out as soon as I can get back home.  One question, though...is there any specific place I should download the latest version of Tons from?  I assume it's from the stickied post in these forums, but I just thought I'd ask.

Thanks again!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on October 04, 2009, 01:20:18 pm
Quote from: game_guy on October 04, 2009, 11:32:21 am
wait was the error in the script my fault? If so sorry :(

Anyways question, is it possible to have rmxp load a script from a text file and run it? Like say I have this text file just for example and its got a config in it like so
module GameGuy
  Stuff = "Blah"
end


Now would it be possible to make one of the script slots load that text file and run it? This goes back to what I was asking blizz whether how to load rxdata through c# and reading and writing so seeing my friend is lazy....he like wants a config for everything so anyways instead of actually using c# to read and write I use it instead to generate this code that rmxp loads into a script that makes the rxdata.

So I just wanted to know if thats possible or not. So hopefully it is and I know its probably a stupid idea to be doing it like this but I want to experiment and stuff.


Yep, you'd use

require File.expand_path 'script_name.rb'
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on October 05, 2009, 01:07:32 pm
I tried the new Tons of Addons, and it's got several more error messages it's giving me...

When I put it below RTAB and everything else now, as soon as I attack something in battle, it gives me the following:

Script 'Tons of Addons 2' Line 3814: ArgumentError occurred
wrong number of arguments (0 for 1)

I checked out that section of the code - it's the skill separation section.  So I tried blocking out that chunk of code with =begin and =end to see if that was causing the problem.  When I did that and attacked something, it gave me the following:

Script 'Real Time Active Battle' line 2772: ArgumentError occurred
wrong number of arguments(2 for 1)

That is this sections of RTAB:
Spoiler: ShowHide

#--------------------------------------------------------------------------
  # * Effective application of normality attack
  #     attacker : Attack person (battler)
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clearing the critical flag
    self.critical[attacker] = false
    state_p[attacker] = []
    state_m[attacker] = []
    # First on-target hit decision
    hit_result = (rand(100) < attacker.hit)
    # In case of on-target hit
    hit_result = true
    if hit_result == true
      # Calculating the basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage[attacker] = atk * (20 + attacker.str) / 20
      # Attribute correction
      self.damage[attacker] *= elements_correct(attacker.element_set)
      self.damage[attacker] /= 100
      # When the mark of the damage is correct,
      if self.damage[attacker] > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage[attacker] *= 2
          self.critical[attacker] = true
        end
        # Defense correction
        if self.guarding?
          self.damage[attacker] /= 2
        end
      end
      # Dispersion
      if self.damage[attacker].abs > 0
        amp = [self.damage[attacker].abs * 15 / 100, 1].max
        self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
      end
      # Second on-target hit decision
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage[attacker] < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # In case of on-target hit
    if hit_result == true
      # State shocking cancellation
      remove_states_shock
      # From HP damage subtraction
      # State change
      @state_changed = false
      states_plus(attacker, attacker.plus_state_set) <---- THIS LINE
      states_minus(attacker, attacker.minus_state_set)
    # In case of miss
    else
      # Setting "Miss" to the damage
      self.damage[attacker] = "Miss"
      # Clearing the critical flag
      self.critical[attacker] = false
    end
    # Method end
    return true
  end



Any thoughts?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 05, 2009, 02:13:43 pm
I'll look into it when I'm back from dinner.

EDIT: Fixed. BTW, you can post bugs about Tons in the Tons thread. :P

EDIT: Wait. Something else is wrong.

EDIT: Ok, done
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on October 06, 2009, 02:39:14 am
Rock on.  Thanks, man.  I will post in the Tons sticky in the future.  In fact, I just did because I found another bug.  Computers suck.

And thank you for all your help.  You are very helpful.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on October 06, 2009, 07:29:35 pm
Question:

How do I detect player/event collision through a script call?

I have a little dilemma. I'm making an enemy detection system using a view range script. Right now, I've got it set up so that the first event page for an enemy is a parallel process in which they are constantly scanning to see if the player is within range via a script call - when they are, a self switch goes on and they chase the player down, etc., etc. However, there's a little problem: the few times I've tested it where the enemies DON'T see me, I can walk right up behind them and into them but nothing happens. Obviously, whether or not the enemy sees the player or not, I want a battle to start when the player touches the enemy. However, I can't do this simply by making an 'Event Touch' condition for battle processing because I need a parallel process to check for when the enemy DOES see the player.

So, all that rambling preamble is to this question: Is there a way to make a script call that will detect whether or not a player is in collision with an event? If I could use a conditional branch on the first parallel process page, that would bypass the problem completely.

Thanks!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 07, 2009, 03:55:37 am
$game_player.passable?(X, Y, DIRECTION)


Direction is 2, 4, 6 or 8 for down, left, right or up respectively. Also, this checks for general passability, not just for collision detection with events.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: C.C. rOyAl on October 11, 2009, 05:15:01 pm
k i got a question. in RGSS do you have to put things in order?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on October 11, 2009, 05:37:07 pm
lolwut?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: C.C. rOyAl on October 11, 2009, 05:39:51 pm
ok to be more specific

Say i  want to make a CMS, would i have to define the class Scene_Menu before i defined The Status screen?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 11, 2009, 05:43:07 pm
That's ok. Mostly classes can be defined in any order, but when several script redefine the same classes, this is where your scripts need to be in the correct order.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: C.C. rOyAl on October 11, 2009, 05:55:51 pm
what do you mean?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 11, 2009, 05:58:37 pm
This:

Quote from: C.C. rOyAl on October 11, 2009, 05:39:51 pm
would i have to define the class Scene_Menu before i defined The Status screen?


No you wouldn't. This order IS NOT important.
BUT! Your CMS script that redefines Scene_Menu MUST be placed under the original Scene_Menu script. This order IS important.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: C.C. rOyAl on October 11, 2009, 07:49:53 pm
oh lol duh  8)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on October 13, 2009, 05:20:02 pm
if i wanted to inclose each Character in a separate window in my menu status how would i do that
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on October 13, 2009, 05:22:44 pm
Quote from: nathmatt on October 13, 2009, 05:20:02 pm
if i wanted to inclose each Character in a separate window in my menu status how would i do that


Just replace the single instance of Window_MenuStatus with four instances of your own window.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on October 17, 2009, 02:13:55 pm
so I have an dynamically generated array that looks something like this

powers = [[index_to_another_array, effective_power], [index_to_another_array, effective_power], [index_to_another_array, effective_power],[index_to_another_array, effective_power]]

what I need to do is find the array in the powers array that has the highest value for effective_power and return it so that I end up with
[index_to_another_array, highest_effective_power]

how can I do this?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 17, 2009, 04:50:33 pm
max = nil
powers.each {|current| max = current if max == nil || current[1] > max[1]}


It's just a standard max/min loop. You could also use something like this:

max = powers[0]
(1...powers.size).each {|i| max = powers[i] if powers[i][1] > max[1]}


I prefer the latter due to only 1 condition being checked.

There's also a way to use a block with .max, but I don't really recommend it as it's confusing.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on October 17, 2009, 06:07:33 pm
*face palm* thanks Blizz
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on October 21, 2009, 08:47:19 pm
K here's a method from scene_battle
def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Determine if treasure appears
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # Treasure is limited to a maximum of 6 items
    treasures = treasures[0..5]
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 100
  end


Anyways what I'm wondering is how do I change how the experience is handled when aliasing, see when I alias it and call the old method its gonna change how the exp is given but I wanna change that to something else but still be able to alias and not over write the method.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 22, 2009, 06:11:35 am
Check out how I did it in the Different Difficulties System in Tons.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on October 24, 2009, 10:14:29 am
Quote from: Ryexander on October 17, 2009, 02:13:55 pm
so I have an dynamically generated array that looks something like this

powers = [[index_to_another_array, effective_power], [index_to_another_array, effective_power], [index_to_another_array, effective_power],[index_to_another_array, effective_power]]

what I need to do is find the array in the powers array that has the highest value for effective_power and return it so that I end up with
[index_to_another_array, highest_effective_power]

how can I do this?


This looks suspiciously like you're solving a polynomial, or something similar (that code would function to find the degree of any polynomial once you process it into an array of constants and variable names and the highest of their powers). May I ask what you're trying to do?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 24, 2009, 10:34:51 am
http://forum.chaos-project.com/index.php?topic=4809.0
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on October 24, 2009, 12:21:02 pm
How do we get all of the map files put into an array?
For example, MAP001, MAP002, MAP003 are in the data folder, how would I get each of those map files in an array?

Because I dont know how many maps people are going. I'm working on a really cool script but yea I need all the map files in an array first.

Or if possible, instead of the file names, I want to use the actual map names used in the editor.
Like MAP001 is named Grasslands ect.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on October 24, 2009, 12:46:09 pm
hash = load_data('Data/MapInfos.rxdata')


The keys in the hash are the map IDs of all maps in the game (hash.keys returns an array of all keys). The values in the hash are RPG::MapInfo instances which have the attribute @name. So you can simply use hash[ID].name to get the map name.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on October 25, 2009, 07:38:41 am
is there a way to get the exp curve and use it so that other things lvl the same way
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on November 01, 2009, 08:43:53 pm
how do you alias a self.method in a module?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 02, 2009, 04:12:09 am
module XYZ
 
  class << XYZ
    alias abc_2 abc
  end
 
  def self.abc
    # code
    abc_2
    # code
  end
 
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on November 02, 2009, 09:40:57 am
thanks Blizz
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on November 02, 2009, 09:49:22 am
Quoteis there a way to get the exp curve and use it so that other things lvl the same way

http://forum.chaos-project.com/index.php?topic=4851.0
should be correct
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Xelias on November 07, 2009, 07:59:02 am
In class Game Battler, what is the syntax for
"If the attacker's Weapon Id is equal to..."
I tried "If attacker.weapon_id = ..." and it doesn't work:
I wanted to modify the algorithm of ONE weapon and all my weapons are changed !
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 07, 2009, 08:05:09 am
use this
    if attacker.is_a?(Game_Actor)
      if attacker.weapon_id == 1
        # Code here
      end
    end

Got to make sure the attacker is a Game_Actor because when enemies use that same method when attacking and enemies dont have weapons.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Xelias on November 07, 2009, 08:23:46 am
It works, but...
after the attack with the special weapon, I get an error
"Nil can't be coerced into fixnum"
at "self.hp -= self.damage"
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 07, 2009, 08:24:47 am
post the code and I'll see whats wrong
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Xelias on November 07, 2009, 08:28:00 am
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Alternative Attack Algorithms  by Xelias
# Version: 7.39b
# Type: Battle Add-ON
# Date v1.00b:   7.11.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#  How to use this script :
# This allows your weapons to follow different damage algorithms.
# ATMA_WEAPON_ID = X ; The weapon with an ID equal to X will inflict
# more damage depending on the user's HP. If HP are full, attack power is doubled.
# If HP are at minimum, attack power is normal. If HP are equal to half, attack power
# is equal to 1,5 of the normal Attack power, and so on...
#
#
#
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

  ATMA_WEAPON_ID = 10

class Game_Battler

def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
          if attacker.is_a?(Game_Actor)
      if attacker.weapon_id == ATMA_WEAPON_ID
        # Code here
     atk = [attacker.atk - self.pdef / 2,0].max
     atk2 = atk * (20 + attacker.str) / 20
    self.damage = atk2 + (atk2*(attacker.hp/attacker.maxhp))
  else 
    atk = [attacker.atk - self.pdef / 2, 0].max
     self.damage = atk * (20 + attacker.str) / 20
   end
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.agi / self.pdef
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
        if rand(100) < ((self.pdef*10)/25)
          self.damage = 0
        end
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
     # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Miss"
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
end
end


Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on November 07, 2009, 09:10:07 am
all if statements need to be closed with an end statement after the

if attacker.is_a?(Game_Actor)
  if attacker.weapon_id == ATMA_WEAPON_ID

put

  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Xelias on November 07, 2009, 09:21:11 am
I don't understand where I should place them. I tried after the formula ; I tried after BOTH formulas ; I tried at the end of the script and all of those tries  create strange bugs. Can you help me by putting the "End"s directly in my script please?  
EDIT : ...Whatever. I modified something in the defending part, and it worked. Thanks.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on November 07, 2009, 12:05:47 pm
The nil is when you have no equipped weapon.
So you gotta make a check for if you're fighting with just bare hands.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Xelias on November 07, 2009, 12:10:44 pm
Thanks, but you're a little to late. It works now.  :haha:
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on November 09, 2009, 04:02:16 pm
ok i cant figure out what im doing wrong so im initializing @name = [] then im updating
for i in 0 ..BlizzABS::Config::MAX_PARTY - 1 then im using this code
it keeps saying @name is nill i can post the whole script if you need it

#----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name(id)
    actors = $game_party.actors[id]
    # set current variable
    @name[id] = actors.name
    # set font color
    self.bitmap.font.color = Color.new(0, 255, 0)
    # draw actor's name
    self.bitmap.draw_text_full(@name_x, @name_y+@all_y, 104, 20, @name[id])
  end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 09, 2009, 04:48:17 pm
So, even if there is only 1 person in the party, you're still iterating through "0 ..BlizzABS::Config::MAX_PARTY - 1", are you?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on November 09, 2009, 05:46:57 pm
actually im going through 1..BlizzABS::Config::MAX_PARTY - 1 because the first 1 is done differently fixed the party member problem heres the full script its an edited version or ur BlizzABS hud


Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Game_System
 
  attr_accessor :bar_style
  attr_reader   :bar_opacity
  #----------------------------------------------------------------------------
  # initialize
  #  Added bar style variables.
  #----------------------------------------------------------------------------
  alias init_blizzart_later initialize
  def initialize
    init_blizzart_later
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#
#   Configure this part manually if you have no "Options" controller for the
#   styles and the opacity. (style: 0~6, opacity: 0~255)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @bar_style = 2
    self.bar_opacity = 255
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  end
  #----------------------------------------------------------------------------
  # bar_opacity=
  #  alpha - opacity
  #  Encapsulation and range limitation of opacity.
  #----------------------------------------------------------------------------
  def bar_opacity=(alpha)
    @bar_opacity = [[alpha, 0].max, 255].min
  end
 
end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor
 
  #----------------------------------------------------------------------------
  # now_exp
  #  Returns the EXP collected in this level.
  #----------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #----------------------------------------------------------------------------
  # next_exp
  #  Returns the EXP needed to level up as number.
  #----------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
 
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap

  #----------------------------------------------------------------------------
  # gradient_bar
  #  x      - x coordinate
  #  y      - y coordinate
  #  w      - width of the bar to be drawn
  #  color1 - primary color
  #  color2 - secondary color
  #  color3 - back color
  #  rate   - fill rate
  #  This special method is able to draw one out of 7 styles.
  #----------------------------------------------------------------------------
  def gradient_bar(x, y, w, color1, color2, color3, rate, flag = true)
    # stop if not active or out of range
    return unless flag
    return if $game_system.bar_style < 0 || $game_system.bar_style > 6
    # styles with "vertical" black borders
    styles = [1, 3, 4, 5, 6]
    # setup of coordinates and offsets depending on style
    offs = 5
    x += offs
    y += 26
    if styles.include?($game_system.bar_style)
      offs += 2
      y -= 1
      [5, 6].include?($game_system.bar_style) ? y -= 2 :  x += 1
      # quantizes the width so it looks better (remove it and see what happens)
      w = w / 8 * 8
    end
    # temporary variable
    a = $game_system.bar_opacity
    if $game_system.bar_style < 5
      # draw black slanted back
      (0...(offs+3)).each {|i| fill_rect(x-i, y+i-2, w+3, 1, Color.new(0, 0, 0))}
      # draw white slanted back onto black, but let black borders stay
      (0...(offs+1)).each {|i| fill_rect(x-i, y+i-1, w+1, 1, Color.new(255, 255, 255))}
      if $game_system.bar_style < 2
        # iterate through each vertical bar
        (0...w+offs).each {|i|
            # calculate color
            r = color3.red * i / (w+offs)
            g = color3.green * i / (w+offs)
            b = color3.blue * i / (w+offs)
            # special offset calculation
            oy = i < offs ? offs-i : 0
            off = i < offs ? i : i > w ? w+offs-i : offs
            # draw this part of the bar
            fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
        # if slanted bar is out of critical area
        if (w*rate).to_i >= offs
          # draw the little triangular part on the left
          (0...((w*rate).to_i+offs)).each {|i|
              r = color1.red + (color2.red-color1.red)*i / ((w+offs)*rate)
              g = color1.green + (color2.green-color1.green)*i / ((w+offs)*rate)
              b = color1.blue + (color2.blue-color1.blue)*i / ((w+offs)*rate)
              oy = i < offs ? offs-i : 0
              off = i < offs ? i : i > w*rate ? (w*rate).to_i+offs-i : offs
              fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
        else
          # draw the little triangular part on the left using special method
          (0...(w * rate).to_i).each {|i| (0...offs).each {|j|
              r = color1.red + (color2.red-color1.red)*i / (w*rate)
              g = color1.green + (color2.green-color1.green)*i / (w*rate)
              b = color1.blue + (color2.blue-color1.blue)*i / (w*rate)
              set_pixel(x+i-j+1, y+j-1, Color.new(r, g, b, a))}}
        end
      else
        # iterate through all horizontal lines
        (0...offs).each {|i|
            # calculate colors
            r = color3.red * i / offs
            g = color3.green * i / offs
            b = color3.blue * i / offs
            # draw background line
            fill_rect(x-i+1, y+i-1, w, 1, Color.new(r, g, b, a))}
        if $game_system.bar_style == 4
          # iterate through half of all horizontal lines
          (0...offs/2+1).each {|i|
              # calculate colors
              r = color2.red * (i+1) / (offs/2)
              g = color2.green * (i+1) / (offs/2)
              b = color2.blue * (i+1) / (offs/2)
              # draw bar line
              fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))
              # draw bar line mirrored vertically
              fill_rect(x-offs+i+2, y+offs-i-2, w*rate, 1, Color.new(r, g, b, a))}
        else
          # iterate through all horizontal lines
          (0...offs).each {|i|
              # calculate colors
              r = color1.red + (color2.red-color1.red)*i / offs
              g = color1.green + (color2.green-color1.green)*i / offs
              b = color1.blue + (color2.blue-color1.blue)*i / offs
              # draw bar line
              fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))}
        end
      end
      # if style with black vertical slanted intersections
      if styles.include?($game_system.bar_style)
        # add black bars on 1st and 8th column every 8 pixels
        (0...w).each {|i| (0...offs).each {|j|
            if styles.include?($game_system.bar_style) && i % 8 < 2
              set_pixel(x+i-j+1, y+j-1, Color.new(0, 0, 0, a))
            end}}
      end
    else
      # fill white background
      fill_rect(x+1, y-3, w+2, 12, Color.new(255, 255, 255, a))
      # iterate through each of 6 lines
      (1...6).each {|i|
          # calculate background color
          color = Color.new(color3.red*i/5, color3.green*i/5, color3.blue*i/5, a)
          # draw background
          fill_rect(x+2, y+i-3, w, 12-i*2, color)
          # calculate bar color
          color = Color.new(color2.red*i/5, color2.green*i/5, color2.blue*i/5, a)
          # draw bar
          fill_rect(x+2, y+i-3, w*rate, 12-i*2, color)}
      # if style 5 (with vertical borders)
      if $game_system.bar_style == 5
        # add black bars on 1st and 8th column every 8 pixels
        (0...w/8).each {|i|
            fill_rect(x+2+i*8, y-2, 1, 10, Color.new(0, 0, 0, a))
            fill_rect(x+2+(i+1)*8-1, y-2, 1, 10, Color.new(0, 0, 0, a))}
      end
    end
  end
 
end

#==============================================================================
# Hud
#------------------------------------------------------------------------------
#  This class was modified to support SR display and modify the number of
#  skills left to use.
#==============================================================================

class Hud < Sprite
 
  #----------------------------------------------------------------------------
  # Initialization
  #  viewport - the viewport for the sprite
  #----------------------------------------------------------------------------
  def initialize(viewport = nil)
    # call superclass method
    super
    @name = []
    @level = []
    @hp = []
    @sp = []
    @exp = []
    # create ids
    create_ids
    # get height
    h = BlizzABS::Config::DIRECT_HOTKEYS ? @hud_height - 28 : @hud_height
    # create bitmap
    self.bitmap = Bitmap.new(@hud_width, h)
    # set font
    self.bitmap.font.name = 'Arial'
    # set font to bold
    self.bitmap.font.bold = true
    # set x, y id
    self.x, self.y = 0, 0
    # set z coordinate
    self.z = 1000
    # draw basic HUD
    draw_basic
    # update
    update
  end
  #----------------------------------------------------------------------------
  # create_ids
  #  Sets drawing ids. This method can be aliased and the ids
  #  modified to create a different HUD.
  #----------------------------------------------------------------------------
  def create_ids
    @original_width = @hud_width = 250
    @original_height = @hud_height = 480
    @name1_x, @name1_y, @level1_x, @level1_y = 150, 1, 105, 1
    @hp1_x, @hp1_y, @sp1_x, @sp1_y, @exp1_x, @exp1_y = 130, 13, 105, 33, 5, 100
    @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
    @face1_x, @face1_y = 5, 5
    @name_x, @name_y, @level_x, @level_y = 150, 1, 105, 1
    @hp_x, @hp_y, @sp_x, @sp_y, @exp_x, @exp_y = 130, 13, 105, 33, 5, 100
    @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
    @face_x, @face_y = 5, 5
  end
  #----------------------------------------------------------------------------
  # draw_basic
  #  Draws the HUD template.
  #----------------------------------------------------------------------------
  def draw_basic
    # set font color
    self.bitmap.font.color = system_color
    # draw "LV"
    self.bitmap.draw_text_full(@level1_x, @level1_y, 20, 20, 'LV',2)
  end
  #----------------------------------------------------------------------------
  # draw_empty
  #  Draws the HP and SP display when actor doesn't exist.
  #----------------------------------------------------------------------------
  def draw_empty
    # draw empty bars
    self.bitmap.gradient_bar_hud(@hp1_x+32, @hp1_y+3, 114, 0, 'hud_green_bar', 1)
    # draw empty bars
    self.bitmap.gradient_bar_hud(@sp1_x+32, @sp1_y+3, 114, 0, 'hud_blue_bar', 2)
    # set font color
    self.bitmap.font.color = disabled_color
    # draw empty HP
    self.bitmap.draw_text_full(@hp1_x+38, @hp1_y, 48, 20, '0', 2)
    self.bitmap.draw_text_full(@hp1_x+86, @hp1_y, 12, 20, '/', 1)
    self.bitmap.draw_text_full(@hp1_x+98, @hp1_y, 48, 20, '0')
    # draw empty SP
    self.bitmap.draw_text_full(@sp1_x+38, @sp1_y, 48, 20, '0', 2)
    self.bitmap.draw_text_full(@sp1_x+86, @sp1_y, 12, 20, '/', 1)
    self.bitmap.draw_text_full(@sp1_x+98, @sp1_y, 48, 20, '0')
    # reset all flag variables
    @name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
        @skills_left = @item = @items_left = @gold = nil
  end
  #----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name1
    # set current variable
    @name1 = actor.name
    # set font color
    self.bitmap.font.color = Color.new(0, 255, 0)
    # draw actor's name
    self.bitmap.draw_text_full(@name1_x, @name1_y, 104, 20, @name1)
  end
  #----------------------------------------------------------------------------
  # draw_face
  #  Draws the face display.
  #----------------------------------------------------------------------------
  def draw_face1
    # set current variable
    @sprite1 = Sprite.new
    # draw actor's face
    @sprite1.bitmap = RPG::Cache.picture(actor.name + '_f')
    @sprite1.x, @sprite1.y = @face1_x, @face1_y
    @sprite1.mirror = true
  end
  #----------------------------------------------------------------------------
  # draw_level
  #  Draws the level display.
  #----------------------------------------------------------------------------
  def draw_level1
    # set current variable
    @level1 = actor.level
    # set font color
    self.bitmap.font.color = normal_color
    # draw actor's level
    self.bitmap.draw_text_full(@level1_x+20, @level1_y, 20, 20, @level.to_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_hp
  #  Draws the HP display.
  #----------------------------------------------------------------------------
  def draw_hp1
    # set current variables
    @hp1, @maxhp1 = actor.hp, actor.maxhp
    # set fill rate
    rate = (@maxhp1 > 0 ? @hp1.to_f / @maxhp1 : 0)
    # create color
    if rate > 0.6
      color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
      color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
    elsif rate > 0.2 && rate <= 0.6
      color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
      color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
    elsif rate <= 0.2
      color1 = Color.new(400 * rate, 0, 0, 192)
      color2 = Color.new(240, 0, 0, 192)
    end
     color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@hp1_x,@hp1_y - 10,114,color1,color2,color3,rate)
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@hp1_x, @hp1_y, 32, 32, $data_system.words.hp)
    # set font color depending on how many HP left
    # set colors and draw values
    self.bitmap.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@hp1_x, @hp1_y, 48, 32, actor.hp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@hp1_x + 48, @hp1_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@hp1_x + 60, @hp1_y, 48, 32, actor.maxhp.to_s)
    self.bitmap.font.color.alpha = 255
  end
  #----------------------------------------------------------------------------
  # draw_sp
  #  Draws the SP display.
  #----------------------------------------------------------------------------
  def draw_sp1
    # set current variables
    @sp1, @maxsp1 = actor.sp, actor.maxsp
    # set fill rate
    rate = (@maxsp1 > 0 ? @sp1.to_f / @maxsp1 : 0)
    if rate > 0.4
        color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
        color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
      elsif rate <= 0.4
        color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
        color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
      end
     color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@sp1_x,@sp1_y-10,114,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@sp1_x, @sp1_y, 32, 32, $data_system.words.sp)
    # set offset
    # set colors and draw values
    self.bitmap.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@sp1_x, @sp1_y, 48, 32, actor.sp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@sp1_x + 48, @sp1_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@sp1_x + 60, @sp1_y, 48, 32, actor.maxsp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_exp
  #  Draws the exp display.
  #----------------------------------------------------------------------------
  def draw_exp1
    # set current variables
    @now_exp1, @next_exp1 = actor.now_exp, actor.next_exp
    # set fill rate
    rate = (@next_exp1 != 0 ? @now_exp1.to_f / @next_exp1 : 1)
   if rate < 0.5
        color1 = Color.new(20 * rate, 60, 80, 192)
        color2 = Color.new(60 * rate, 180, 240, 192)
      elsif rate >= 0.5
        color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
        color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
      end
      color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@exp1_x,@exp1_y-10,114/2,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@exp1_x, @exp1_y, 32, 32, 'EXP')

  end
  #----------------------------------------------------------------------------
  # draw_name
  #  Draws the name display.
  #----------------------------------------------------------------------------
  def draw_name(id)
    actors = $game_party.actors[id]
    # set current variable
    @name[id] = actors.name
    # set font color
    self.bitmap.font.color = Color.new(0, 255, 0)
    # draw actor's name
    self.bitmap.draw_text_full(@name_x, @name_y+@all_y, 104, 20, @name[id])
  end
  #----------------------------------------------------------------------------
  # draw_face
  #  Draws the face display.
  #----------------------------------------------------------------------------
  def draw_face(id)
    actors = $game_party.actors[id]
    # set current variable
    @sprite[id] = Sprite.new
    # draw actor's face
    @sprite[id].bitmap = RPG::Cache.picture(actors.name + '_f')
    @sprite[id].x, @sprite[id].y = @face_x, @face_y+@all_y
    @sprite[id].mirror = true
  end
  #----------------------------------------------------------------------------
  # draw_level
  #  Draws the level display.
  #----------------------------------------------------------------------------
  def draw_level(id)
    actors = $game_party.actors[id]
    # set current variable
    @level[id] = actors.level
    # set font color
    self.bitmap.font.color = normal_color
    # draw actor's level
    self.bitmap.draw_text_full(@level_x+20, @level_y+@all_y, 20, 20, @level.to_s, 2)
  end
  #----------------------------------------------------------------------------
  # draw_hp
  #  Draws the HP display.
  #----------------------------------------------------------------------------
  def draw_hp(id)
    actors = $game_party.actors[id]
    # set current variables
    @hp[id], @maxhp[id] = actors.hp, actors.maxhp
    # set fill rate
    rate = (@maxhp[id] > 0 ? @hp[id].to_f / @maxhp[id] : 0)
    # create color
    if rate > 0.6
      color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
      color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
    elsif rate > 0.2 && rate <= 0.6
      color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
      color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
    elsif rate <= 0.2
      color1 = Color.new(400 * rate, 0, 0, 192)
      color2 = Color.new(240, 0, 0, 192)
    end
     color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@hp_x,@hp_y+@all_y - 10,114/2,color1,color2,color3,rate)
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 32, 32, $data_system.words.hp)
    # set font color depending on how many HP left
    # set colors and draw values
    self.bitmap.font.color = actors.hp == 0 ? knockout_color :
      actors.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 48, 32, actors.hp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@hp_x + 48, @hp_y+@all_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@hp_x + 60, @hp_y+@all_y, 48, 32, actors.maxhp.to_s)
    self.bitmap.font.color.alpha = 255
  end
  #----------------------------------------------------------------------------
  # draw_sp
  #  Draws the SP display.
  #----------------------------------------------------------------------------
  def draw_sp(id)
    actors = $game_party.actors[id]
    # set current variables
    @sp[id], @maxsp[id] = actors.sp, actors.maxsp
    # set fill rate
    rate = (@maxsp[id] > 0 ? @sp[id].to_f / @maxsp[id] : 0)
    if rate > 0.4
        color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
        color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
      elsif rate <= 0.4
        color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
        color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
      end
     color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@sp_x,@sp_y-10+@all_y,114/2,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@sp_x, @sp_y+@all_y, 32, 32, $data_system.words.sp)
    # set offset
    # set colors and draw values
    self.bitmap.font.color = actors.sp == 0 ? knockout_color :
      actors.sp <= actors.maxhp / 4 ? crisis_color : normal_color
    self.bitmap.draw_text_full(@sp+@all_y_x, @sp_y+@all_y, 48, 32, actors.sp.to_s, 2)
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@sp_x + 48, @sp_y+@all_y, 12, 32, '/', 1)
    self.bitmap.draw_text_full(@sp_x + 60, @sp_y+@all_y, 48, 32, actors.maxsp.to_s)
  end
  #----------------------------------------------------------------------------
  # draw_exp
  #  Draws the exp display.
  #----------------------------------------------------------------------------
  def draw_exp(id)
    actors = $game_party.actors[id]
    # set current variables
    @now_exp[id], next_exp[id] = actors.now_exp, actors.next_exp
    # set fill rate
    rate = (next_exp[id] != 0 ? @now_exp[id].to_f / @next_exp[id] : 1)
   if rate < 0.5
        color1 = Color.new(20 * rate, 60, 80, 192)
        color2 = Color.new(60 * rate, 180, 240, 192)
      elsif rate >= 0.5
        color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
        color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
      end
      color3 = Color.new(0, 80, 0, 192)
    # draw gradient bar
    self.bitmap.gradient_bar(@exp_x,@exp_y-10+@all_y,114/4,color1, color2, color3, rate)
    # set font color depending on how many SP left
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@exp_x, @exp_y+@all_y, 32, 32, 'EXP')

  end
  #----------------------------------------------------------------------------
  # draw_hskill
  #  Draws the hot skill display.
  #----------------------------------------------------------------------------
  def draw_hskill
    # set current variable
    @skill = actor.skill
    # if skill hot skill exists
    if @skill != 0
      # load bitmap
      bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
      # draw bitmap
      self.bitmap.blt(@hot_x+48, @hot_y+4, bitmap, Rect.new(0, 0, 24, 24))
    end
    # removes skills left to use display
    draw_lskill
  end
  #----------------------------------------------------------------------------
  # draw_lskill
  #  Draws the skills left to use display.
  #----------------------------------------------------------------------------
  def draw_lskill
    # get the number of skills left
    @skills_left = get_skills_left
    # if hot skill exists
    if @skill != nil && @skill > 0
      # if normal SP cost
      if @skills_left >= 0
        # if not enough sp to use
        if @skills_left == 0
          # set font color
          self.bitmap.font.color = Color.new(255, 0, 0)
        # if enough SP for 5 or less skill uses
        elsif @skills_left <= 5
          # set font color
          self.bitmap.font.color = Color.new(255, 255, 0)
        else
          # set font color
          self.bitmap.font.color = normal_color
        end
        # decrease font color
        self.bitmap.font.size -= 2
        # draw number how many skills left to use
        self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, @skills_left.to_s, 1)
        # increase font size
        self.bitmap.font.size += 2
      # if infinite skills left
      elsif @skills_left == -1
        # set font color
        self.bitmap.font.color = Color.new(0, 255, 0)
        # increase font size
        self.bitmap.font.size += 4
        # draw "∞" skill uses left
        self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, '∞', 1)
        # decrease font size
        self.bitmap.font.size -= 4
      end
    end
  end
  #----------------------------------------------------------------------------
  # get_skills_left
  #  Gets the number of skill usages left.
  #----------------------------------------------------------------------------
  def get_skills_left
    # if skill hot skill exists
    if @skill != nil && @skill > 0
      # if SP cost is zero
      if $data_skills[@skill].sp_cost > 0
        # get basic SP cost
        sp_cost = $data_skills[@skill].sp_cost
        # if using SP Cost Mod Status
        if $tons_version != nil && $tons_version >= 6.54 &&
            $game_system.SP_COST_MOD
          # get modified cost
          sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
        end
        # infinite
        return -1 if sp_cost == 0
        # calculate skills left to use
        return @sp / sp_cost
      end
      # set flag
      return -1
    end
    # set flag
    return -2
  end
  #----------------------------------------------------------------------------
  # draw_hitem
  #  Draws the hot item display.
  #----------------------------------------------------------------------------
  def draw_hitem
    # set current variable
    @item = actor.item
    # if hot item exists
    if @item != 0
      # load bitmap
      bitmap = RPG::Cache.icon($data_items[@item].icon_name)
      # draw bitmap
      self.bitmap.blt(@hot_x+124, @hot_y+4, bitmap, Rect.new(0, 0, 24, 24))
    end
    # removes items left to use display
    draw_litem
  end
  #----------------------------------------------------------------------------
  # draw_litem
  #  Draws the items left to use display.
  #----------------------------------------------------------------------------
  def draw_litem
    # set current variable
    @items_left = $game_party.item_number(@item)
    # if hot item exists
    if @item != nil && @item > 0
      # if item exists and cannot be consumed
      if $data_items[@item] != nil && !$data_items[@item].consumable
        # set font color
        self.bitmap.font.color = Color.new(0, 255, 0)
        # increase font size
        self.bitmap.font.size += 4
        # draw "∞" items left
        self.bitmap.draw_text_full(@left_x+76, @left_y, 24, 20, '∞', 1)
        # decrease font size
        self.bitmap.font.size -= 4
      else
        # if no items left
        if @items_left == 0
          # set font color
          self.bitmap.font.color = Color.new(255, 0, 0)
        # if equal or less items left
        elsif @items_left <= 10
          # set font color
          self.bitmap.font.color = Color.new(255, 255, 0)
        else
          # set font color
          self.bitmap.font.color = normal_color
        end
        # decrease font color
        self.bitmap.font.size -= 2
        # draw number how many items left to use
        self.bitmap.draw_text_full(@left_x+76, @left_y, 24, 20, @items_left.to_s, 1)
        # increase font size
        self.bitmap.font.size += 2
      end
    end
  end
  #----------------------------------------------------------------------------
  # update
  #  Checks if HUD needs refreshing.
  #----------------------------------------------------------------------------
  def update
    # if actor doesn't exist
    if actor == nil
      # unless already drawn empty HUD
      unless @empty_hud_drawn
        # draw HUD template
        draw_basic
        # draw empty HP, SP and EXP bars
        draw_empty
        # empty HUD was drawn
        @empty_hud_drawn = true
      end
    else
      # if HUD needs refresh
      if $game_temp.hud_refresh
        # draw all data about actor
         self.bitmap.font.size = 16
        draw_name1
        draw_level1
        draw_hp1
        draw_sp1
        draw_exp1
        draw_face1
        if $game_party.actors.size < 1..BlizzABS::Config::MAX_PARTY - 1
         @max = $game_party.actors.size
        else
         @max = BlizzABS::Config::MAX_PARTY - 1
        end
        for i in 1..@max
         self.bitmap.font.size = 8
          @all_y = 60 + i *70
          draw_name(i)
          draw_level(i)
          draw_hp(i)
          draw_sp(i)
          draw_exp(i)
          draw_face(i)
        end
        unless BlizzABS::Config::DIRECT_HOTKEYS
          draw_hskill
          draw_lskill
          draw_hitem
          draw_litem
        end
        # remove flag
        $game_temp.hud_refresh = nil
      else
        # draw data that needs to ve updated
        test_name1
        test_level1
        test_hp1
        test_sp1
        test_exp1
        test_face1
        for i in 1..BlizzABS::Config::MAX_PARTY - 1
         test_name(i)
         test_level(i)
         test_hp(i)
         test_sp(i)
         test_exp(i)
         test_face(i)
        end
        unless BlizzABS::Config::DIRECT_HOTKEYS
          test_hskill
          test_lskill
          test_hitem
          test_litem
        end
      end
      # empty HUD wasn't drawn
      @empty_hud_drawn = false
    end
  end
  #----------------------------------------------------------------------------
  # test_name
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_name1
    # draw new name if name has changed
    draw_name1 if actor.name != @name1
  end
  #----------------------------------------------------------------------------
  # test_face
  #  Tests and draws the face.
  #----------------------------------------------------------------------------
  def test_face1
    # draw new name if name has changed
    draw_face1
  end
  #----------------------------------------------------------------------------
  # test_level
  #  Tests and draws the level.
  #----------------------------------------------------------------------------
  def test_level1
    # draw new level if level has changed
    draw_level1 if actor.level != @level1
  end
  #----------------------------------------------------------------------------
  # test_hp
  #  Tests and draws the HP.
  #----------------------------------------------------------------------------
  def test_hp1
    # draw new HP if HP or max HP have changed
    draw_hp1 if actor.hp != @hp1 || actor.maxhp != @maxhp1
  end
  #----------------------------------------------------------------------------
  # test_sp
  #  Tests and draws the SP.
  #----------------------------------------------------------------------------
  def test_sp1
    # draw new SP if SP or max SP have changed
    draw_sp1 if actor.sp != @sp1 || actor.maxsp != @maxsp1
  end
  #----------------------------------------------------------------------------
  # test_exp
  #  Tests and draws the EXP.
  #----------------------------------------------------------------------------
  def test_exp1
    # draw new SP if SP or max SP have changed
    draw_exp1 if actor.now_exp != @now_exp1
  end
  #----------------------------------------------------------------------------
  # test_name
  #  Tests and draws the name.
  #----------------------------------------------------------------------------
  def test_name(id)
    actors = $game_party.actors[id]
    # draw new name if name has changed
    draw_name(id) if actors.name != @name[id]
  end
  #----------------------------------------------------------------------------
  # test_face
  #  Tests and draws the face.
  #----------------------------------------------------------------------------
  def test_face(id)
    # draw new name if name has changed
    draw_face(id)
  end
  #----------------------------------------------------------------------------
  # test_level
  #  Tests and draws the level.
  #----------------------------------------------------------------------------
  def test_level(id)
    actors = $game_party.actors[id]
    # draw new level if level has changed
    draw_level(id) if actors.level != @level[id]
  end
  #----------------------------------------------------------------------------
  # test_hp
  #  Tests and draws the HP.
  #----------------------------------------------------------------------------
  def test_hp(id)
    actors = $game_party.actors[id]
    # draw new HP if HP or max HP have changed
    draw_hp(id) if actors.hp != @hp[id] || actors.maxhp != @maxhp[id]
  end
  #----------------------------------------------------------------------------
  # test_sp
  #  Tests and draws the SP.
  #----------------------------------------------------------------------------
  def test_sp(id)
    actors = $game_party.actors[id]
    # draw new SP if SP or max SP have changed
    draw_sp(id) if actors.sp != @sp[id] || actors.maxsp != @maxsp[id]
  end
  #----------------------------------------------------------------------------
  # test_exp
  #  Tests and draws the EXP.
  #----------------------------------------------------------------------------
  def test_exp(id)
    actors = $game_party.actors[id]
    # draw new SP if SP or max SP have changed
    draw_exp(id) if actors.now_exp != @now_exp[id]
  end
  #----------------------------------------------------------------------------
  # test_hskill
  #  Tests and draws the hskill.
  #----------------------------------------------------------------------------
  def test_hskill
    # draw new skill icon if assigned skill has changed
    draw_hskill if actor.skill != @skill
  end
  #----------------------------------------------------------------------------
  # test_lskill
  #  Tests and draws the lskill.
  #----------------------------------------------------------------------------
  def test_lskill
    # draw how many skills left to use if this number has changed
    draw_lskill if get_skills_left != @skills_left
  end
  #----------------------------------------------------------------------------
  # test_hitem
  #  Tests and draws the hitem.
  #----------------------------------------------------------------------------
  def test_hitem
    # draw new item icon if assigned item has changed
    draw_hitem if actor.item != @item
  end
  #----------------------------------------------------------------------------
  # test_litem
  #  Tests and draws the litem.
  #----------------------------------------------------------------------------
  def test_litem
    # draw how many items left to use if this number has changed
    draw_litem if $game_party.item_number(@item) != @items_left
  end
  #----------------------------------------------------------------------------
  # actor
  #  Returns the party leader's battler for easier reference.
  #----------------------------------------------------------------------------
  def actor
    return $game_player.battler
  end
 
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 09, 2009, 06:31:49 pm
You need to use "1...$game_party.actors.size" instead. Your code tries to access non-existing actors if the party isn't full. It's MAX_PARTY, not CURRENT_PARTY or something like that.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on November 09, 2009, 07:34:42 pm
ok here the new code but its lagging realy bad & the exp for the other chars stays full also how should i update the faces

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Game_System
 
 attr_accessor :bar_style
 attr_reader   :bar_opacity
 #----------------------------------------------------------------------------
 # initialize
 #  Added bar style variables.
 #----------------------------------------------------------------------------
 alias init_blizzart_later initialize
 def initialize
   init_blizzart_later
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#
#   Configure this part manually if you have no "Options" controller for the
#   styles and the opacity. (style: 0~6, opacity: 0~255)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   @bar_style = 2
   self.bar_opacity = 255
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 end
 #----------------------------------------------------------------------------
 # bar_opacity=
 #  alpha - opacity
 #  Encapsulation and range limitation of opacity.
 #----------------------------------------------------------------------------
 def bar_opacity=(alpha)
   @bar_opacity = [[alpha, 0].max, 255].min
 end
 
end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor
 
 #----------------------------------------------------------------------------
 # now_exp
 #  Returns the EXP collected in this level.
 #----------------------------------------------------------------------------
 def now_exp
   return @exp - @exp_list[@level]
 end
 #----------------------------------------------------------------------------
 # next_exp
 #  Returns the EXP needed to level up as number.
 #----------------------------------------------------------------------------
 def next_exp
   return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
 end
 
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap

 #----------------------------------------------------------------------------
 # gradient_bar
 #  x      - x coordinate
 #  y      - y coordinate
 #  w      - width of the bar to be drawn
 #  color1 - primary color
 #  color2 - secondary color
 #  color3 - back color
 #  rate   - fill rate
 #  This special method is able to draw one out of 7 styles.
 #----------------------------------------------------------------------------
 def gradient_bar(x, y, w, color1, color2, color3, rate, flag = true)
   # stop if not active or out of range
   return unless flag
   return if $game_system.bar_style < 0 || $game_system.bar_style > 6
   # styles with "vertical" black borders
   styles = [1, 3, 4, 5, 6]
   # setup of coordinates and offsets depending on style
   offs = 5
   x += offs
   y += 26
   if styles.include?($game_system.bar_style)
     offs += 2
     y -= 1
     [5, 6].include?($game_system.bar_style) ? y -= 2 :  x += 1
     # quantizes the width so it looks better (remove it and see what happens)
     w = w / 8 * 8
   end
   # temporary variable
   a = $game_system.bar_opacity
   if $game_system.bar_style < 5
     # draw black slanted back
     (0...(offs+3)).each {|i| fill_rect(x-i, y+i-2, w+3, 1, Color.new(0, 0, 0))}
     # draw white slanted back onto black, but let black borders stay
     (0...(offs+1)).each {|i| fill_rect(x-i, y+i-1, w+1, 1, Color.new(255, 255, 255))}
     if $game_system.bar_style < 2
       # iterate through each vertical bar
       (0...w+offs).each {|i|
           # calculate color
           r = color3.red * i / (w+offs)
           g = color3.green * i / (w+offs)
           b = color3.blue * i / (w+offs)
           # special offset calculation
           oy = i < offs ? offs-i : 0
           off = i < offs ? i : i > w ? w+offs-i : offs
           # draw this part of the bar
           fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
       # if slanted bar is out of critical area
       if (w*rate).to_i >= offs
         # draw the little triangular part on the left
         (0...((w*rate).to_i+offs)).each {|i|
             r = color1.red + (color2.red-color1.red)*i / ((w+offs)*rate)
             g = color1.green + (color2.green-color1.green)*i / ((w+offs)*rate)
             b = color1.blue + (color2.blue-color1.blue)*i / ((w+offs)*rate)
             oy = i < offs ? offs-i : 0
             off = i < offs ? i : i > w*rate ? (w*rate).to_i+offs-i : offs
             fill_rect(x+i-offs+1, y+oy-1, 1, off, Color.new(r, g, b, a))}
       else
         # draw the little triangular part on the left using special method
         (0...(w * rate).to_i).each {|i| (0...offs).each {|j|
             r = color1.red + (color2.red-color1.red)*i / (w*rate)
             g = color1.green + (color2.green-color1.green)*i / (w*rate)
             b = color1.blue + (color2.blue-color1.blue)*i / (w*rate)
             set_pixel(x+i-j+1, y+j-1, Color.new(r, g, b, a))}}
       end
     else
       # iterate through all horizontal lines
       (0...offs).each {|i|
           # calculate colors
           r = color3.red * i / offs
           g = color3.green * i / offs
           b = color3.blue * i / offs
           # draw background line
           fill_rect(x-i+1, y+i-1, w, 1, Color.new(r, g, b, a))}
       if $game_system.bar_style == 4
         # iterate through half of all horizontal lines
         (0...offs/2+1).each {|i|
             # calculate colors
             r = color2.red * (i+1) / (offs/2)
             g = color2.green * (i+1) / (offs/2)
             b = color2.blue * (i+1) / (offs/2)
             # draw bar line
             fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))
             # draw bar line mirrored vertically
             fill_rect(x-offs+i+2, y+offs-i-2, w*rate, 1, Color.new(r, g, b, a))}
       else
         # iterate through all horizontal lines
         (0...offs).each {|i|
             # calculate colors
             r = color1.red + (color2.red-color1.red)*i / offs
             g = color1.green + (color2.green-color1.green)*i / offs
             b = color1.blue + (color2.blue-color1.blue)*i / offs
             # draw bar line
             fill_rect(x-i+1, y+i-1, w*rate, 1, Color.new(r, g, b, a))}
       end
     end
     # if style with black vertical slanted intersections
     if styles.include?($game_system.bar_style)
       # add black bars on 1st and 8th column every 8 pixels
       (0...w).each {|i| (0...offs).each {|j|
           if styles.include?($game_system.bar_style) && i % 8 < 2
             set_pixel(x+i-j+1, y+j-1, Color.new(0, 0, 0, a))
           end}}
     end
   else
     # fill white background
     fill_rect(x+1, y-3, w+2, 12, Color.new(255, 255, 255, a))
     # iterate through each of 6 lines
     (1...6).each {|i|
         # calculate background color
         color = Color.new(color3.red*i/5, color3.green*i/5, color3.blue*i/5, a)
         # draw background
         fill_rect(x+2, y+i-3, w, 12-i*2, color)
         # calculate bar color
         color = Color.new(color2.red*i/5, color2.green*i/5, color2.blue*i/5, a)
         # draw bar
         fill_rect(x+2, y+i-3, w*rate, 12-i*2, color)}
     # if style 5 (with vertical borders)
     if $game_system.bar_style == 5
       # add black bars on 1st and 8th column every 8 pixels
       (0...w/8).each {|i|
           fill_rect(x+2+i*8, y-2, 1, 10, Color.new(0, 0, 0, a))
           fill_rect(x+2+(i+1)*8-1, y-2, 1, 10, Color.new(0, 0, 0, a))}
     end
   end
 end
 
end

#==============================================================================
# Hud
#------------------------------------------------------------------------------
#  This class was modified to support SR display and modify the number of
#  skills left to use.
#==============================================================================

class Hud < Sprite
 
 #----------------------------------------------------------------------------
 # Initialization
 #  viewport - the viewport for the sprite
 #----------------------------------------------------------------------------
 def initialize(viewport = nil)
   # call superclass method
   super
   @name = @level = @hp = @maxhp = @sp = @maxsp = @now_exp = @next_exp = @sprite = Array.new
   # create ids
   create_ids
   # get height
   h = BlizzABS::Config::DIRECT_HOTKEYS ? @hud_height - 28 : @hud_height
   # create bitmap
   self.bitmap = Bitmap.new(@hud_width, h)
   # set font
   self.bitmap.font.name = 'Times New Roman'
   # set font to bold
   self.bitmap.font.bold = true
   # set x, y id
   self.x, self.y = 0, 0
   # set z coordinate
   self.z = 1000
   # update
   update
 end
 #----------------------------------------------------------------------------
 # create_ids
 #  Sets drawing ids. This method can be aliased and the ids
 #  modified to create a different HUD.
 #----------------------------------------------------------------------------
 def create_ids
   @original_width = @hud_width = 250
   @original_height = @hud_height = 480
   @name1_x, @name1_y, @level1_x, @level1_y = 150, 1, 105, 1
   @hp1_x, @hp1_y, @sp1_x, @sp1_y, @exp1_x, @exp1_y = 130, 13, 105, 33, 5, 100
   @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
   @face1_x, @face1_y = 5, 5
   @name_x, @name_y, @level_x, @level_y = 120, 1, 50, 1
   @hp_x, @hp_y, @sp_x, @sp_y, @exp_x, @exp_y = 80, 13, 70, 33, 5, 50
   @hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
   @face_x, @face_y = 5, 5
 end
 #----------------------------------------------------------------------------
 # draw_empty
 #  Draws the HP and SP display when actor doesn't exist.
 #----------------------------------------------------------------------------
 def draw_empty
   # draw empty bars
   self.bitmap.gradient_bar_hud(@hp1_x+32, @hp1_y+3, 114, 0, 'hud_green_bar', 1)
   # draw empty bars
   self.bitmap.gradient_bar_hud(@sp1_x+32, @sp1_y+3, 114, 0, 'hud_blue_bar', 2)
   # set font color
   self.bitmap.font.color = disabled_color
   # draw empty HP
   self.bitmap.draw_text_full(@hp1_x+38, @hp1_y, 48, 20, '0', 2)
   self.bitmap.draw_text_full(@hp1_x+86, @hp1_y, 12, 20, '/', 1)
   self.bitmap.draw_text_full(@hp1_x+98, @hp1_y, 48, 20, '0')
   # draw empty SP
   self.bitmap.draw_text_full(@sp1_x+38, @sp1_y, 48, 20, '0', 2)
   self.bitmap.draw_text_full(@sp1_x+86, @sp1_y, 12, 20, '/', 1)
   self.bitmap.draw_text_full(@sp1_x+98, @sp1_y, 48, 20, '0')
   # reset all flag variables
   @name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
       @skills_left = @item = @items_left = @gold = nil
 end
 #----------------------------------------------------------------------------
 # draw_name
 #  Draws the name display.
 #----------------------------------------------------------------------------
 def draw_name1
   # set current variable
   @name1 = actor.name
   # set font color
   self.bitmap.font.color = Color.new(0, 255, 0)
   # draw actor's name
   self.bitmap.draw_text_full(@name1_x, @name1_y, 104, 20, @name1)
 end
 #----------------------------------------------------------------------------
 # draw_face
 #  Draws the face display.
 #----------------------------------------------------------------------------
 def draw_face1
   # set current variable
   @sprite1 = Sprite.new
   # draw actor's face
   @sprite1.bitmap = RPG::Cache.picture(actor.name + '_f')
   @sprite1.x, @sprite1.y = @face1_x, @face1_y
   @sprite1.mirror = true
 end
 #----------------------------------------------------------------------------
 # draw_level
 #  Draws the level display.
 #----------------------------------------------------------------------------
 def draw_level1
   # set current variable
   @level1 = actor.level
   # set font color
   self.bitmap.font.color = normal_color
   # draw actor's level
   self.bitmap.draw_text_full(@level1_x+20, @level1_y, 20, 20, @level1.to_s, 2)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@level1_x, @level1_y, 20, 20, 'LV',2)
 end
 #----------------------------------------------------------------------------
 # draw_hp
 #  Draws the HP display.
 #----------------------------------------------------------------------------
 def draw_hp1
   # set current variables
   @hp1, @maxhp1 = actor.hp, actor.maxhp
   # set fill rate
   rate = (@maxhp1 > 0 ? @hp1.to_f / @maxhp1 : 0)
   # create color
   if rate > 0.6
     color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
     color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
   elsif rate > 0.2 && rate <= 0.6
     color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
     color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
   elsif rate <= 0.2
     color1 = Color.new(400 * rate, 0, 0, 192)
     color2 = Color.new(240, 0, 0, 192)
   end
    color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@hp1_x,@hp1_y - 10,114,color1,color2,color3,rate)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@hp1_x, @hp1_y, 32, 32, $data_system.words.hp)
   # set font color depending on how many HP left
   # set colors and draw values
   self.bitmap.font.color = actor.hp == 0 ? knockout_color :
     actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@hp1_x, @hp1_y, 48, 32, actor.hp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@hp1_x + 48, @hp1_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@hp1_x + 60, @hp1_y, 48, 32, actor.maxhp.to_s)
   self.bitmap.font.color.alpha = 255
 end
 #----------------------------------------------------------------------------
 # draw_sp
 #  Draws the SP display.
 #----------------------------------------------------------------------------
 def draw_sp1
   # set current variables
   @sp1, @maxsp1 = actor.sp, actor.maxsp
   # set fill rate
   rate = (@maxsp1 > 0 ? @sp1.to_f / @maxsp1 : 0)
   if rate > 0.4
       color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
       color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
     elsif rate <= 0.4
       color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
       color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
     end
    color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@sp1_x,@sp1_y-10,114,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@sp1_x, @sp1_y, 32, 32, $data_system.words.sp)
   # set offset
   # set colors and draw values
   self.bitmap.font.color = actor.sp == 0 ? knockout_color :
     actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@sp1_x, @sp1_y, 48, 32, actor.sp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@sp1_x + 48, @sp1_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@sp1_x + 60, @sp1_y, 48, 32, actor.maxsp.to_s)
 end
 #----------------------------------------------------------------------------
 # draw_exp
 #  Draws the exp display.
 #----------------------------------------------------------------------------
 def draw_exp1
   # set current variables
   @now_exp1, @next_exp1 = actor.now_exp, actor.next_exp
   # set fill rate
   rate = (@next_exp1 != 0 ? @now_exp1.to_f / @next_exp1 : 1)
  if rate < 0.5
       color1 = Color.new(20 * rate, 60, 80, 192)
       color2 = Color.new(60 * rate, 180, 240, 192)
     elsif rate >= 0.5
       color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
       color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
     end
     color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@exp1_x,@exp1_y-10,114/2,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@exp1_x, @exp1_y, 32, 32, 'EXP')

 end
 #----------------------------------------------------------------------------
 # draw_name
 #  Draws the name display.
 #----------------------------------------------------------------------------
 def draw_name(id)
   actors = $game_party.actors[id]
   # set current variable
   @name[id] = actors.name
   # set font color
   self.bitmap.font.color = Color.new(0, 255, 0)
   # draw actor's name
   self.bitmap.draw_text_full(@name_x, @name_y+@all_y, 104, 20, @name[id])
 end
 #----------------------------------------------------------------------------
 # draw_face
 #  Draws the face display.
 #----------------------------------------------------------------------------
 def draw_face(id)
   actors = $game_party.actors[id]
   # set current variable
   @sprite[id] = Sprite.new
   # draw actor's face
   @sprite[id].bitmap = RPG::Cache.picture(actors.name + '_f')
   @sprite[id].x, @sprite[id].y = @face_x, @face_y+@all_y
   @sprite[id].zoom_x, @sprite[id].zoom_y = @sprite[id].zoom_x / 2 ,@sprite[id].zoom_y / 2
   @sprite[id].mirror = true
 end
 #----------------------------------------------------------------------------
 # draw_level
 #  Draws the level display.
 #----------------------------------------------------------------------------
 def draw_level(id)
   actors = $game_party.actors[id]
   # set current variable
   @level[id] = actors.level
   # set font color
   self.bitmap.font.color = normal_color
   # draw actor's level
   self.bitmap.draw_text_full(@level_x+20, @level_y+@all_y, 20, 20, @level[id].to_s, 2)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@level_x, @level_y+@all_y, 20, 20, 'LV',2)
 end
 #----------------------------------------------------------------------------
 # draw_hp
 #  Draws the HP display.
 #----------------------------------------------------------------------------
 def draw_hp(id)
   actors = $game_party.actors[id]
   # set current variables
   @hp[id], @maxhp[id] = actors.hp, actors.maxhp
   # set fill rate
   rate = (@maxhp[id] > 0 ? @hp[id].to_f / @maxhp[id] : 0)
   # create color
   if rate > 0.6
     color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
     color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
   elsif rate > 0.2 && rate <= 0.6
     color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
     color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
   elsif rate <= 0.2
     color1 = Color.new(400 * rate, 0, 0, 192)
     color2 = Color.new(240, 0, 0, 192)
   end
    color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@hp_x,@hp_y+@all_y - 10,114/2,color1,color2,color3,rate)
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 32, 32, $data_system.words.hp)
   # set font color depending on how many HP left
   # set colors and draw values
   self.bitmap.font.color = actors.hp == 0 ? knockout_color :
     actors.hp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@hp_x, @hp_y+@all_y, 48, 32, actors.hp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@hp_x + 18, @hp_y+@all_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@hp_x + 20, @hp_y+@all_y, 48, 32, actors.maxhp.to_s)
   self.bitmap.font.color.alpha = 255
 end
 #----------------------------------------------------------------------------
 # draw_sp
 #  Draws the SP display.
 #----------------------------------------------------------------------------
 def draw_sp(id)
   actors = $game_party.actors[id]
   # set current variables
   @sp[id], @maxsp[id] = actors.sp, actors.maxsp
   # set fill rate
   rate = (@maxsp[id] > 0 ? @sp[id].to_f / @maxsp[id] : 0)
   if rate > 0.4
       color1 = Color.new(60 - 66 * (rate-0.4), 20, 80, 192)
       color2 = Color.new(180 - 200 * (rate-0.4), 60, 240, 192)
     elsif rate <= 0.4
       color1 = Color.new(20 + 100 * rate, 50 * rate, 26 + 166 * rate, 192)
       color2 = Color.new(60 + 300 * rate, 150 * rate, 80 + 400 * rate, 192)
     end
    color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@sp_x,@sp_y-10+@all_y,114/2,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@sp_x, @sp_y+@all_y, 32, 32, $data_system.words.sp)
   # set offset
   # set colors and draw values
   self.bitmap.font.color = actors.sp == 0 ? knockout_color :
     actors.sp <= actors.maxhp / 4 ? crisis_color : normal_color
   self.bitmap.draw_text_full(@sp_x, @sp_y+@all_y, 48, 32, actors.sp.to_s, 2)
   self.bitmap.font.color = normal_color
   self.bitmap.draw_text_full(@sp_x + 18, @sp_y+@all_y, 12, 32, '/', 1)
   self.bitmap.draw_text_full(@sp_x + 20, @sp_y+@all_y, 48, 32, actors.maxsp.to_s)
 end
 #----------------------------------------------------------------------------
 # draw_exp
 #  Draws the exp display.
 #----------------------------------------------------------------------------
 def draw_exp(id)
   actors = $game_party.actors[id]
   # set current variables
   @now_exp[id], @next_exp[id] = actors.now_exp, actors.next_exp
   # set fill rate
   rate = (@next_exp[id] != 0 ? @now_exp[id].to_f / @next_exp[id] : 1)
  if rate < 0.5
       color1 = Color.new(20 * rate, 60, 80, 192)
       color2 = Color.new(60 * rate, 180, 240, 192)
     elsif rate >= 0.5
       color1 = Color.new(20 + 120 * (rate-0.5), 60 + 40 * (rate-0.5), 80, 192)
       color2 = Color.new(60 + 360 * (rate-0.5), 180 + 120 * (rate-0.5), 240, 192)
     end
     color3 = Color.new(0, 80, 0, 192)
   # draw gradient bar
   self.bitmap.gradient_bar(@exp_x,@exp_y-10+@all_y,114/4,color1, color2, color3, rate)
   # set font color depending on how many SP left
   self.bitmap.font.color = system_color
   self.bitmap.draw_text_full(@exp_x, @exp_y+@all_y, 32, 32, 'EXP')

 end
 #----------------------------------------------------------------------------
 # draw_hskill
 #  Draws the hot skill display.
 #----------------------------------------------------------------------------
 def draw_hskill
   # set current variable
   @skill = actor.skill
   # if skill hot skill exists
   if @skill != 0
     # load bitmap
     bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
     # draw bitmap
     self.bitmap.blt(@hot_x+48, @hot_y+4, bitmap, Rect.new(0, 0, 24, 24))
   end
   # removes skills left to use display
   draw_lskill
 end
 #----------------------------------------------------------------------------
 # draw_lskill
 #  Draws the skills left to use display.
 #----------------------------------------------------------------------------
 def draw_lskill
   # get the number of skills left
   @skills_left = get_skills_left
   # if hot skill exists
   if @skill != nil && @skill > 0
     # if normal SP cost
     if @skills_left >= 0
       # if not enough sp to use
       if @skills_left == 0
         # set font color
         self.bitmap.font.color = Color.new(255, 0, 0)
       # if enough SP for 5 or less skill uses
       elsif @skills_left <= 5
         # set font color
         self.bitmap.font.color = Color.new(255, 255, 0)
       else
         # set font color
         self.bitmap.font.color = normal_color
       end
       # decrease font color
       self.bitmap.font.size -= 2
       # draw number how many skills left to use
       self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, @skills_left.to_s, 1)
       # increase font size
       self.bitmap.font.size += 2
     # if infinite skills left
     elsif @skills_left == -1
       # set font color
       self.bitmap.font.color = Color.new(0, 255, 0)
       # increase font size
       self.bitmap.font.size += 4
       # draw "∞" skill uses left
       self.bitmap.draw_text_full(@left_x, @left_y, 24, 20, '∞', 1)
       # decrease font size
       self.bitmap.font.size -= 4
     end
   end
 end
 #----------------------------------------------------------------------------
 # get_skills_left
 #  Gets the number of skill usages left.
 #----------------------------------------------------------------------------
 def get_skills_left
   # if skill hot skill exists
   if @skill != nil && @skill > 0
     # if SP cost is zero
     if $data_skills[@skill].sp_cost > 0
       # get basic SP cost
       sp_cost = $data_skills[@skill].sp_cost
       # if using SP Cost Mod Status
       if $tons_version != nil && $tons_version >= 6.54 &&
           $game_system.SP_COST_MOD
         # get modified cost
         sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
       end
       # infinite
       return -1 if sp_cost == 0
       # calculate skills left to use
       return @sp / sp_cost
     end
     # set flag
     return -1
   end
   # set flag
   return -2
 end
 #----------------------------------------------------------------------------
 # draw_hitem
 #  Draws the hot item display.
 #----------------------------------------------------------------------------
 def draw_hitem
   # set current variable
   @item = actor.item
   # if hot item exists
   if @item != 0
     # load bitmap
     bitmap = RPG::Cache.icon($data_items[@item].icon_name)
     # draw bitmap
     self.bitmap.blt(@hot_x+124, @hot_y+4, bitmap, Rect.new(0, 0, 24, 24))
   end
   # removes items left to use display
   draw_litem
 end
 #----------------------------------------------------------------------------
 # draw_litem
 #  Draws the items left to use display.
 #----------------------------------------------------------------------------
 def draw_litem
   # set current variable
   @items_left = $game_party.item_number(@item)
   # if hot item exists
   if @item != nil && @item > 0
     # if item exists and cannot be consumed
     if $data_items[@item] != nil && !$data_items[@item].consumable
       # set font color
       self.bitmap.font.color = Color.new(0, 255, 0)
       # increase font size
       self.bitmap.font.size += 4
       # draw "∞" items left
       self.bitmap.draw_text_full(@left_x+76, @left_y, 24, 20, '∞', 1)
       # decrease font size
       self.bitmap.font.size -= 4
     else
       # if no items left
       if @items_left == 0
         # set font color
         self.bitmap.font.color = Color.new(255, 0, 0)
       # if equal or less items left
       elsif @items_left <= 10
         # set font color
         self.bitmap.font.color = Color.new(255, 255, 0)
       else
         # set font color
         self.bitmap.font.color = normal_color
       end
       # decrease font color
       self.bitmap.font.size -= 2
       # draw number how many items left to use
       self.bitmap.draw_text_full(@left_x+76, @left_y, 24, 20, @items_left.to_s, 1)
       # increase font size
       self.bitmap.font.size += 2
     end
   end
 end
 #----------------------------------------------------------------------------
 # update
 #  Checks if HUD needs refreshing.
 #----------------------------------------------------------------------------
 def update
   # if actor doesn't exist
   if actor == nil
     # unless already drawn empty HUD
     unless @empty_hud_drawn
       # draw HUD template
       draw_basic
       # draw empty HP, SP and EXP bars
       draw_empty
       # empty HUD was drawn
       @empty_hud_drawn = true
     end
   else
     # if HUD needs refresh
     if $game_temp.hud_refresh
       # draw all data about actor
       draw_name1
       draw_level1
       draw_hp1
       draw_sp1
       draw_exp1
       draw_face1
       for i in 1..$game_party.actors.size - 1
         draw_name(i)
         draw_level(i)
         draw_hp(i)
         draw_sp(i)
         draw_exp(i)
         draw_face(i)
       end
       unless BlizzABS::Config::DIRECT_HOTKEYS
         draw_hskill
         draw_lskill
         draw_hitem
         draw_litem
       end
       # remove flag
       $game_temp.hud_refresh = nil
     else
       # draw data that needs to ve updated
       self.bitmap.font.size = 16
       test_name1
       test_level1
       test_hp1
       test_sp1
       test_exp1
       test_face1
       for i in 1..$game_party.actors.size - 1
        self.bitmap.font.size = 10
        @all_y = 60 + i *70
        test_name(i)
        test_level(i)
        test_hp(i)
        test_sp(i)
        test_exp(i)
        test_face(i)
       end
       unless BlizzABS::Config::DIRECT_HOTKEYS
         test_hskill
         test_lskill
         test_hitem
         test_litem
       end
     end
     # empty HUD wasn't drawn
     @empty_hud_drawn = false
   end
 end
 #----------------------------------------------------------------------------
 # test_name
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_name1
   # draw new name if name has changed
   draw_name1 if actor.name != @name1
 end
 #----------------------------------------------------------------------------
 # test_face
 #  Tests and draws the face.
 #----------------------------------------------------------------------------
 def test_face1
   # draw new name if name has changed
   draw_face1
 end
 #----------------------------------------------------------------------------
 # test_level
 #  Tests and draws the level.
 #----------------------------------------------------------------------------
 def test_level1
   # draw new level if level has changed
   draw_level1 if actor.level != @level1
 end
 #----------------------------------------------------------------------------
 # test_hp
 #  Tests and draws the HP.
 #----------------------------------------------------------------------------
 def test_hp1
   # draw new HP if HP or max HP have changed
   draw_hp1 if actor.hp != @hp1 || actor.maxhp != @maxhp1
 end
 #----------------------------------------------------------------------------
 # test_sp
 #  Tests and draws the SP.
 #----------------------------------------------------------------------------
 def test_sp1
   # draw new SP if SP or max SP have changed
   draw_sp1 if actor.sp != @sp1 || actor.maxsp != @maxsp1
 end
 #----------------------------------------------------------------------------
 # test_exp
 #  Tests and draws the EXP.
 #----------------------------------------------------------------------------
 def test_exp1
   # draw new SP if SP or max SP have changed
   draw_exp1 if actor.now_exp != @now_exp1
 end
 #----------------------------------------------------------------------------
 # test_name
 #  Tests and draws the name.
 #----------------------------------------------------------------------------
 def test_name(id)
   actors = $game_party.actors[id]
   # draw new name if name has changed
   draw_name(id) if actors.name != @name[id]
 end
 #----------------------------------------------------------------------------
 # test_face
 #  Tests and draws the face.
 #----------------------------------------------------------------------------
 def test_face(id)
   # draw new name if name has changed
   draw_face(id)
 end
 #----------------------------------------------------------------------------
 # test_level
 #  Tests and draws the level.
 #----------------------------------------------------------------------------
 def test_level(id)
   actors = $game_party.actors[id]
   # draw new level if level has changed
   draw_level(id) if actors.level != @level[id]
 end
 #----------------------------------------------------------------------------
 # test_hp
 #  Tests and draws the HP.
 #----------------------------------------------------------------------------
 def test_hp(id)
   actors = $game_party.actors[id]
   # draw new HP if HP or max HP have changed
   draw_hp(id) if actors.hp != @hp[id] || actors.maxhp != @maxhp[id]
 end
 #----------------------------------------------------------------------------
 # test_sp
 #  Tests and draws the SP.
 #----------------------------------------------------------------------------
 def test_sp(id)
   actors = $game_party.actors[id]
   # draw new SP if SP or max SP have changed
   draw_sp(id) if actors.sp != @sp[id] || actors.maxsp != @maxsp[id]
 end
 #----------------------------------------------------------------------------
 # test_exp
 #  Tests and draws the EXP.
 #----------------------------------------------------------------------------
 def test_exp(id)
   actors = $game_party.actors[id]
   # draw new EXP if EXP was changed
   draw_exp(id) if actor.now_exp != @now_exp[id]
 end
 #----------------------------------------------------------------------------
 # test_hskill
 #  Tests and draws the hskill.
 #----------------------------------------------------------------------------
 def test_hskill
   # draw new skill icon if assigned skill has changed
   draw_hskill if actor.skill != @skill
 end
 #----------------------------------------------------------------------------
 # test_lskill
 #  Tests and draws the lskill.
 #----------------------------------------------------------------------------
 def test_lskill
   # draw how many skills left to use if this number has changed
   draw_lskill if get_skills_left != @skills_left
 end
 #----------------------------------------------------------------------------
 # test_hitem
 #  Tests and draws the hitem.
 #----------------------------------------------------------------------------
 def test_hitem
   # draw new item icon if assigned item has changed
   draw_hitem if actor.item != @item
 end
 #----------------------------------------------------------------------------
 # test_litem
 #  Tests and draws the litem.
 #----------------------------------------------------------------------------
 def test_litem
   # draw how many items left to use if this number has changed
   draw_litem if $game_party.item_number(@item) != @items_left
 end
 #----------------------------------------------------------------------------
 # actor
 #  Returns the party leader's battler for easier reference.
 #----------------------------------------------------------------------------
 def actor
   return $game_player.battler
 end
 
end


Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 10, 2009, 03:11:44 am
You probably did something wrong so it keeps refreshing it all the time rather than refreshing only when something changes.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 12, 2009, 02:14:30 am
I'm all full of questions today.
How do I create a whole new event on a map?
All I need to know is setting up X, Y, Graphic, and Name
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 12, 2009, 03:20:34 am
Check out how I did it with drop events in Blizz-ABS.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 12, 2009, 10:00:26 am
EDIT:
Fixed that
module GameGuy
  def self.spawn_enemy(id,x,y,name,graphic)
    event = RPG::Event.new(0,0)
    event.x, event.y = x, y
    keys = $game_map.events.keys
    event.id = (keys.size == 0 ? 1 : keys.max + 1)
    event.name = name
    event.pages[0].graphic.character_name = graphic
    event.pages[0].graphic.character_hue = 0
    event.pages[0].trigger = 0
    drop = Game_Event.new($game_map.map_id, event)
    $game_map.events[event.id] = drop
    sprite = Sprite_Character.new($scene.spriteset.viewport1, drop)
    $scene.spriteset.character_sprites.push(sprite)
  end
end


But now the enemy wont appear it all on the map
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 12, 2009, 11:14:45 am
IDK. Maybe you did something wrong. There are more than 1 method involved.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on November 12, 2009, 06:27:00 pm
Ok, I'm trying to make ONLY weapons display in this menu, and each weapon separate(Instead of
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Shining Riku on November 12, 2009, 07:51:46 pm
I have all I need, I'm just not sure how to do it. I understand scripting well enough to know where to go if somebody tells me, but I can't get my SE to play during a critical hit.

I think it'd be awesome to have it in my game. If it's possible, somebody please tell me how. I'd greatly appreciate it!

And everybody else that comes here could benefit from it too. :D
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on November 12, 2009, 07:58:55 pm
There are scripts out there already like this.

Try RPG Revolution or creationasylum or something. :)

Edit:
If you /really/ wanna do it yourself...
$game_system.se_play(name_of_sound_effect_here)

Would play the sound effect.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on November 12, 2009, 08:47:33 pm
So, I'm using a view range script for my game, and I was wondering how to do the following:

The script calls a method like so:

$view_range_enemies_view(a, b, c, d, e)
Where:
a = event_id (the monster's ID)
b = the view range in tiles
c = switch thrown when player is within view range
d = self switch thrown when player is within view range
e = whether impassable tiles are taken into account (block enemy view)

Here's an example:
$view_range_enemies_view(4, 5, nil, 'A', true)

However, I use a lot of these script calls in the enemy event and I'm going to make a lot of enemy events.  Instead of having to go through each page for each event and type in the enemy's event ID for each script call, I'd like to be able to set some sort of variable that will do that for me.

I tried PK8's Self Variables script to do that.  That does the following:

self_variable(variable_id, value, operation(i.e set, add, etc.))
And to call the variable, you use: self_variable(variable_id) in a call script.

So I tried this:

self_variable('monster', 4, 0) #set variable to monster's ID which is 4
$view_range_enemies_view(self_variable('monster'), 5, nil, 'A', true)

And I get an error telling me:
Script 'Self Variables' line 127: NoMethodError occurred
undefined method for '[]=' for nil:NilClass

That points to the following line in the script:
Spoiler: ShowHide


class Interpreter
  def self_variable(id, value = nil, oper = nil)
    if @event_id > 0
      key = [@map_id, @event_id, id]
      if value != nil
        case oper
        when nil, 0, 'equal', 'set', '='                     # Setting
          $game_self_variables[key] = value   <------------------THIS LINE
        when 1, 'add', '+'                                   # Adding
          $game_self_variables[key] += value
        when 2, 'sub', 'subtract', '-'                       # Subtracting
          $game_self_variables[key] -= value
        when 3, 'mul', 'multiply', 'x', '*'                  # Multiplying
          $game_self_variables[key] *= value
        when 4, 'div', 'divide', '/'                         # Dividing
          $game_self_variables[key] /= value if value != 0
        when 5, 'mod', 'modular', '%'                        # Modulating
          $game_self_variables[key] %= value if value != 0
        end
      else
        return $game_self_variables[key]
      end
      if value != nil
        $game_map.need_refresh = true
        return true
      end
    end
  end
end



I have a feeling it's just the syntax I'm messing up on.  Any ideas?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Shining Riku on November 12, 2009, 11:05:52 pm
Thanks Aqua. I'll take a look. :D

The reason why I asked is I figured I could edit the default scripts to do the critical noises, But now I dunno ha ha  :^_^':

So i'll go looking for now. I'll keep that script sniplet you showed me in mind though (I tried using it, but I guess I don't know how to get it to use the SE I need. I can't remember if I need " " around the SE name or not)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on November 12, 2009, 11:09:36 pm
Just add it in Game_Battler 3
Where the critical stuff takes place in attact_effects or whatever it's called
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 13, 2009, 04:46:30 am
@Satoh: Don't do it like this. Instead in the refresh method you should add the items like you need them to be displayed. Then in the draw_item method just remove the quantity display.

Instead of the default loop to get all items, use this one:

data = []
(1...$data_items).each {|id|
    $game_party.item_number(id).times {data.push($data_items[id])}}


Remember to change $data_items and item_number to $data_XXXs and XXX_number depending for what you need it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on November 13, 2009, 05:08:52 am
Lol, Thanks again... I swear you fix things so easily and make it seem obvious... It's like looking back at childhood and wondering how 8 * 2 was ever a tough problem...(Ironically I always had issues with 8's... now they're the ones that come most naturally... binary and hexadecimal have changed my life.)

Eventually I'll probably find myself making a new battle system... but that's a ways off...

Thanks again.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 15, 2009, 12:58:21 pm
How would we take a screenshot and use it as a bitmap?
Its for my save system. When you save, it snaps a picture of the map, then only displays a small square of it, and the small square is where you saved.

Is this possible?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on November 15, 2009, 01:07:58 pm
I saw a save system like this before...
Either on RPG Rev or CreationAsylum.
It requires the screenshot dll

There even was a system where an image /was/ the savefile D:
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 15, 2009, 01:41:41 pm
Could you help me find it? I've been searching RRR and CreationAsylum for awhile now.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on November 15, 2009, 02:18:30 pm
http://www.rpgrevolution.com/forums/?showtopic=13382
That one is for VX.
You can take the screenshot dll from there and maybe even learn how to do it in RGSS by looking at RGSS2?
XD

I'll continue searching.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on November 15, 2009, 03:03:53 pm
If you just want a screenshot on map, look at Blizz-ABS.  That's how the pre-menu works, it takes a screenshot of the game then sets it as the background for the menu. ;)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 15, 2009, 03:09:06 pm
all it does is call Spriteset_Map, and I'm trying to do that but I'm trying to make it a small rectangle and center that rectangle on the player. I'm trying to understand spriteset_map some more.

>__> this is confusing >.<
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on November 15, 2009, 03:20:25 pm
Quote from: game_guy on November 15, 2009, 03:09:06 pm
all it does is call Spriteset_Map, and I'm trying to do that but I'm trying to make it a small rectangle and center that rectangle on the player. I'm trying to understand spriteset_map some more.

>__> this is confusing >.<


call that first, than BLT a portion of it to a variable, and save that variable to the save file...?

I can't say I'd know how to do it myself, but recently I have found block transfer to be invaluable for just about any drawing method...

Alternately you could save the transfered image to a new file and have the save files look up an image file with a corresponding name...


I regret that I'm too inexperienced to explain HOW to do any of that... but I can at least give the suggested modus operandi...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on November 15, 2009, 05:14:36 pm
You can't BLT Spriteset_Map, it's not a Bitmap. AFAIK, there's no way to do this without taking a literal screenshot or synthesizing a map on the fly.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on November 15, 2009, 07:29:35 pm
I haveth a question...

How doth one change thine global variables in thine scripts before the main processing occurreth? 

In other, modern english words:

How do I set something like &data_enemies[1].exp in the script editor instead of in a map event?  If I try to do it, it tells me the following:

undefined method [] for nil:NilClass

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Satoh on November 15, 2009, 08:20:52 pm
1. use a $ for global, not an &
2. Try adding "p $data_enemies[1].exp" on a line and see if it's producing the right info.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 15, 2009, 11:05:36 pm
I would still like to know how to do the map screenshot thing, but I have a question.
Also @aqua: the vx thing didnt have the screenshot dll in it, it simply copied some stuff from spriteset_map, but seeing how vx's rtp is way different then xp, makes it so difficult.

Anyways, how would we rotate a picture or bitmap?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on November 16, 2009, 01:58:57 am
@G_G: Dude, you can find Screenshot.dll in my Transition Pack demo, with a good demonstration of how to use it >.<

@samsonite789: The $data_BLAH stuff are loaded in Scene_Title#main. So if you want to do anything, look for where they are loaded and do your magic after they are loaded.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 16, 2009, 04:12:51 am
I did a script once that would syntesize everything in Spriteset_Map to a bitmap, but the add-blended fog and weather were causing problems so I figured it's easier to go with a screenshot script.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: samsonite789 on November 16, 2009, 10:18:53 pm
Quote from: Fantasist on November 16, 2009, 01:58:57 am
@samsonite789: The $data_BLAH stuff are loaded in Scene_Title#main. So if you want to do anything, look for where they are loaded and do your magic after they are loaded.


Rock on.  Thank you!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 16, 2009, 11:16:33 pm
@fantasist: it works great but I only want it to capture a small rectangle that surrounds the player. How would I do this?

EDIT: I got it nvm
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on November 19, 2009, 10:45:06 am
any ideas how And where i would add the battle transition in my script http://forum.chaos-project.com/index.php/topic,3183.0.html
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: SorceressKyrsty on November 21, 2009, 08:55:05 am
Hmm, not much of a scripter, but I'm wondering how I'd go about creating a static window in Battle Status that just shows the actor names.

(I say this too often)kinda like FF7, except without the 'Barrier' bars (Kinda pointless...). I'm not making an FF7 fan game, it's a parody with that system in particular. I've taken a few other systems from other FF's for it as well, but the battle/menu is FF7's mainly.

I've already moved the command window over and elimated the names from the actual Display, I just need that one box with the names in it...then I will rule the world...or something like that.

Static window creation is something I have attempted at but failed miserably. I keep back-ups for script testing of my game, but I'd rather not mess up my code completely by a simple error by floundering and guessing on my own.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on November 21, 2009, 09:38:04 am
out the top of my head
can be wrong tough because I'm no scripter :P

class Window_Battlernames < Window_Base

 def initialize
   super(0, 320, 640, 160)
   self.contents = Bitmap.new(width - 32, height - 32)  
   refresh
 end

 def refresh
   self.contents.clear
   @item_max = $game_party.actors.size
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     actor_y = i * 32 + 4
     draw_actor_name(actor, 0, actor_y)
   end
end



make sure that in "Scene_Battle 1" you add where you call out the windows:
@Name_window = Window_Battlernames.new


and under "# Dispose of windows" add
@Name_window.dispose


and under "# Update windows" add
@Name_window.update
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on November 27, 2009, 12:49:07 pm
How do we rotate images?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on November 27, 2009, 01:33:13 pm
sprite.angle = value
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 27, 2009, 02:33:15 pm
Works for sprites only, not for bitmaps.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Holyrapid on November 27, 2009, 03:09:46 pm
May i take a guess? bitmap.angle = value
Am i right? Have i learned anything about scripting?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 27, 2009, 03:15:13 pm
No, it doesn't work for bitmaps. using .angle or .angle= on a bitmap will cause an undefined method for Bitmap class error.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on December 02, 2009, 01:40:33 am
so...
say I'm using RMX-OS and say that I want to sync the clocks between the server and the clients AND i want to be able to have more or less than 1 clock cycle in a 24 hours.

ok, so It dose not seem so hard all I would need to do I request the servers current time when you log in correct? then it would be a simple matter of finding the offset in hours between the server and the client using Time.now.hour correct?.

so If I have the Time object on the client and a number that is the server client off set how do I return a time object that reflects the server's current time?

and If I can do that how do I modified it using a float that represents the # of clock cycles in 24 hours?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 02, 2009, 04:41:51 am
You can easily make a small server extension that sends the current server time to clients periodically (i.e. every second to reduce network load). Store this time into a special variable. Obviously you will need a plugin for that. I already use a format for sending the time of when PMs where sent which you can easily use for that in the server extension and the plugin. I can't remember the method name, but I think it was one of the few methods of the RMXOS module.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 07, 2009, 09:48:09 pm
How do we detect if a variable is a string?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 08, 2009, 08:12:41 am
variable.is_a?(String)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 08, 2009, 11:06:59 am
Thanks it worked, but these popped in my head as well.
How do we check to see if its a boolean, integer, integer with decimal and array?
I think array is this
variable.is_a?(Array)

Not sure about the others though
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 08, 2009, 12:10:18 pm
variable.is_a?(Float) # Float = decimal number
variable.is_a?(Integer)
variable.is_a?(Numeric) # any number
variable.is_a?(FalseClass) # or just variable == false
variable.is_a?(TrueClass) # or just variable == true
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on December 08, 2009, 03:58:55 pm
in short you can tell if a object is an instance of any class with

object.is_a?(Class)


also

object.kind_of?(Class)


dose the same thing

it is worth noting that the is_a? and the kind_of? methods return true even if the object is only an instance of a subclass of Class

the

object.instance_of?(Class)


method is slightly different in that it only returns true if it is a direct instance of Class

ie.


module Foo
end
class Boo < Object
  include Foo
end
class Goo < Boo
end

obj = Goo.new
p obj.is_a? Goo       # true
p obj.is_a? Foo      # true
p obj.is_a? Boo      # true
p obj.is_a? Object  # true
p obj.is_a? Hash    # false
p obj.instance_of? Goo  # true
p obj.instance_of? Boo  # false
p obj.instance_of? Object  # false
p obj.instance_of? Foo  # false

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 08, 2009, 07:47:05 pm
Question. How do I, if possible, alias a method between the method. That made no sense.
Example:
So example here's some code.
Class Test
  def main
    stuff_here
    more_stuff_here
  end
end

But I want to add stuff to that method in between stuff_here and more_stuff_here.
Class Test
  def main
    stuff_here
    other_stuff_here
    more_stuff_here
  end
end

Is it possible to accomplish that by aliasing?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 09, 2009, 02:31:48 am
Not possible. Aliasing goes before or after and you can't put it in between.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 09, 2009, 01:31:23 pm
thanks for the answer blizzard

I'm making a title screen for GAX. And he wants the map as the background. Done. But he also wants events to execute while its on the map. How would I do this?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on December 09, 2009, 01:38:31 pm
QuoteI'm making a title screen for GAX. And he wants the map as the background. Done. But he also wants events to execute while its on the map. How would I do this?


got also as far to add a map in the background. but failed to get stuff going on the map.
so if you figure it out can you plzz share it?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 09, 2009, 01:49:09 pm
I figured it out. I'm going to ask GAX first if he cares if its publically released. I think a map as background would be interesting. Eh give me a few hours so I ca ask him when he gets on.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 09, 2009, 03:15:04 pm
Better use a map as title screen. Seph made a script like that.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 09, 2009, 03:18:08 pm
Its okay Blizz, I already got it. Shows map as background, and events work and everything.
And ew, Seph's stuff uses SDK.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 09, 2009, 04:12:22 pm
Then make it better / an SDK-free version. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on December 09, 2009, 05:18:45 pm
# By Murasame assassin 
begin
$data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
  $defaultfonttype = "Tahoma"
  $defaultfontsize = 22
  $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    $game_party.setup_starting_members
    $game_map.setup($data_system.start_map_id)
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    $game_map.autoplay
    $game_map.update
    $scene = Scene_Map.new
  Graphics.freeze
  while $scene != nil
    $scene.main
  end
  Graphics.transition(20)
rescue Errno::ENOENT
  filename = $!.message.sub("No such file or directory - ", "")
  print("File #{filename} not found.")
end


Tada...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 09, 2009, 05:20:40 pm
I already have it made >__> why werent you on an hour ago XD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 15, 2009, 10:17:35 pm
Okay I'm making a mouse plugin for Babs, really what I need to know is how to detect if the mouse is on an impassible area or an event
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 16, 2009, 04:28:50 am
Better check the sprite. Or you can translate the mouse coordinates into pixel coordinates * 4 and using $game_map.display_x and $game_map.display_y you can match it with event real_x and real_y considering that an event side is 128x128 in that case.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on December 16, 2009, 06:48:00 am
how can I check the exp that was needed for the current lvl.
example:

Character is lvl 25
got a total of 500 exp

I want to know how I can check how much exp was needed to get to lvl 25 (for example 475 exp)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 16, 2009, 09:49:09 am
This has the EXP needed for that level.

@exp_list[level] # inside Game_Actor
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on December 16, 2009, 10:18:46 am
probably because of my crap scripting skills:

undefined method '[]' for nil:NilClass
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 16, 2009, 10:22:14 am
place this code in your script
class Game_Actor
  attr_accessor :exp_list
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on December 16, 2009, 10:31:46 am
did not work :S
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 16, 2009, 10:39:00 am
Works for me. You have to place this in a new script or in yours.
class Game_Actor
  attr_accessor :exp_list
end

Call the actors exp with this
$game_actors[id].exp_list[level]
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on December 16, 2009, 10:41:14 am
nvm.. just noob scripting on my part
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 19, 2009, 02:46:37 am
I know we can use dll's in RGSS but can we use dll's coded in c#? If so how do we call the dll and call a method? I want to experiment with something.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 20, 2009, 09:31:34 am
You need to "Add a reference" in your C# project to the DLL.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 14, 2010, 07:59:26 am
ok im trying to move the placement of the minimap in  blizz-ABS i moved it before but cant remember how

edit:might have helped to say it was blizz-ABS minimap
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 18, 2010, 04:15:18 am
Change x and y coordinates in the class Minimap.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 18, 2010, 12:35:33 pm
redo post: ok i have a question i see how you can windows visible depending on a command windows index
like this @item_window1.visible = (@equip.index == 0) (so now @item_window1 is only visible when @equip.index == 0) can you use this to change @help_window.set_text depending on the command window or do i just need to use the case branch
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on January 23, 2010, 10:19:51 pm
is
x = Sprite.src_rect.x

the same thing as
x = Sprite.ox


and is
Sprite.src_rect.x = x

the same as
Sprite.ox = x
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on January 24, 2010, 04:43:16 pm
Having some troubles with this sprite class. Here's the code I have for the update method.
    self.bitmap.clear
    width = self.bitmap.width
    height = self.bitmap.width
    twidth = self.bitmap.text_size(@text).width
    self.bitmap.font.color.set(255, 255, 255)
    self.bitmap.fill_rect(self.x, self.y, width, height, Color.new(0, 0, 0))
    if @over
      color = Color.new(0, 0, 200)
      self.bitmap.fill_rect(self.x+1, self.y+1, width, height, color)
    else
      color = Color.new(255, 255, 255)
      self.bitmap.fill_rect(self.x+1, self.y+1, width, height, color)
    end
    self.bitmap.font.color = Color.new(0, 0, 0)
    self.bitmap.draw_text(0, 16, width, height, @text, 0)

It draws the blue rectangle if @over is true. And a white rectangle if @over is false. It does what its supposed to do. The only problem is it doesn't draw the text. Any ideas?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 25, 2010, 06:45:29 am
height = self.bitmap.width
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: SorceressKyrsty on February 06, 2010, 08:34:43 am
Quote from: Jackolas on November 21, 2009, 09:38:04 am
out the top of my head
can be wrong tough because I'm no scripter :P

class Window_Battlernames < Window_Base

 def initialize
   super(0, 320, 640, 160)
   self.contents = Bitmap.new(width - 32, height - 32)  
   refresh
 end

 def refresh
   self.contents.clear
   @item_max = $game_party.actors.size
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     actor_y = i * 32 + 4
     draw_actor_name(actor, 0, actor_y)
   end
end



make sure that in "Scene_Battle 1" you add where you call out the windows:
@Name_window = Window_Battlernames.new


and under "# Dispose of windows" add
@Name_window.dispose


and under "# Update windows" add
@Name_window.update



I asked for this code a long time ago but I couldn't get this to work. I got a syntax error, and the game started up when I added another end to the code, but no window showed up.
This is the LAST thing I need to finish the coding for my game. Other than Limit Break but I can't get that to work at all. Oh well.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 11, 2010, 05:40:39 pm
Horizontal menus?

How would I go about making one? (I'm getting bored of vertical selectable menus)
And how would I make them images rather than text?
And lastly, how would I change the size of the image selected, so it LOOKS like it zooms in?
And I'm a noob so any help would be appreciated :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on February 11, 2010, 11:16:03 pm
take a look at my collapsing cms or asantear battle system both contain a horizontal menu class so you can see how it is done
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 12, 2010, 05:41:53 am
Wow my eyes hurt now >.<
I'll have to have a major sift through the horizontal setup sections and see whats what
Cheers tho :D
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 13, 2010, 11:53:46 am
[code]Its not really help I need its just a matter of which one is more efficient?
[code]
loop do
   Graphics.update
   Input.update
   update
   if $scene != self
       break
   end
end

or
while $scene == self
   Graphics.update
   Input.update
   update
end


The 2nd one is shorter and so far it seems to be working the same as the other one.[/code][/code]
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on February 14, 2010, 05:43:34 am
I prefer the first way because I can add more abort-loop conditions more nicely. It's pretty much the same in the end.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 14, 2010, 11:58:32 am
Any way to center text within a menu/command window?
Any help would be appreciated :D
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 14, 2010, 12:00:32 pm
draw_text(x, y, width, height, text, 1)


Example, I'll draw "Hello". It'll center it between the width.
draw_text(0, 32, 320, 32, "Hello", 1)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 14, 2010, 12:18:26 pm
And that works in a command menu?
Where would I put it in main? thats IF i put it in main.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on February 14, 2010, 12:22:52 pm
you would put it in here like this this

change ur call in main from @command_window = Window_Command.new to
@command_window = Window_Command2.new


#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    # Compute window height from command quantity
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index],1)
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 14, 2010, 12:31:22 pm
Quote from: nathmatt on February 14, 2010, 12:22:52 pm
you would put it in here like this this

change ur call in main from @command_window = Window_Command.new to
@command_window = Window_Command2.new


#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command2 < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     width    : window width
 #     commands : command text string array
 #--------------------------------------------------------------------------
 def initialize(width, commands)
   # Compute window height from command quantity
   super(0, 0, width, commands.size * 32 + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i, normal_color)
   end
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #     color : text color
 #--------------------------------------------------------------------------
 def draw_item(index, color)
   self.contents.font.color = color
   rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index],1)
 end
 #--------------------------------------------------------------------------
 # * Disable Item
 #     index : item number
 #--------------------------------------------------------------------------
 def disable_item(index)
   draw_item(index, disabled_color)
 end
end



I actually define my menu window IN main like so:


   s1="Items"
   s2="Skills"
   s3="Equip"
   s4="Status"
   s5="Options"
   s6="Quit"
   s7="Cancel"
   @menu_win=Window_Command.new(120, [s1, s2, s3, s4, s5, s6, s7])
   @menu_win.x=260
   @menu_win.y=60
   @menu_win.height=260
   @menu_win.index=@menu_index


Any way to change it from inside that?



EDIT::
Nevermind, I realise what you did there lol, thanks for the help again :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 17, 2010, 10:26:42 pm
How do we round floats up or down?

I'm aware of the .round method, but if its below .5 it'll round down. If its above 0.5 it'll round up. There are certain times where I want it to just round down, or round up.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on February 17, 2010, 10:32:07 pm
try .floor and .ceiling.  Those should be the terms.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 17, 2010, 10:35:36 pm
The ceiling one didn't work but floor did.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on February 17, 2010, 10:50:15 pm
loot in the rmxp help file at the number classes there is quite a lot of info there.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 17, 2010, 10:52:05 pm
Ah found it. It was .ceil

Also can someone explain what .abs actually does? Maybe give me some examples?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on February 17, 2010, 10:53:25 pm
It's .ceil

Don't you know what absolute value is? O.o
It'll return the positive value of a number... in simplest terms :P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on February 18, 2010, 12:35:20 am

(1).abs     #1
(-1).abs    #1
(10).abs    #0
(-10).abs   #10

the absolute value of X (or |X|) is simply the positive distance from 0 on the number line
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 18, 2010, 09:41:37 pm
Quick file question.
I'm using this to read all lines from a text file.
lines = []
file = File.open('Data.txt')
file.each_line{|line| lines.push(line)
file.close
for i in lines
 p i
end


Which works and prints all 5 lines. Except the first 4 lines print the line plus \n. Anyway to remove this?

I also did another test with it with integers.
lines = []
file = File.open('Data.txt')
file.each_line{|line| lines.push(line.to_i)
file.close
for i in lines
 p i
end


And this time it just printed the numbers with no \n. Any idea?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on February 18, 2010, 11:37:29 pm
\n is the new line char. try using gsub! to remove it
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on February 19, 2010, 02:42:05 am
file = File.open('Data.txt', 'r')
lines = file.readlines
file.close
lines.each {|line| p line}


:)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 19, 2010, 07:59:30 am
Both ways worked. xD

However blizz is the simplest. I'm gonna have to go with his. However *double level's up*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on February 19, 2010, 08:30:01 am
There's also

s.chomp! # removes whitespace at end of string
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on February 19, 2010, 08:42:37 am
lstrip / rstrip / strip can be useful as well. :3 I'm just not sure if they are named the same in Ruby as in other languages.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on February 20, 2010, 12:41:19 pm
ok im trying to make a small script def that you will give it the current exp of a passive type skill and will return the lvl and exp needed i baes my code off this
Quote from: Jackolas on October 22, 2009, 04:46:33 am
Harder than I thought it was gone be :^_^':
best i could do i a short time.

To calculate exp needed to lvl:
L= LVL
B= Base
I= Inflation
E= EXP

E = B * ((L + 4) ^ (2,4 + I / 100)) / (5 ^ (2,4 + I / 100))

so the exp needed from lvl 5-6 when base and inflation are both 10 is:
10*((5+4)^(2,4+10/100))/(5^(2,4+10/100)) = 56,56854
looking in the rmxp actor exp table it says 56

yes i know they are a litle bid off...
but i think that RMXP is not calculating with numbers behind the ,
so it will always round the numbers down

im getting a syntax error on this  @e = 25 * ((lvl + 4) ^ (2,4 + 35 / 100)) / (5 ^ (2,4 + 35 / 100))
  def get_lvl(lvl,exp,expneeded)
   @e = 25 * ((lvl + 4) ^ (2,4 + 35 / 100)) / (5 ^ (2,4 + 35 / 100))
   if exp >= @e
     lvl += 1
   end
   expneeded = @e - exp
   return lvl,expneeded
 end

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on February 22, 2010, 02:36:44 am
In programming you never use a decimal comma. You ALWAYS use a decimal dot.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on February 22, 2010, 09:27:39 am
Quote from: Champion Blizzard on February 22, 2010, 02:36:44 am
In programming you never use a decimal comma. You ALWAYS use a decimal dot.


silly europeans, not following america's vastly superior lead :V
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on February 22, 2010, 10:25:55 am
k fixed that but now im having another problem the lvl is increasing to much when lvl 1 you need 25 exp but when i make exp 25 the lvl goes up to 5 & expneeded  goes to 10

edit got it to work

class Bitmap
 
  def get_lvl(exp,x,y)
    lvl = 1
    while exp >= get_exp_list(lvl)
      lvl += 1
    end
    slvl = lvl - 1
    expneeded = get_exp_list(lvl) - exp
    self.draw_text(x, y, 120, 32, slvl.to_s)
    self.draw_text(x, y+32, 120, 32, exp.to_s+'/'+get_exp_list(lvl).to_s)
  end
  def get_exp_list(lvl)
    @exp_list = Array.new(101)
    @exp_list[1] = 0
    pow_i = 2.4 + 35 / 100.0
    for i in 2..100
      if i > 99
        @exp_list[i] = 0
      else
        n = 25 * ((i + 3) ** pow_i) / (5 ** pow_i)
        @exp_list[i] = @exp_list[i-1] + Integer(n)
      end
    end
    return @exp_list[lvl]
  end
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on February 22, 2010, 10:33:27 am
Quote from: Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:


For writing, I stand by this as the proper form:
Quote
1 234 567.89

which should read as one-million, two-hundred and thirty-four thousand, five-hundred and sixty-seven and eighty-nine hundredths.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Trainer Zydragon on February 22, 2010, 11:03:04 am
Quote from: fugo ad te, pikachu! on February 22, 2010, 10:33:27 am
Quote from: Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:


For writing, I stand by this as the proper form:
Quote
1 234 567.89

which should read as one-million, two-hundred and thirty-four thousand, five-hundred and sixty-seven and eighty-nine hundredths.


See us British would write that as 1,234,567.89 :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: fugibo on February 22, 2010, 01:48:01 pm
Quote from: Zydragon on February 22, 2010, 11:03:04 am
Quote from: fugo ad te, pikachu! on February 22, 2010, 10:33:27 am
Quote from: Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:


For writing, I stand by this as the proper form:
Quote
1 234 567.89

which should read as one-million, two-hundred and thirty-four thousand, five-hundred and sixty-seven and eighty-nine hundredths.


See us British would write that as 1,234,567.89 :)


I'm American. We do, too. I prefer 1 234 567.89, though. The commas are used for readability. Spaces work just as well.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on February 22, 2010, 03:36:05 pm
ok im any help on the most effective way to make passive type (mining,fishing,etc... )skills i thought about sort of a copy of game actor but not sure 
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on February 23, 2010, 02:14:31 am
Quote from: fugo ad te, pikachu! on February 22, 2010, 09:27:39 am
Quote from: Champion Blizzard on February 22, 2010, 02:36:44 am
In programming you never use a decimal comma. You ALWAYS use a decimal dot.


silly europeans, not following america's vastly superior lead :V


Lulz
That's because you had the first computers and you said it's gonna be a dot. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Zeriab on February 23, 2010, 07:05:37 am
Quote from: Champion Blizzard on February 19, 2010, 02:42:05 am
file = File.open('Data.txt', 'r')
lines = file.readlines
file.close
lines.each {|line| p line}


:)


I suggest using a block since File provides error handling in that case. It for example ensures that the file stream will be closed.
File.open('Data.txt', 'r') {|file|
 lines = file.readlines
 lines.each {|line| p line}
}


*hugs*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on February 23, 2010, 08:20:08 am
I prefer begin-rescue blocks since you can catch the error. :3
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Zeriab on February 23, 2010, 01:19:40 pm
You can perfectly fine still catch the error.
It still raises errors it gets.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on February 26, 2010, 09:23:09 am
ok im trying to figure out how i should set up my skill script right now it wait 5 then takes the base stat & multiplies it my the number of times it loops then adds the atk so ur weapon so ur weapon effects the speed  till it equals the given amount but what im what i need is by how much should the base stat increase each lvl right now it starts at 50 than increases by 5 every lvl
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on March 25, 2010, 01:26:11 pm
ok i managed to get the path finder from Blizz-ABS with creates an array of directions to get to the targeted x & y my problem is figuring out how to get the player to move using each command in the array i tried casing the direction to move in the correct direction then i shifted the array to remove the already moved direction from the array the problem is it goes through the array to fast i need it to wait for the move to be completed remove it from the array then do the next 1

edit: figured it out just had to check if player was moving if he wasn't then call the method again
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 29, 2010, 12:05:28 am
I'm assuming this just has to do with math because it most likely does. What I want is to draw an area around the player like in a tactic battle system. Something like this.

Spoiler: ShowHide
(http://img8.imageshack.us/img8/5254/aream.png)


That area would be drawn if the player's move count was 3. The red square is the player and the blue squares are where he can walk.
I'm trying to figure out an equation to draw so many squares like that according to move count.

If anyone could help I would be very thankful. Its for a small mini-game I'm working on.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on March 29, 2010, 12:49:02 am
that area is defined by abs(a.x-o.x) + abs(a.y-o.y) <= r, where a is a tile, o is the center, and r is the radius.  One way to do it is using that equation.

Another way is to go from one end to the other, increasing the amount of tiles by 2 each time until you hit the center, then decreasing by 2 each time.  it's simpler and doesn't need an equation.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on March 31, 2010, 11:13:08 am
is there a way to check if a message is being displayed from the show text command in Interpreter ?
edit: found it $game_temp.message_window_showing
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 01, 2010, 08:35:09 pm
Okay how would we use a dll made in C# in a script? I'm trying a few things out. Any help is appreciated.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 06, 2010, 11:02:41 am
You can't. Ruby can only use libraries made in C (AFAIK) and C# DLLs are bound to .NET so you can't use them out of two reasons.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jragyn on April 08, 2010, 01:08:15 am
Congratulations, Blizzard on retiring from rmXP!
Hope life goes in the way you want, away from this game making software lol.

But, erhm, to whomever can answer:

Whats the difference between this:

if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end


and this:...?

 @command_window.disable_item(4) if $game_system.save_disabled


Is the First like...bad coding?
I've personally discovered that using the latter when possible seems easier to manage...
but does it...really make a difference in some way?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 08, 2010, 02:39:41 am
There is no difference. It's just in the first statement you can add more commands under that conditional branch while in the second you can't.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: momentai1018 on April 10, 2010, 03:42:59 pm
Hi i was wondering if anyone can make this script compatible with blizz abs cause  i can't seem to get it. it's not mine but i want to be able to use it, it's a swimming script and it worked before i added blizz abs


Spoiler: ShowHide

#==============================================================================#
#  Swimming!  v 1.8                                                          #
#  By: ToriVerly @ hbgames.org                                                    #
#==============================================================================#
#  Intructions:                                                                #
#------------------------------------------------------------------------------#
=begin
Paste this script above Main and below everything else.
For each character you will have swimming, make a swimming sprite that has the
same name as the character but ending with "_swim" and another with "_dive" if
DIVE_GRAPHIC is true.
   Example: "001-Fighter01_swim.png"

If TREAD_ANI = true, the character will be animated while in water when they are
not moving.  Hence a treading water effect.  Set it to false if you don't want
the effect.

Set the WATER constant to the terrain tag ID of your water tiles or whatever tile
you want to swim through.  When you place non water tiles over water tiles (in
a higher layer), the non water tiles will need to have a terrain tag that is
different than WATER and not 0 or else the characters is swim through it.

   IMPORTANT--->make sure your water tile is passable.

If you want the ability to swim to depend on a switch, set SWIM_SWITCH to the ID
of the game switch you're using. If you don't want to use a switch, set it to nil.
Similarily, set SWIM_ITEM, SWIM_ARMOR or SWIM_WEAPON to the ID of the item, armor
or weapon required for swimming and nil if there is none.  You can even set more
than one condition!

The SWIM_SE will play every time you jump into water.  If you don't want a sound,
set DIVE_SOUND_OFF to true.

The SNEAK_KEY and DASH_KEY functions can be set for Mr.Mo's ABS or an input
letters script.  If you don't have such an input system but have another dashing
and/or sneaking system/script, change them to Input::YourKey.
    Example: Input::X
             Input::Y
If you don't have dashing or sneaking at all, set them to nil.
WATER_DASHING is self explanitory.  If you want to dash in water, set it to true.
If DROWNING is on, the player will have about three seconds to get out of water
before they die (if swimming isn't available). If it is off, water will just be
impassable.
Enjoy!
=end
#------------------------------------------------------------------------------#
WATER = 3
SWIM_SWITCH = nil
SWIM_ITEM = nil
SWIM_ARMOR = nil
SWIM_WEAPON = nil
SNEAK_KEY = nil #Input::Letterres["Z"] for Mr.Mo's ABS or input letters script
DASH_KEY = nil #Input::Letters["X"] for Mr.Mo's ABS or input letters script
SWIM_SE = "022-Dive02"
DROWN_SE = "021-Dive01"
DROWNING = false
WATER_DASHING = false
DIVE_SOUND_OFF = false
DIVE_GRAPHIC = true
TREAD_ANI = true
#------------------------------------------------------------------------------#

#==============================================================================#
# Game_Player                                                                  #
#------------------------------------------------------------------------------#
# Modifies the Game_Player class initialization and updating                   #
#==============================================================================#
class Game_Player < Game_Character
 attr_reader   :swim
 attr_reader   :swimming?
 attr_reader   :swim_count
 alias swim_init initialize
 def initialize
   @swim = false
   @drown_count = 0
   @swim_count = 0
   swim_init
 end
 alias swim_update update
 def update

   # Checks if swimming is triggered
   if DROWNING == true
   return jump_in if facing?(WATER, 'any', 1) and !@swim and moving?
   # Drowns if it is not available
   drown if !swim_available? and on?(WATER)
   elsif DROWNING == false
   return jump_in if facing?(WATER, 'any', 1) and !@swim and moving? and swim_available?
   end
   
   # Jumps out of water at shore
   jump_forward if !on?(WATER) and !facing?(WATER, 'any', 1) and !facing?(WATER, 'any', 2) and @swim and moving?
   # Returns original settings when out of water
   revert if @swim and !on?(WATER)
   
   # Refreshes swimming state
    swim_refresh if swimming?
 swim_update
end

   # Makes water impassable when swimming isn't available
 alias mrmo_swim_game_player_passable passable?
 def passable?(x, y, d)
   # Get new coordinates
   new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
   new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
   # Check if it water tag
   return false if $game_map.terrain_tag(new_x,new_y) == WATER and !swim_available? and DROWNING == false
   # Old Method
   mrmo_swim_game_player_passable(x,y,d)
 end
#------------------------------------------------------------------------------#
# Custom Methods                                                               #
#------------------------------------------------------------------------------#
 # Checks swimming availability
 def swim_available?
    if SWIM_SWITCH != nil
     return true if $game_switches[SWIM_SWITCH]
     return false if !$game_switches[SWIM_SWITCH]
    end
    if SWIM_ITEM != nil
      return true if $game_party.item_number(SWIM_ITEM) != 0
      return false if $game_party.item_number(SWIM_ITEM) == 0
    end
    if SWIM_ARMOR != nil
      return true if $game_party.actors[0].armor1_id == SWIM_ARMOR
      return true if $game_party.actors[0].armor2_id == SWIM_ARMOR
      return true if $game_party.actors[0].armor3_id == SWIM_ARMOR
      return true if $game_party.actors[0].armor4_id == SWIM_ARMOR
      return false
    end
    if SWIM_WEAPON != nil
      return true if $game_party.actors[0].weapon_id == SWIM_WEAPON
      return false
    end
    return true
  end
   
 # Jumps in the water if swimming is triggered
 def jump_in
   @swim = true
   unless DIVE_SOUND_OFF
    @play_sound = true
   end
  if DIVE_GRAPHIC == true
   @character_name = $game_party.actors[0].character_name
   @character_name = $game_party.actors[0].character_name + "_dive"
  end
  jump_forward if facing?(WATER, 'any', 1)
 end
 
 # Swimming setup
 def swim_refresh
     get_speed if moving?
     if !moving?
       @character_name = $game_party.actors[0].character_name
       @character_name = $game_party.actors[0].character_name + "_swim"
     end
     if @play_sound and !moving?
        Audio.se_play("Audio/SE/" + SWIM_SE , 80, 100)
        @play_sound = false
     end
        @swim = true
     if TREAD_ANI == true
        @step_anime = true
      end
    end
   
 # Drowning
 def drown
   @move_speed = 0.1
   if @drown_count <= 120
     #jump_in if !@swim
     @drown_count += 1
       if @drown_count %40 == 0
         Audio.se_play("Audio/SE/" + DROWN_SE, 80, 100)
       end
     elsif @drown_count >= 120
     @character_name = ""
     @drown_count = 0
     Audio.se_play("Audio/SE/" + SWIM_SE, 80, 100)
    $scene = Scene_Gameover.new
   end
 end
 
 # Reverts original settings when out of water
 def revert
     @character_name = $game_party.actors[0].character_name
     @swim = false
     @drown_count = 0
       unless dashing? or sneaking?
        @move_speed = 4
        @move_frequency = 6
       end
      if TREAD_ANI == true
      @step_anime = false
    end
  end
 
 # Determines Speed (Swim Leveling)
 def get_speed
   # Gets Swim Count
     @swim_count += 0.05
   case @swim_count
   when 0.05
     @swim_speed = 1
     @move_frequency = 1
   when 100
     @swim_speed =  2
     @move_frequency = 1
   when 250
     @swim_speed = 3
     @move_frequency = 1
   when 750
     @swim_speed = 4
     @move_frequency = 1
   when 2000
     @swim_speed = 5
     @move_frequency = 1
   end
   @move_speed = @swim_speed
     if WATER_DASHING == true
         if DASH_KEY != nil and Input.press?(DASH_KEY) and !sneaking?
          @move_speed = @swim_speed + 1
          @move_frequency = 6
         end
         if SNEAK_KEY != nil and Input.press?(SNEAK_KEY) and !dashing?
          @move_speed = @swim_speed -1
          @move_frequency = 2
        end
      end
    end
 
# Jumps forward
 def jump_forward
 case @direction
     when 2
       jump(0, 1)
     when 4
       jump(-1, 0)
     when 6
       jump(1, 0)
     when 8
       jump(0, -1)
     end
   end
 # Jumps backward
 def jump_backward
   case @direction
     when 2
       jump(0, -1)
     when 4
       jump(1, 0)
     when 6
       jump(-1, 0)
     when 8
       jump(0, 1)
     end
   end

 # Checks if dashing
 def dashing?
   return true if DASH_KEY != nil and Input.press?(DASH_KEY)
   return false if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
 end
 # Checks if sneaking
 def sneaking?
   return true if SNEAK_KEY != nil and Input.press?(SNEAK_KEY)
   return false if DASH_KEY != nil and Input.press?(DASH_KEY)
 end
 # Checks if swimming
 def swimming?
   return true if on?(WATER) and @swim
 end
 # Checks if player is on a terrain tag
 def on?(tag)
   return true if $game_map.terrain_tag($game_player.x, $game_player.y) == tag
 end
 # Checks if player is facing a terrain tag
 def facing?(tag, dir, dist)
   case dir
    when 2
      if $game_player.direction == 2
       tag_x = $game_player.x
       tag_y = $game_player.y + dist
     end
    when 4
      if $game_player.direction == 4
       tag_x = $game_player.x - dist
       tag_y = $game_player.y
      end
    when 6
      if $game_player.direction == 6
       tag_x = $game_player.x + dist
       tag_y = $game_player.y
      end
    when 8
      if $game_player.direction == 8
       tag_x = $game_player.x
       tag_y = $game_player.y - dist
     end
    when 'any'
      if $game_player.direction == 2
       tag_x = $game_player.x
       tag_y = $game_player.y + dist
     end
      if $game_player.direction == 4
       tag_x = $game_player.x - dist
       tag_y = $game_player.y
     end
      if $game_player.direction == 6
       tag_x = $game_player.x + dist
       tag_y = $game_player.y
     end
     if $game_player.direction == 8
       tag_x = $game_player.x
       tag_y = $game_player.y - dist
     end
   end
  return false if tag_x == nil or tag_y == nil
  return true if $game_map.terrain_tag(tag_x, tag_y) == tag
end
end
#------------------------------------------------------------------------------#
# By ToriVerly
# Thanks to Mr.Mo for help with my passability issues and to Chaosg1 for my intro
# into scripting :)
#------------------------------------------------------------------------------


Added code and spoiler tags ~ G_G
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: WhiteRose on April 10, 2010, 03:51:59 pm
I'm afraid I can't help, as I'm not much of a scripter, but I do have a few recommendations that will make sure your request is filled quicker:
1. Make sure you use the "Search" function before you post; I don't know if you did already, but I do recall a swimming script being mentioned before. I don't remember if it worked or not, though.
2. Once you have confirmed that there is no solution already available, start a new thread clearly outlining what scripting work you would like completed. In this case, sorting out the compatibility between your swimming script and Blizz-ABS.
3. Use code tags. It'll make your script easier to read, use and edit.

If you follow these things, I'm sure that one of our expert scripters such as Ryex or Game_Guy will come give you a hand. :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 12, 2010, 02:46:55 am
This is a topic for scripters and GENERAL scripting questions. If you have problems with a specific script, post it in the Script Troubleshooting section.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on April 13, 2010, 08:32:56 am
question.... (kinda got myself in over my head again:S)
I want kinda create a rather complicated array (think that's it called)

for example:
random for specific actor at a level must return a number

so I will end up wit:
for actor A
 on lvl 1 return 2
 on lvl 2 return 6
 etc...
for actor B
 etc...


now I want a way that I configure this (as small as poss) and than read it from some point in my script
I hope I make sense :S

i seen scripts that use it the configure this way:
  something = {
 1 => [  [1,2],[2,6],[3,8],[4,10],[etc],
      ],
 2 => [  [1,3],[2,5],[3,7],[4,9],[etc],
      ],
 } #end

what I kinda like because its small (not a lot of lines)
but I know no way to read it. (and the script I found this in is incomplete, accidental removed a part and can't find the script any more :S)
ofc it doe's not have to be like that 1... as long as its 1 that works
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: (Hexamin) on April 13, 2010, 11:14:28 am
Hmmm... something like...

$game_party.actors[0] = index
Random_Stuff[index] = player_lvls
player_lvls[index.level] # returns random number


or...


Random_Stuff[$game_party.actors[0]][$game_party.actors[0].level] # returns random number


Maybe?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on April 13, 2010, 11:27:54 am
hmm.. think its my lack of explaining skill :S

retry:

I want somehow in a script a predetermined number that fist at a specific lvl and actor.

for example of the following config:
 something = {
 1 => [  [1,2],[2,6],[3,8],[4,10],[etc],
      ],
 2 => [  [1,3],[2,5],[3,7],[4,9],[etc],
      ],
 } #end

if I than ask for lvl 3 in actor 1 I need to get 8 in return (as an example)
hope that makes it more clear

atm i'm trying to work around it by something like:
  def self.something(id)
   case id
     when 1: return [2,6,8,10,etc...]
     when 2: return [3,5,7,9,etc...]
     end
   return [0]
 end

and than somehow request the 4th number when ID is 1 (witch will result in 10 ofc)
atm am failing :S

Edit:
Nvm... fixed it myself
something(id)[place] = number

so
something(01)[4] = 10
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Valdred on April 13, 2010, 03:55:01 pm
I got a question. How do I show an Animation trough scripting?
I don't mean the charset/stop animation way. You know the animations like "hit" and so.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 13, 2010, 04:39:13 pm
charactor.animation_id = the animation id caractor is the charactor so say $game_player.animation_id = 1 would use the animation 1 on the player

edit: i think ruby doesn't like me how does @players.any? {|key, value| value.username == value.username} = false?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 13, 2010, 05:38:56 pm
Quote from: Jackolas on April 13, 2010, 08:32:56 am
question.... (kinda got myself in over my head again:S)
I want kinda create a rather complicated array (think that's it called)

for example:
random for specific actor at a level must return a number

so I will end up wit:
for actor A
  on lvl 1 return 2
  on lvl 2 return 6
  etc...
for actor B
  etc...


now I want a way that I configure this (as small as poss) and than read it from some point in my script
I hope I make sense :S

i seen scripts that use it the configure this way:
  something = {
  1 => [  [1,2],[2,6],[3,8],[4,10],[etc],
       ],
  2 => [  [1,3],[2,5],[3,7],[4,9],[etc],
       ],
  } #end

what I kinda like because its small (not a lot of lines)
but I know no way to read it. (and the script I found this in is incomplete, accidental removed a part and can't find the script any more :S)
ofc it doe's not have to be like that 1... as long as its 1 that works


Like this.
array = Random_stuff[actor_id]
# array then = [  [1,2],[2,6],[3,8],[4,10] ]

Then go from there.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jackolas on April 13, 2010, 05:46:30 pm
got it already fixed Game_guy.
could not solve it one way so I approached the problem from an other side.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Valdred on April 14, 2010, 11:49:58 am
Quote from: nathmatt on April 13, 2010, 04:39:13 pm
charactor.animation_id = the animation id caractor is the charactor so say $game_player.animation_id = 1 would use the animation 1 on the player

edit: i think ruby doesn't like me how does @players.any? {|key, value| value.username == value.username} = false?


It's probably just me being stupid, but I'm not sure what you mean. I pasted the first one, it did nothing  :haha:.
Then I tried the second one, it crashed. Note that it's called from inside the Game_Player class.


EDIT: Just me being stupid as I said. Solved it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 14, 2010, 09:20:18 pm
what would be the best way to see if a hash has changed
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on April 14, 2010, 09:30:26 pm
Quotewhat would be the best way to see if a hash has changed


Just make an event with the script call

p NAMEOFHASH[KEY]


That should work.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 15, 2010, 01:12:51 am
not exactly what i ment i wanted to update somthing everytime the hash changed
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 15, 2010, 02:55:08 am
Store a copy of the hash (via .clone) and compare it to the original. If they are not equal, the hash has changed. Store the new hash and execute your additional code.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 15, 2010, 08:53:22 am
i tryed storing in a var but didn't use .clone i will try that

edit that worked thx

i have a new question im trying to open a store a defined class in an array but i keep getting a undefined method push for nil class before you ask yes i did turn my array into an array

def window(obj) 
  s = obj.new
  window.push(s)
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Valdred on April 26, 2010, 10:33:15 am
I have a little question. How do I read the name of an event? I know it's somewhere in the datafiles, and I have tried printing them to see if I find what I need. However, I did not find it. Anyone knows?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 27, 2010, 07:32:39 am
if you want to read the name of an event use say $game_map.events[the id of the event].name
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 27, 2010, 08:01:54 am
Won't work because Game_Event instances don't have name defined. The contained class RPG::Data_Event in Game_Event#event has the name.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Valdred on April 27, 2010, 10:30:59 am
So, for example: $game_map.events[2].RPG::Data_Event.name
?

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on April 27, 2010, 10:53:10 am
I remember useing
$game_map.events[2].name

before but if it doesn't work try this


$game_map.events[2].event.name

but in order for that to work you need
class Game_Event
  attr_reader    :event
end


to define access to the event's data
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Fantasist on April 28, 2010, 09:48:55 am
Quote from: nathmatt on April 15, 2010, 08:53:22 am

i have a new question im trying to open a store a defined class in an array but i keep getting a undefined method push for nil class before you ask yes i did turn my array into an array

def window(obj) 
  s = obj.new
  window.push(s)
end



So basically, what is window in window.push(s)? You didn't declare an array window. It should be something like:


@window = []
def window(obj)
  s = obj.new
  @window.push(s)
end


I'm guessing you will be using that method to call new windows and keep track of them?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 28, 2010, 07:40:44 pm
I need to know a better way to shorten this code. .__.
If possible of course.
    if mx > px
      if my > py
        tx = mx - px
        ty = my - py
        if tx > ty
          @direction = 6
        else
          @direction = 2
        end
      end
    end
    if mx < px
      if my < py
        tx = px - mx
        ty = py - my
        if tx > ty
          @direction = 4
        else
          @direction = 8
        end
      end
    end
    if mx > px
      if my < py
        tx = mx - px
        ty = py - my
        if tx > ty
          @direction = 6
        else
          @direction = 8
        end
      end
    end
    if mx < px
      if my > py
        tx = px - mx
        ty = my - py
        if tx < ty
          @direction = 2
        else
          @direction = 4
        end
      end
    end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on April 28, 2010, 07:49:40 pm
You don't need to repeat mx > px & mx < px O.o
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 28, 2010, 07:56:01 pm
Thanks to Aqua I managed to cut off 4 lines. THanks ^^
Now to try and find a way to shorten it more.

    if mx > px
      if my > py
        tx = mx - px
        ty = my - py
        if tx > ty
          @direction = 6
        else
          @direction = 2
        end
      end
      if my < py
        tx = mx - px
        ty = py - my
        if tx > ty
          @direction = 6
        else
          @direction = 8
        end
      end
    end
    if mx < px
      if my < py
        tx = px - mx
        ty = py - my
        if tx > ty
          @direction = 4
        else
          @direction = 8
        end
      end
      if my > py
        tx = px - mx
        ty = my - py
        if tx < ty
          @direction = 2
        else
          @direction = 4
        end
      end
    end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on April 28, 2010, 08:22:39 pm
You repeat tx = mx - px for the if mx > px & do the same for the ys in the y if
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on April 28, 2010, 09:22:57 pm
        
        if tx > ty
          @direction = 6
        else
          @direction = 2
        end

You can shorten these this way:
@direction = (tx > ty ? 6 : 2)


Do that to all of them.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 28, 2010, 09:52:01 pm
Thanks FZ I knew that but I didn't think about using it. *lv's up aqua and FZ*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 29, 2010, 07:24:59 am
sorry i forgot to say i figured it out it was because i had @win becoming an array in def initialize but wasn't calling in with the super method so i moved it to main
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Jragyn on April 30, 2010, 03:17:54 am
Please bear with me, I'm struggling to push myself to write some script, but...
Umm, the language of RGSS & RGSS2 is essentially...both Ruby, right?

So with that in mind, are these the same?

dropped_items = []
dropped_items << $data_items[i.item_id]


dropped_items = []
dropped_items.push($data_items[i.item_id])


I am trying to rip apart a script so I can understand scripting in general, better.
However, I am assuming the << is the .push() into the array of dropped_items?

Is there a better of these two? X_X
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on April 30, 2010, 10:02:59 am
no they are not the same push adds to an array as far as i know << is only used to refer to super classes such
as Window_Base

edit: did not know that i always use push
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 30, 2010, 12:03:02 pm
You're talking about <. << is an operator and when used on an array is does the same as push.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Valdred on May 05, 2010, 02:32:29 pm
Is it possible to get a class as a string? I mean the class with all it's code.
Example:

module Example

def this_is_some_code
#nothing
end
end

Now I need a method that gets just that as a string. like this:

#module Example

def this_is_some_code
#nothing
end
end"

You see? I need this because I want to read the RPG module. Is that possible?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on May 05, 2010, 05:38:57 pm
QuoteYou see? I need this because I want to read the RPG module. Is that possible?


The Help Manual that comes with the game shows the RPG module and the modules included within it.
If you need a copy of the Help Manual, download Blizzard's Scripting Guide for Advanced and Intermediate, or whatever its called, something like that. There is a copy of it included in that.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on May 13, 2010, 11:50:15 pm
How do we access Mysql data through ruby? I'm willing to look through it in RMX-OS if someone can pinpoint me to where it does it.
Help is appreciated.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on May 14, 2010, 12:53:29 am
well for one thing you need the mysql.so file and include it or what ever. also if you get SciTE (http://www.scintilla.org/SciTE.html) then you can run searches of all of rmx'os code and see the code color coded for syntax ect. just in the search option make sure that *.rb is one of the extension patterns for the files to look through. SciTE makes coding ruby outside of rmxos a lot easier in general.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on May 14, 2010, 02:31:59 am
Check out RMXOS.rb and Data/Server.rb. And possibly Data/Client.rb
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Valdred on June 05, 2010, 12:56:36 pm
How do I set what page of an event is currently running?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Hellfire Dragon on June 06, 2010, 10:55:00 am
Quote from: Hellfire Dragon on June 05, 2010, 02:46:11 pm
Would there be a way to disable the player from using skills with certain elements unless a switch is on? So basically I need a way to check if the skill the player attempting to use is a certain element, then check if the switch is on, if it is, then continue with the skill.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on June 06, 2010, 11:06:58 am
Quote from: Hellfire Dragon on June 06, 2010, 10:55:00 am
Quote from: Hellfire Dragon on June 05, 2010, 02:46:11 pm
Would there be a way to disable the player from using skills with certain elements unless a switch is on? So basically I need a way to check if the skill the player attempting to use is a certain element, then check if the switch is on, if it is, then continue with the skill.


I answered you! D:
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 06, 2010, 11:09:15 am
I sent him a script, and it'll do what he wants.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Hellfire Dragon on June 06, 2010, 12:14:39 pm
Thanks G_G

Quote from: Aqua on June 06, 2010, 11:06:58 am
Quote from: Hellfire Dragon on June 06, 2010, 10:55:00 am
Quote from: Hellfire Dragon on June 05, 2010, 02:46:11 pm
Would there be a way to disable the player from using skills with certain elements unless a switch is on? So basically I need a way to check if the skill the player attempting to use is a certain element, then check if the switch is on, if it is, then continue with the skill.


I answered you! D:

QuoteThat's not related to Blizz-ABS.
This is very much possible.
Just mod the skill_can_use? method.


I have no idea how to do that, so I posted here :P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 21, 2010, 05:44:09 pm
Got a math question. Made a sprite class. I'm trying to make it look in the direction of a point.
So an arrow for example. It'll always be looking towards the mouse. Something like that. I know its just some sort of equation but I'm pretty stumped.
Pretty much just get a direction out of two points.

Thanks in advance!
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on June 21, 2010, 06:27:46 pm
i could be wrong but wouldn't you just get the x and y if the x is lower that the x being checked face left face down if the y is higher ?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 21, 2010, 07:34:00 pm
I'm not doing left, up, right, and down stuff. I'm using a whole 360 degrees.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on June 21, 2010, 07:43:29 pm
i was wondering about that
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: winkio on June 21, 2010, 07:56:26 pm
atan2 (also known as the circular inverse tangent) is the function you need.  Specifically, it's atan2(x, y).

http://en.wikipedia.org/wiki/Atan2 (http://en.wikipedia.org/wiki/Atan2)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on June 21, 2010, 08:05:25 pm
this also might help

Spoiler: ShowHide
#==============================================================================
# ** Map Target Pointer
#------------------------------------------------------------------------------
# by Fantasist
# Version: 1.0
# Date: 30-Jan-2009
#------------------------------------------------------------------------------
# Version History:
#
#   1.0 - First version
#------------------------------------------------------------------------------
# Description:
#
#     This script adds a pointer which points to a desired event on the map.
#------------------------------------------------------------------------------
# Compatibility:
#
#     Should be compatible with almost everything.
#------------------------------------------------------------------------------
# Instructions:
#
#     Place this script in a new slot below Scene_Debug and above main.
#   If you're using any input modules and the key you set is from that script,
#   plave this below that input script.
#
#   Use the following call script to set a target event:
#
#         $game_temp.point_towards(EVENT_ID)
#
#   where EVENT_ID is the ID of the event to which the pointer should point.
#
#   To remove the target, use:
#
#         $game_temp.point_towards
#                   or
#         $game_temp.point_towards(nil)
#------------------------------------------------------------------------------
# Configuration:
#
#     Scroll down a bit for configuration.
#
#  MTP_Pic: Name of the picture file in the "Graphics/Pictures" folder.
#           The pointer should point upwards.
#  MTP_Position: Position of the pointer.
#                 - If it is fixed, use an array of X and Y values
#                   (like this: [X, Y]) if the pointer is static.
#                 - Use nil for placing the pointer above the player.
#  MTP_Key: The key which should be pressed for the pointer to appear.#
#------------------------------------------------------------------------------
# Issues:
#
#     None that I know of.
#------------------------------------------------------------------------------
# Credits and Thanks:
#
#    - Fantasist for making this.
#    - Hellfire Dragon for requesting this.
#------------------------------------------------------------------------------
# Notes:
#
#   If you have any problems, suggestions or comments, you can find me at:
#
# - www.chaos-project.com
# - www.quantumcore.forumotion.com
#
#   Enjoy ^_^
#==============================================================================

#==============================================================================
# ** FTSConfig
#==============================================================================
module FTSConfig
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG BEGIN
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  MTP_Pic = 'Target_Pointer'
  MTP_Position = nil #[320, 240]
  MTP_Key = Input::A
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG END
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
end
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
 
  attr_reader :point_target
 
  alias mtp_game_temp_init initialize
  def initialize
    mtp_game_temp_init
    @point_target = nil
  end
 
  def point_towards(val=nil)
    @point_target = val
    $scene.set_target(val) if $scene.is_a?(Scene_Map)
  end
 
end
#==============================================================================
# ** Spriteset_Map
#==============================================================================
class Spriteset_Map
 
  attr_reader :character_sprites
  attr_reader :pointer
 
  alias mtp_spriteset_map_init initialize
  def initialize
    mtp_spriteset_map_init
    @pointer = Pointer.new(self)
    @pointer.z = 5100
  end
 
  alias mtp_spriteset_map_upd update
  def update
    mtp_spriteset_map_upd
    @pointer.update if @pointer != nil
  end
 
  alias mtp_spriteset_map_disp dispose
  def dispose
    mtp_spriteset_map_disp
    @pointer.dispose
  end
 
end
#==============================================================================
# ** Pointer
#==============================================================================
class Pointer < Sprite
 
  attr_reader :target
  attr_accessor :spriteset
 
  def initialize(spriteset)
    super()
    self.visible = false
    self.spriteset = spriteset
    self.target = $game_temp.point_target
    self.bitmap = RPG::Cache.picture(FTSConfig::MTP_Pic)
    if FTSConfig::MTP_Position
      self.x, self.y = FTSConfig::MTP_Position[0], FTSConfig::MTP_Position[1]
    end
  end
 
  def update
    super
    self.visible = @target && Input.press?(FTSConfig::MTP_Key)
    return unless Input.press?(FTSConfig::MTP_Key)
    update_pointing if @target
  end
 
  def update_pointing
    y = ($game_player.screen_y - @target.screen_y).to_f
    x = (@target.screen_x - $game_player.screen_x).to_f
    rad = Math.atan2(y, x) - Math::PI/2
    self.angle = rad * 180 / Math::PI
    unless FTSConfig::MTP_Position
      self.x = $game_player.screen_x
      self.y = $game_player.screen_y - 64
    end
  end
 
  def get_sprite_char(event_id)
    return nil unless $scene.is_a?(Scene_Map)
    self.spriteset.character_sprites.each {|spr_char|
    return spr_char if spr_char.character.id == event_id}
    return nil
  end
 
  def target=(event_id)
    @target = nil if event_id == nil || event_id < 0
    @target = get_sprite_char(event_id)
    @target = @target.character unless @target == nil
    update_pointing if @target
    self.visible = false
  end
 
  def bitmap=(val)
    super(val)
    return if val == nil
    self.ox, self.oy = self.bitmap.width/2, self.bitmap.height/2
  end
 
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
 
  attr_reader :spriteset
 
  def set_target(event_id)
    @spriteset.pointer.target = event_id
  end
 
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on July 15, 2010, 08:52:56 am
Not sure if this would go here, but I'm having a major problem with ruby right now. First theres a file called dir.tmp it reads from. Here's what it says.
C:/Users/Ronnie/Documents/RPGXP/Project1
C:/Users/Ronnie/Documents/RPGXP/Project2


Then I have this.
f = File.open('dir.tmp', 'r+')
  dir1 = f.readline# + "/Data"
  dir2 = f.readline# + "/Data"
  f.close
  puts dir1
  puts dir2
  contains = Dir.new(dir2).entries
  contains2 = Dir.new(dir1).entries


Now the puts dir1 and dir2 print out what it should. Now I get this error when I try to run the ruby app.
Invalid Argument - C:/Users/Ronnie/Documents/RPGXP/Project1

Its referring to dir1, it doesnt do it for dir2 however. I'll comment this line
containts2 = Dir.new(dir1).entries

And my app will continue on just fine.

Help please :S
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dragoon on August 14, 2010, 05:51:06 pm
Please forgive me if this seems like a silly question, but is it possible to script battle animation concurrency between the attacker and target, using the animation frames of both to decide the total length? I'm trying to figure out the degree of difficulty involved in re-scripting the battle animation updating to allow for this. Would it merely involve merging the update phases for them?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Hellfire Dragon on August 21, 2010, 06:35:01 pm
Anyone know if there's a way to continue to show the player's total experience after they reached the max level? I'm not using levels in my game but I'm using experience for something else. If you open the menu you can see "E   CURRENT_EXP/EXP_TO_NEXT_LEVEL" but when you reach the max level you see "E    ---/---"
I looked at the script and only found how to remove the "/EXP_TO_NEXT_LEVEL" part.

Any help would be appreciated :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Sacred Nym on August 23, 2010, 12:38:14 pm
@Hellfire

In Game_Actor look for this code:
  def exp_s
    return @exp_list[@level+1] > 0 ? @exp.to_s : "-------"
  end

Replace or comment out the middle line and replace it with:
return @exp.to_s
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Hellfire Dragon on November 06, 2010, 07:01:02 pm
I'm a bit late but thanks Nym :) Another question, anyone know how to remove all skills from an actor?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on November 06, 2010, 07:22:57 pm
(1...$data_skills.size).each {|i| $game_party.actors[ACTOR_INDEX].forget_skill(i) }


Can't remember if "forget_skill" is the correct method name. Look in the Game_Actor class and find something along them lines if it doesn't work.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Hellfire Dragon on November 07, 2010, 10:11:34 am
That worked perfectly, ty Zer0 ;)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on November 22, 2010, 12:29:30 pm
How can one make it so that a Graphics.transition affects more than the standard 640x480 window. I ask because it is the last thing I need to finish a Custom Resolution script I made, one that is about as Plug & Play as a script of this nature can be.

I kind of created a cheated method, using the screenshot.dll from the custom transitions script floating around the forum, but this is only good for a standard transition with a simple fade from one screen to another, not for using actual transitions in the game folder.

I already messed around trying to reset the default viewport size returned and about everything else, but apparently the graphic is not loaded like other bitmaps are. The script works perfect, but during transitions, only a 640x480 box is transition, then the rest will just instantly change when the transition is done.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 22, 2010, 02:45:30 pm
You will have to implement the transitioning manually. :/ I don't think there's a way to make it affect the whole screen just like that.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on November 22, 2010, 03:10:35 pm
Damn. I figured. Just hoping I wouldn't have to...   :<_<:

EDIT:

Okay, these transitions are just straight pissing me off now. How exactly is the graphic used to get the effect seen on screen. I obviously don't mean the basics of the lighter/darker shades, etc, etc. I can't seem to get to work using a graphic, just the simple fade that you see if no transition name is passed as an argument. I do know the image is not loaded through the Bitmap class, which I image means it is using a function from the library I do not know about, but how can I achieve the same effect using Ruby?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on November 24, 2010, 02:45:17 pm
I was pretty sure that the graphic WAS loaded through the bitmap class and then bitmap.get pixel to get the color of a pixel and if it matched the color of gray it was transitioning that point in the loop it would do so.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on November 24, 2010, 03:47:45 pm
I don't think. I tried aliasing Bitmap, Sprite, and Viewport to print the arguments passed to them before doing the normal thing, and nothing happened at all. No output when the graphics transitioned.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on November 24, 2010, 04:52:55 pm
It's a transitioning effect with using the transition image as alpha threshold map to determine the timing of the pixel transitions (but you know that). I don't think you can fake it in a quick/efficient way without having to edit the raw render engine (which you pretty much can't do). But there might be a way... If you used a similar way like the screenshot DLL does to get the screen caption and if you could force a transition manually over DirectX using that image combined with the black/white transition map, then it could work out. Of course, this would probably be more of a hassle than the end result would be worth. That would be the first thing to pop into my mind.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on November 24, 2010, 05:02:01 pm
This may have to just be a sacrifice I have to make. I really wanted to maintain high compatibility and as little "pain-in-the-ass" as possible. Until this, the entire script, with the exception of window sizes etc. in scenes is plug & play. Like I said, I have the standard simple transition implemented well, but I may have to cut out the graphical ones, with the exception of course of the ones from th Transition Pack, since that is already the key for them working.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on December 31, 2010, 12:22:23 am
How do you access special folders in ruby? e.g. AppData, current user, etc...
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on December 31, 2010, 01:14:15 am
Quote from: game_guy on December 31, 2010, 12:22:23 am
How do you access special folders in ruby? e.g. AppData, current user, etc...


ENV['TEMP'] and ENV['TMP'] i do believe.
That's for the AppData.


file = File.open('ENV.txt', 'wb')
ENV.each_key {|key| file.write("#{key}\r\n  #{ENV[key]}\r\n\r\n") }
file.close


Use that to see what it all got.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on December 31, 2010, 04:46:53 am
ProgramData is the Win 7 equivalent of Win XP's Application Data folder. Use ENV['ALLUSERSPROFILE'] for that. You should put application specific stuff such as savegames into that folder. Since v1.2 CP saves the games and screenshots into "%ALLUSERSPROFILE%/Stormtronics/Lexima Legends IV - Chaos Project/%USERNAME%".
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 06, 2011, 04:37:46 pm
I would like to know how i call the shop with a call script command, i tried "$scene = Scene_Shop.new" but it gives an error.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 06, 2011, 04:46:55 pm
You would also need to manually set up the shop items first.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 06, 2011, 04:48:48 pm
wow that was a fast reply, do i do that with a cal script to ? or can i just use the event.

how do i do that?:P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 06, 2011, 04:54:41 pm
Yeah, I'm online right now so this can happen.

If you are calling the shop via script call, you probably want to use a script call here as well. First you need to call this:

$game_temp.shop_goods.clear


This makes sure the items from the last shop don't appear in the new one. Then use this template to add items into the shop:

$game_temp.shop_goods.push([TYPE, ID])


For TYPE you can use 0, 1 or 2 which is for item, weapon or armor respectively and the ID is the database ID of the item, weapon or armor.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 06, 2011, 05:01:35 pm
Oh ok, Thanks a bunch :D thats really helpfull :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 06, 2011, 05:07:46 pm
Hmm, I just tested it, and it turns out im doing something wrong.

Spoiler: ShowHide

(http://img152.imageshack.us/img152/4100/errorw.png)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on January 06, 2011, 05:22:33 pm
I'm not sure why you would want to, but here you go.

set up the shop goods
[code]
$game_temp.shop_goods = [
[0,1], [1,1], [2,1]
]

pattern goes
[TYPE,ID], [TYPE,ID], [TYPE,ID]

where type is 0, 1 or 2 meaning item, weapon, or armor respectively and ID is the items id in the database.
then call the shop
$scene = Scene_Shop.new



EDIT: darn blizz beat me to the punch. ah well my example is slightly different[/code]
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 06, 2011, 05:26:27 pm
well i gues i shouldhv just said this in the first place, but i was hoping i could call it during batle,....why didnt i say that in the first place.....

anywya if i cant call it during a battle i gues ill need to find someone to make me a script.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 06, 2011, 05:34:20 pm
when you call Scene_Shop and you want to make it custom call it like this
$scene = Scene_Shop.new([[0,1]]) if you made that some kind of global variable could add to it when ever you wanted say using $game_variables[1] first you need to make it an array  $game_variables[1] = []
now you can just use $game_variables[1].push([0,1]) and call it like this $scene = Scene_Shop.new($game_variables[1]) that should work
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on January 06, 2011, 05:40:53 pm
Quote from: nathmatt on January 06, 2011, 05:34:20 pm
when you call Scene_Shop and you want to make it custom call it like this
$scene = Scene_Shop.new([[0,1]]) if you made that some kind of global variable could add to it when ever you wanted say using $game_variables[1] first you need to make it an array  $game_variables[1] = []
now you can just use $game_variables[1].push([0,1]) and call it like this $scene = Scene_Shop.new($game_variables[1]) that should work


don't listen to him, Scene_Shop dose not take any arguments so this will only give you errors.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 06, 2011, 05:42:11 pm
use ryex's code it should work  :^_^':
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 06, 2011, 05:44:40 pm
And especially don't use $game_variables for that kind of thing.

If "$game_temp.shop_goods.clear" is giving you an error, use "$game_temp.shop_goods = []" instead.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 06, 2011, 05:48:35 pm
y not ? Does it really mater what use the $game_variables for ?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 06, 2011, 06:02:28 pm
Thanks all off you guys :D

after some tries i got it workign like this:
Spoiler: ShowHide

(http://img190.imageshack.us/img190/9379/callshop.png)


now to see if i cn call this during battle.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 07, 2011, 02:21:24 am
If you call it during battle, it will abort the battle and restart it after you return to the battle scene.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Dundora on January 07, 2011, 04:52:08 am
Yeah your right, its alright though i already firgured somethign else out :)
thanks again.

Edit: i  now need an other piece of script thoug, i need one that makes the player use an item that is in the inventory without actually going to the menu, so its used when talking to an event for example.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 08, 2011, 02:18:56 pm
ok i using array.each{|word|text.gsub!("#{word}") {replace}} the only problem is i want it to remove the word no matter how its capitalized in the text 
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on January 08, 2011, 02:53:16 pm
array.each{|word|text.downcase.gsub!("#{word}") {replace}}

Define the words as all lower case words.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 08, 2011, 03:10:42 pm
That won't work. The original text will never be modified but only the copy that gets returned by downcase.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on January 08, 2011, 03:26:34 pm
i figured out a way the entire word gets replaced so if crap is filtered fcrap gets replaced too but i can live with that because i added the non_filtered array to fix words so that you can put scrap
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on January 08, 2011, 03:26:35 pm
Quote from: Blizzard on January 08, 2011, 03:10:42 pm
That won't work. The original text will never be modified but only the copy that gets returned by downcase.


I didn't think of that. You ay have to go with Regular Expressions.
Do the old [Cc][Rr][Aa][Pp].
This is going to hamper performance a bit though, especially if it is checking for a lot of words.

Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 08, 2011, 03:46:42 pm
Actually it's a lot simpler than that. Use a regular expression with the word as exact sequence and just turn on the option for case insensitive. I'm not sure, but I think it was \i or /i. Check out Z's tute on regex.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on January 08, 2011, 04:19:24 pm
Quote from: Blizzard on January 08, 2011, 03:46:42 pm
Actually it's a lot simpler than that. Use a regular expression with the word as exact sequence and just turn on the option for case insensitive. I'm not sure, but I think it was \i or /i. Check out Z's tute on regex.


I figured there was an easier way than what I showed, but I couldn't remember. I never did memorize all the commands and syntaz of regexpr. I always just looked up what I needed for any given situation.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on January 08, 2011, 04:41:18 pm
I don't know all possibilities of regex by memory either. I know the general stuff and look up the details when I need them.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Zeriab on January 11, 2011, 03:25:32 pm
I don't remember either  :shy:
The reference part of my tut I actually wrote for myself. >_>

*hugs*
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 28, 2011, 10:50:58 pm
It wouldn't be too possible to have a console open and type in script calls and have it execute through RMXP would it? Or can it be done through win32api calls and stuff.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Aqua on February 28, 2011, 10:56:04 pm
RMX-OS's chat system handles script thingies...
Sooo maybe?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on February 28, 2011, 11:01:50 pm
fairly simple I should think. use Zer0's console script and try getting input from it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on February 28, 2011, 11:02:10 pm
I meant like an actual console cmd per say.

@Ryex: I'll take a look at it
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Zeriab on March 01, 2011, 01:49:30 am
The eval command makes it a matter of allowing text input and retrieving that. (Unless you want some sort of auto-complete like there is in cmd)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 01, 2011, 01:52:23 am
well what I meant was I have a console open, (the command prompt) and you can type in script calls which then gets sent to the RGSS player which then gets executed.

Wait...I have an idea, is there anyway to copy and retrieve a class from the clipboard?
class EvalCmd
    attr_accessor :cmd
end

Maybe I can have the console create a new class, set the command, copy it to the clipboard, have rmxp retrieve it, execute the command, and clear the clipboard. Is that all possible?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on March 01, 2011, 02:37:15 am
A way it could be done would be through a file.
You make a Ruby script that allows you to enter text all the time. Then you make it append the text each time to a file. Let RMXP repeatedly (every frame) check for the file. If the file isn't empty, it should executed what's inside and then empty it. You would only have to be careful about concurrent access. This is a rather dirty solution and I suggest you simply use a console script.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on March 01, 2011, 03:26:20 am
ya as I said find out how to get input from the console and the use an eval in a begin except finally block. you might be able to figure out how to redirect standard input
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 01, 2011, 08:31:09 am
Thanks guys, this'll be way cooler then a floating textbox in the middle of my screen F0 :V
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on March 01, 2011, 12:09:07 pm
You should be able to fuse the console debugger and the script caller I wrote to solely use the console.

Link the console to stdin instead of it being stdout only. Then all you have to do is run an "eval" method on the line. I was going to do this originally, but if I remember correctly I was encountering a few issues. My knowledge of pointers, etc was in its infancy at the time. I ended up splitting them and just released both seperate scripts at the same time.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KoenLemmen on March 20, 2011, 04:32:14 am
Hi people,

I am new here on the forums.
I've got one question about RMX-OS script!
Is it possible to post your game on your server (a site NOT your own PC) and run it with your PC off.
PM me pleas. I need to find a way to run my online game without keeping my pc on the hole time!  :wacko:

Koen

PS Maybe I typ bad English I am dutch.  8)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on March 20, 2011, 04:48:58 am
Yes, its possible. You will likely need to pay a small amount for whatever company hosts it. I don't know any off-hand, but I'm sure google will help you out.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KoenLemmen on March 20, 2011, 04:55:24 am
Quick answer thanks!   :D
I know about the pay part.
I hope anybody still can help me with how to make my online game setup on a site and keep it running without having my PC on.
But thanks already!

Koen
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on March 20, 2011, 10:13:43 am
Actually, I'm pretty sure its almost impossible, you'd need a host that runs Ruby. Not Ruby on Rails but Ruby.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KoenLemmen on March 20, 2011, 10:14:35 am
Hmm oke... Thats bad to know.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 15, 2011, 06:13:25 pm
Anyway to stop the blinking of the cursor? Ya know, that annoying flashing like effect the rectangle has when selecting choices.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on April 15, 2011, 06:30:42 pm
Probably a little bit tricky, since it is in the hidden Window class. You can reference the cursor_rect from the class, but I don't know how that can really help you change the opacity. I think that the cursor is its own sprite, but is private to the class.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 16, 2011, 01:21:14 am
Which effect would be better? Zooming the battle back so it fits? Or stretching it? Stretching of course is easier but I think zooming would be the nicer way to go. Plus I need help calculating this equation. I think I'm on the right track.

Code for Zoom
if width < 640
  sprite.zoom_x = 1.0 + width / 640
end
if height < 480
  sprite.zoom_y = 1.0 + height / 480
end

I think I'm on the right track but haven't had any real time to test it out.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on April 16, 2011, 01:31:00 am
sprite.zoom_x = 640.0 / sprite.bitmap.width
sprite.zoom_y = 480.0 / sprite.bitmap.height


I think that is all you should need.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 16, 2011, 03:47:45 am
Quote from: game_guy on April 15, 2011, 06:13:25 pm
Anyway to stop the blinking of the cursor? Ya know, that annoying flashing like effect the rectangle has when selecting choices.


Set Window#active to false.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 20, 2011, 06:57:34 pm
What module is the method "raise" under? Same with "print"? Would like to make some modifications to the methods reguarding an error log system I have in plan.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on April 20, 2011, 07:00:25 pm
They are both in the Kernel.
Just make methods outside of a class at top-level to change them.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 24, 2011, 10:37:38 pm
Thanks F0. Another question, when you run into a general error like
Undefined Method
No method "clear"
Does "raise" get called? This is very crucial to my logging and debugging system for beta testers. Any errors that occur would be saved into a log that they can just post and I can go and fix.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on April 24, 2011, 11:08:38 pm
I believe so, but I can't say 100% sure. If you need to log errors, you simply need to keep an eye on one global variable: $!

This will be nil until an Exception is raised, then it will be the copy of that Exception, where you can log the message and backtrace information.
What I have done to log errors in Ruby is something simple like this:

In your entry point in Main where looping starts...

require 'script'
require 'another_script'

$program_started = true

begin
 while $program_started
   # Some type of loop
 end
rescue
 file = File.open('ErrorLog.txt', 'a+b')
 file.write(Time.now + "\r\n" + $!.message + "\r\n" + $!.backtrace)
 file.close
ensure
 # Anything you want to log or do no matter how it closes
end



EDIT:
Here, use these. They were invaluable to me when learning to script, and I still use them to look up various things.

Ruby 1.8.6 Documentation (http://dl.dropbox.com/u/20787370/Scripts/Ruby-1.8.6-core.chm), which I use when writing for RMXP.
Ruby 1.9.1 Documentation (http://dl.dropbox.com/u/20787370/Scripts/Ruby-1.9.1-core.chm), for every other time.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 25, 2011, 02:17:13 pm
Check out my mod of the main script in RMX-OS. I added a nice way of logging errors.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: LazyViking on May 24, 2011, 05:49:36 pm
Hi  :) i dont know if this is the rght place to post, but i'll take a dive  :P

My question Is as following: Is ruby scripting and RGSS two different things?

if yes: Do i need basic ruby knowlege to start RGSS scripting?


edit*: I forgot to add something: i have done a little bit of java, and then i used eclipse, is there a similar program for RGSS? :D


thank you for your time   :D


      -lazyV
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on May 24, 2011, 05:54:30 pm
RGSS is the set of scripts that make RMXP what it is. It is basically a "framework" of a basic game, that can be built upon. They are written in Ruby, and use Ruby to execute.

And, no, you don't need to learn Ruby first. By learning to write code for RMXP, you are in fact learning Ruby. The actual Ruby language is much more expansive than what it used in RMXP, so in my opinion, it is actually easier to start with RGSS, and then built upon that knowledge to learn Ruby, though they each will allow you to learn the other.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: LazyViking on May 24, 2011, 05:56:59 pm
Thanks for the quick reply :)

and do i just use RMXP as my "eclipse" for RGSS coding? :P


         -lazyV
     
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: ForeverZer0 on May 24, 2011, 06:16:17 pm
Pretty much.

Although using an external IDE has a lot better features than the RMXP script editor, it is way too much of a hassle to be constantly porting the files back and forth for playtesting. It would be neat to create a little thing that actually read/writes the Scripts.rxdata from an external IDE, such as VS, Eclipse, or NetBeans.

* starts thinking of ways to accomplish this....
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: LazyViking on May 24, 2011, 06:41:43 pm
thank you so much for the answer :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on May 25, 2011, 01:58:07 am
Small correction: RGSS was made in C++, but it was interfaced with Ruby so the whole framework can be used with Ruby in RMXP.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 03, 2011, 03:47:22 am
I've seen it done somewhere and I can't remember where I found the code. I basically want to create "events" when scripting. Events as in when x happens do y. Like .NET forms, when Form loaded, call this method. How would I go doing this?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on June 24, 2011, 09:10:51 pm
im trying to get the a map locations autotile bitmap location with the tile_id im making my own minimap and i got it to display all the maps graphics fine except for the autotiles i cant figure out how to get the location in the autotile graphic for the specific x,y
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 24, 2011, 09:24:39 pm
Take a look at this post here. Everything is explained in there.
http://forum.chaos-project.com/index.php/topic,9104.msg140240.html#msg140240
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on June 25, 2011, 07:43:58 am
Explain this please. The 2 lines in Main.
filename = $!.message.sub("No such file or directory - ", "")
  print("Unable to find file #{filename}.")

I finally looked at it instead of glancing. I don't see the point in it really. To me it looks like their just making their own custom error message. Or is there a deeper meaning?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on June 25, 2011, 08:58:17 am
Quote from: game_guy on June 25, 2011, 07:43:58 am
their own custom error message.


This.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: nathmatt on June 25, 2011, 09:22:49 am
@Blizzard thx worked perfectly

edit: never mind its messed up somewhere else
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: maniak on March 25, 2012, 07:52:04 pm
I want a script to recheck "Data/MapInfos.rvdata" when a game save is loaded. What would this look like?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: element on March 28, 2012, 04:48:23 am
Hey guys, need some help with my first ever rgss script.

Basically I'm making a skill button combo system addon for Blizz-abs.
Everything works fine, but now I have come to the part where I need to unleash the skills.

I tried searching in Game_battleaction and in scene_battle and also in the blizz-abs scripts.
But I cant seem to figure out how to unleash a skill through a script command.

All that it needs to do is simply use a skill with blizz-abs.


Hope you guys can help :)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on April 07, 2012, 03:34:28 pm
I made a script "Ryex's Weapons Unleash skills" you can use the code there to lean if you want. I even made a BABS plugin for it so barrow away."
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: element on April 07, 2012, 06:45:33 pm
It was thanks to your script that I actually tried to script this :D
Though I still cant seem to figure out how you did it.
I'll try to look into it more though.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on April 07, 2012, 07:39:30 pm
Have you forgotten your thread?  :huh:
http://forum.chaos-project.com/index.php/topic,11571.0.html (http://forum.chaos-project.com/index.php/topic,11571.0.html)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Calintz on April 15, 2012, 05:59:33 am
i know that the majority of scripters at CP work with RGSS because of XP, but i have some general questions that i think would apply to all versions of the RGSS, and i am personally working with RGSS3. anyway, my first question is when you're working with windows, the arguments that you decide to implement on that window's initialization is completely up to you, right? depending on what kind of window you'd like to create?

def initialize (i'm talking about the values that go here)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 17, 2012, 09:22:55 am
Quote from: Calintz on April 15, 2012, 05:59:33 am
i know that the majority of scripters at CP work with RGSS because of XP, but i have some general questions that i think would apply to all versions of the RGSS, and i am personally working with RGSS3. anyway, my first question is when you're working with windows, the arguments that you decide to implement on that window's initialization is completely up to you, right? depending on what kind of window you'd like to create?

def initialize (i'm talking about the values that go here)


I merged your original topic with this one, since its more of a general topic already. As for your question, I don't really get what you're asking. If you're creating your own window, the arguments needed to pass are completely up to you. Just be sure that you use the "super" method and follow the parent classes arguments. Example...
class Window_MyWindow < Window_Base
  def initialize(arg1, arg2, etc...)
    super(x, y, width, height)
    # do your stuff here
  end
end

Whenever you have a class inherit another one, always remember to call its parent initialization method and use the proper arguments it comes with, if that makes any sense.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Calintz on April 18, 2012, 03:44:41 am
that is okay, and yes, that was my question. thank you.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on February 25, 2013, 09:29:14 am
How would you turn the actors name vertical instead of horizontal?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Ryex on February 25, 2013, 02:07:57 pm
you would have to invent a method to draw a name vertically.

here's some pseudo code not tested or guaranteed to work
Code: ruby

# set color, size, font-family before call
def draw_vertical_text(bitmap, text, x, y, align=0)
   y_off = 0
   text.each_char do |c|
       rect = bitmap.text_size(c)
       rect.x = x
       rect.y = y + y_off
       bitmap.draw_text(rect, c, align)
       y_off += rect.height
   end
end


if you get it to work I would like a screenshot just to see how it works
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on February 25, 2013, 02:28:35 pm
quick verify, this is done in bitmap right?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on February 25, 2013, 03:08:48 pm
As in a method that should be added to the Bitmap class? From what I'm seeing, no. You could do that by removing 'bitmap' as a parameter and using 'self' in its place.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on March 12, 2013, 07:30:10 pm
quick question, is Does Game_Event have any effect on the player as I created a script that has two switches: One that stops the player and the other one to stop NPC's. I got the player one to just stop the player, but the one that stops the NPC stops the player as well. So back to the orignial question, Should what I've done to Game_Event effected the player.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on March 12, 2013, 08:14:59 pm
Game_Player and Game_Event are both a subclass of Game_Character. From what I'm seeing, and guessing off of intuition, you might have made your "NPC stop switch" to apply to certain Game_Character traits, which in turn affects Game_Player.

You can always do something like

unless self.is_a?(Game_Player)
  #process code
end

within the Game_Character methods/whatever it is you changed.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on March 13, 2013, 01:31:41 am
nope still didn't work,
:facepalm: Nevermind, got it to work, I didn't realize the wait command was haulting the characters movements. :facepalm:
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on March 18, 2013, 05:16:56 pm
Okay so I've created a window that list all of the troops in the game. When you click on one of the troops how do you initiate a battle with said troops?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on March 18, 2013, 06:13:27 pm
Weren't you able to accomplish something like this in your bestiary script?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on March 18, 2013, 06:19:35 pm
 :<_<: oh ya, I guess I'll adjust some settings.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on March 28, 2013, 06:32:32 pm
Anyone know how to change the text alignment for the help window in RMVXA. Unlike in XP/VX where it's obvious, Enterbrain decided to move/remove it.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 06, 2013, 02:49:25 am
Quote from: bigace on March 28, 2013, 06:32:32 pm
Anyone know how to change the text alignment for the help window in RMVXA. Unlike in XP/VX where it's obvious, Enterbrain decided to move/remove it.


Along with the previous question that which I'm bumping, has anyone ever figured out how to change the text message speed in RMXP and/or RMVXA? I was going have an option to change the text in RMXP for my option system and RMVXA for a game I'm making (slow, medium, fast).
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Zexion on April 06, 2013, 01:48:26 pm
Have you tried looking at an AMS to see how they do it? Dubealex AMS is the easiest to read for this.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Blizzard on April 06, 2013, 02:54:55 pm
@bigace: Find a window where the alignment is not set to left and you should be able to easily figure out how it's done.
As for the text speed, check the window class responsible for that and maybe its refresh method (I remember it being Window_Message in RMXP).
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 06, 2013, 06:04:28 pm
The problem with VXA is that it does all this confusing stuff inside of Window_Base, that finding where the alignment is almost impossible. I'll keep looking. As for the text speed in VXA, there is no refresh method in Window_Message and the only option that exist is the ability to instantly have the image appear, but nothing on its speed. I'll keep looking on XP though.

Edit:
Quote from: Zexion on April 06, 2013, 01:48:26 pm
Have you tried looking at an AMS to see how they do it? Dubealex AMS is the easiest to read for this.

Thanks for that, just notice that there was a speed function in there. Now just have to figure out how to configure into my option system?
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on April 07, 2013, 02:42:58 pm
Without a message system script, there is no such thing as text speed in RMXP.

The alignment problem could be solved if the text wasn't drawn character-by-character.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 07, 2013, 03:07:31 pm
Quote from: KK20 on April 07, 2013, 02:42:58 pm
Without a message system script, there is no such thing as text speed in RMXP.

The alignment problem could be solved if the text wasn't drawn character-by-character.

Or VXAce for that matter, I guess I"ll have to make one.

I don't know why enterbrain did that but, until someone figures that out. The alignment is stuck that way. Or I guess I can just create a new help window.  :P
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on April 07, 2013, 04:44:32 pm
You are aware RMXP just shows the entire message at once, not by character, right? Hence why I said it doesn't exist--it's not even possible to begin with :P I thought I got somewhere by using wait(int) in VXA, but the "Input C to display entire message" wasn't working.

Yeah, you have to make edits to the classes anyways. Alignment is only made through draw_text so you would have to manually add the parameter to the class methods.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 07, 2013, 09:37:04 pm
Ya the problem with the message script I'm having is that the game I'm remaking has a option in the menu like in Pokemon where you have three text speeds. Enterbrain does make things more difficult than they need to don't they.  :facepalm:

Edit: Pokemon Essential has a text speed option. However everything so confusing thats it's hard to work through and figure out how it works.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 12, 2013, 08:13:04 am
Pokemon Essentials has it's own custom messaging system.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 12, 2013, 05:49:23 pm
Quote from: gameus on April 12, 2013, 08:13:04 am
Pokemon Essentials has it's own custom messaging system.

Ya I know I've already stated that in the post above yours.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: G_G on April 12, 2013, 06:01:54 pm
Sorry, I just misunderstood what you were saying. xD
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on May 15, 2013, 07:23:51 pm
what does "LocalJumpError occurred. no block given." mean? I was writing a script and got this when I tried to load the game from the title screen.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on May 15, 2013, 07:50:59 pm
Quote from: bigace on May 15, 2013, 07:23:51 pm
what does "LocalJumpError occurred. no block given." mean? I was writing a script and got this when I tried to load the game from the title screen.

A quick Google search says that it occurs when no block is given to a method that requires a block. What's a block? It looks like this

some_array.each {|array_element| do_some_stuff_here }

One of your methods is using 'yield' instead of 'return'.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on May 15, 2013, 10:55:31 pm
I have never used yield before so that's strange. I think I know what I need to rewrite though.
Title: RMXP Help
Post by: bigace on May 17, 2013, 04:23:22 am
Okay well nothing seems to fix this issue. The error seems to stem from when I use this
24.times.max_by {|i| do_some_stuff_here(i) } 


This is the code that gives the error from my save system script.

module ACE
module SaveManager
#--------------------------------------------------------------------------
# * Maximum Number of Save Files
#--------------------------------------------------------------------------
def self.savefile_max
return 24
end
#--------------------------------------------------------------------------
# * Get Update Date of Save File
#--------------------------------------------------------------------------
def self.savefile_time_stamp(index)
File.mtime(make_filename(index)) rescue Time.at(0)
end
#--------------------------------------------------------------------------
# * Get File Index with Latest Update Date
#--------------------------------------------------------------------------
def self.latest_savefile_index
savefile_max.times.max_by {|i| savefile_time_stamp(i) }
end

even if I do it the original way RMXP had it:
		#--------------------------------------------------------------------------
# * Get File Index with Latest Update Date
#--------------------------------------------------------------------------
def self.latest_savefile_index
#savefile_max.times.max_by {|i| savefile_time_stamp(i) }
$game_temp = Game_Temp.new
# Timestamp selects new file
$game_temp.last_file_index = 0
latest_time = Time.at(0)
savefile_max.times.max_by do |i|
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
end

I still get the same error, removing the max_by just puts the cursor at the bottom of the list instead of at the last updated save file.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on May 17, 2013, 02:18:25 pm
Not to mention, the method 'max_by' doesn't even exist in Ruby 1.8.1, which I believe is the version RMXP uses.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on May 17, 2013, 02:31:07 pm
Quote from: KK20 on May 17, 2013, 02:18:25 pm
Not to mention, the method 'max_by' doesn't even exist in Ruby 1.8.1, which I believe is the version RMXP uses.

:facepalm: Wow, this whole time I've been looking at 1.8.7. Okay that explains why this doesn't work.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: Kiwa on January 02, 2014, 09:38:24 am
Hey fellas.

since i've felt like such a piece of turd for always having to depend on you all for coding help. i have spent nearly every hour of my week vacation studying (i know its not a lot of time but it has truly helped) coding in RGSS.

i have discovered that the language is not so different than things i remember in other languages such as VB, Action script, and some C. but ...more simple.
but the real trouble i have in this language is finding what is threaded through other classes or modules and borrowed into the new one.

so in the end someing like...
actor  or game_actor and Game_Actors can be really confusing. the dot commands "self.content.font.size" can also be confusing... what is part of ruby or what is part of rmxp.

anyway thanks for listening to that rant. next is the question.



So im trying to make basic windows for a start. i've managed more or less. sizing, positioning, fonts, font size, ect... i managed to get icons aswell but i think i need to use another method if i want only icons and no text.. but for now the text way is what im looking for.

so what i want to add is attributes of the item. such as atk, str, pdef, ect.. to the text box
looking in the scripts i see alot of actor.str but thats not the item its self its the actors. looking at the code i would expect to see something like

ATKbonus = actorATK - EquipdWEP + NEWwep.
NewATK = actorATK + NEWwep.

or something.

but i find no such thing. only things like:

draw_actor_parameter(@actor, 4, 32, 0)

or

if @new_atk != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 32, 40, 32, "->", 1)
      self.contents.font.color = color_choose(@actor.atk, @new_atk)
      self.contents.draw_text(200, 32, 36, 32, @new_atk.to_s, 2)


so how could i display lets say atk or str from the wep onto the display box?

here is what i have. please critique.


class Item_Window < Window_Base
   
  def initialize
    super(0,0,300,100)  #   taken from Window_Base:  super( x, y, width, height)
    actor = $game_actors[$activecharid]
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = "Arial"
    self.contents.font.size = 24
    #self.contents.draw_text( 0, 0, 200, 32, "It's a trap")
    self.draw_item_name($data_weapons[1], 0, -5)
   
  end
 
end
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on January 02, 2014, 12:12:31 pm
First tip: Read the Manual (F1). There's a good amount of help for learning Ruby syntax as well as hidden classes and methods you may not find in the default scripts.

Following that, you can see there's a RPG::Weapon class with the variable atk.

self.contents.draw_text(0, 0, 30, 24, $data_weapons[1].atk.to_s)
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: whitespirits on January 17, 2014, 01:52:16 pm
Hi all im running into a couple of problems on my RMX-OS game,

1st is that when I try to teleport to other maps using an event i just shoot to another spot on the same map?? I have no idea how or what to do to fix this!

2nd is that when i use RMXOS global variables and switches i get stuck on the receiving just after u login for example i see title screen and  receiving 17/17 and nothing happend?

please help thanks !
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 15, 2015, 08:43:27 pm
Engine: RGSS3

So i was trying to count the amount of files in the movie folder:

module ACE_Manger
def self.folder_size(dir)
Dir.glob(File.join(dir, '**', '*')).select { |file| File.file?(file) }.count
end
end

class Scene_Title
alias :ace_start :start
def start
ace_start
puts ACE_Manger.folder_size("/Movies")
end
end


but when I start the game up it says I have 0 files in the folder when there is actually 4. However if I change the directory name to this:

class Scene_Title
alias :ace_start :start
def start
ace_start
puts ACE_Manger.folder_size("D:/Dropbox/Last Bible I - Revelations The Demon Slayer/Game Mechanics/Title Scene/Movies")
end
end


Then the game will print that there is 4 files within the folder. Can anyone figure out why this happens.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: KK20 on April 15, 2015, 09:17:33 pm
How about not putting a forward slash and just do ("Movies")

EDIT: Confirmed. Heck, all I did was see how graphics were loaded into the cache. It goes ("Graphics/FOLDER").
Note that when you start with a forward slash, it looks into the local disk wherever your project is on. In your case, it was looking for D:\Movies.
Title: Re: General RGSS/RGSS2/RGSS3 Help
Post by: bigace on April 15, 2015, 10:46:08 pm
Thanks that does makes sense, I forgot that Graphics doesn't have the forwards slash in front of it.