- Frequently Asked Questions (Please Add To the FAQ) -

Frequently Asked Questions
RGSS/RGSS2 Support Forum


Introduction:
This topic is for questions that are frequently asked, since the beginning of the forums. Feel free to post questions you believe deserve to be put into the FAQ. The staff will add it to the main post and delete your post (to keep things clean).

If there is a topic discussing the question at hand, a link to the topic would be helpful, as it could possibly provide more support.
If someone asks for something that is in this FAQ, and you are sure of it, simply copy and paste the FAQ link in the thread. Do not say, "search for it", or anything. Just provide the link (This is to prevent confrontation).

RGSS(RMXP) Questions:
Once the FAQ has more questions, the questions will then be divided up accordingly.

Q. How do you make the player teleport? Spoiler
  1.   $game_temp.player_transferring = true
  2.   $game_temp.player_new_map_id = #
  3.   $game_temp.player_new_x = #
  4.   $game_temp.player_new_y = #
  5.   $game_temp.player_new_direction = #
  6.   $scene = Scene_Map.new
  7.   $game_map.autoplay
Expand to see the code.


Q. What is the Syntax for Event Data? Spoiler
  1.   $game_map.events[event_id]
Expand to see the code.


Q. How do I Change Event Graphics? Spoiler
Insert the following code somewhere above main:
  1. class Game_Character
  2.   attr_accessor :character_name
  3.   attr_accessor :character_hue
  4. end
Expand to see the code.

Now, use this as your script call:
  1.   $game_map.events[event_id].character_name = 'filename'
  2.   $game_map.events[event_id].character_hue = 0..360
Expand to see the code.


Q. How do I Change Self-Switches via RGSS? Spoiler
  1.   key = [map_id, event_id, switch]
  2.   $game_self_switches[key] = boolean
  3.   $game_map.need_refresh = true
Expand to see the code.

Where:
  map_id - Map Id
  event_id - Event Id
  switch - 'A', 'B', 'C', or 'D'
  boolean - true or false


Q. How do I Change Switches & Variables via RGSS? Spoiler
  1. # Variables
  2. $game_variables[variable_id] = value
  3. # Switches
  4. $game_switches[switch_id] = boolean
Expand to see the code.

Do not place 0's, such as 001, just use 1.


Q. How do I read Item/Weapon/Armor Element Sets? Spoiler
http://hbgames.org/forums/viewtopic.php?p=126935#p126935


Q. How do I read the Number of Items, Weapons & Armors Possessed? Spoiler
  1. # Test for Number of Items
  2. n = $game_party.item_number(item_id)
  3. # Test for Number of Weapons
  4. n = $game_party.weapon_number(weapon_id)
  5. # Test for Number of Armors
  6. n = $game_party.armor_number(armor_id)
Expand to see the code.


Q. How do I call a common event? Spoiler
  1. # If On Map : Replace id with common event id
  2. $game_temp.common_event_id = id
  3. # If in Battle : Replace id with common event id
  4. common_event = $data_common_events[id]
  5. $game_system.battle_interpreter.setup(common_event.list, 0)
Expand to see the code.


Q. How can I hide the timer while it is running? Spoiler
  1. class Sprite_Timer < Sprite
  2.   alias_method :sprite_timer_update, :update
  3.   def update
  4.      sprite_timer_update
  5.      # Conditions to hide the timer (switch, $game_temp.in_battle etc.)
  6.      if $game_switches[switch_id] == true
  7.         # Hide the timer
  8.         self.visible = false
  9.      end
  10.   end
  11. end
Expand to see the code.


Q. How can I call a shop with scripts? Spoiler
  1.   $game_temp.shop_goods = []
  2.   $game_temp.shop_goods << [item_type, item_id]
  3.   # item type = 0 : Items, 1 : Weapons, 2 : Armors
  4.   # Repeat until you add all your items
  5.   $scene = Scene_Shop.new
Expand to see the code.


Q. How do I change the player or event's move speed? Spoiler
Insert the following code somewhere above main:
  1. class Game_Character
  2.   attr_accessor :move_speed
  3. end
Expand to see the code.

Now, to change the players move speed, use:
  1.   $game_player.move_speed = n
Expand to see the code.

To change events move speed, use:
  1.   $game_map.events[event_id].move_speed = n
Expand to see the code.


Q. How do I draw text on a window? Spoiler
  1.   self.contents.draw_text(x_pos, y_pos, width, height, text, align)
Expand to see the code.

Align:
  0 = Left
  1 = Center
  2 = Right
By default align is set to left.


Q. How do I install "Script_Name" in my game? Spoiler
If there were no installation directions provided or the ones that were, seem vague. Do as follows. First open your project, then your script editor(F11, the shortcut key). Insert an empty section in the script listing by right clicking 'Main' and selecting 'Insert'. Copy the text from the custom script document you want to install. Paste this code that was just copied into the large empty section on the right known as the code panel. Lastly go back to the listing of script on the left and name the section something informative and memorable for the script.

A picture of where your script will most likely go:
Image


RGSS2(RMVX) Questions:
If your question was found above but not below this heading than most likely the answer still applies for RGSS2.

Q. How do you make the player teleport? Spoiler
  1.   # What map to create?
  2. $game_map.setup(map_id)
  3. # Map position
  4. $game_player.moveto(x,   y)
  5. $game_player.refresh
  6. $scene = Scene_Map.new
  7. $game_map.autoplay
Expand to see the code.


Q. How do I read the Number of Items, Weapons & Armors Possessed? Spoiler
  1.   # Test for Number of Items
  2. n = $game_party.item_number($data_items[item_id])
  3. # Test for Number of Weapons
  4. n = $game_party.item_number($data_weapons[weapon_id])
  5. # Test for Number of Armors
  6. n = $game_party.item_number($data_armors[armor_id])
Expand to see the code.


Q. How do I call a common event? Spoiler
  1.   # If On Map : Replace id with common event id
  2.   Script : $game_map.common_event_id = id
  3.   # If in Battle : Replace id with common event id
  4.   Script : common_event = $data_common_events[id]
  5.   $game_troop.interpreter.setup(common_event.list, 0)
Expand to see the code.


Q. How do I install "Script_Name" in my game? Spoiler
If there were no installation directions provided or the ones that were, seem vague. Do as follows. First open your project, then your script editor(F11, the shortcut key). Insert an empty section in the script listing by right clicking 'Insert Here' and selecting 'Insert'. Copy the text from the custom script document you want to install. Paste this code that was just copied into the large empty section on the right known as the code panel. Lastly go back to the listing of script on the left and name the section something informative and memorable for the script.

A picture of where your script will most likely go:
Image




Format For Submitting to FAQ
Q.
Topic Link: http://www.hbgames.org/forums/


Please make questions in question format, if possible.
Please provide a link to topic, if possible.
Please use code tags when supplying code.

khmp: Cleaned up the thread. 4/24/08
RGSS/2:

Q. How do I read a string of text from an Item, Skill, Weapon, or Armor's Note?
rockstar1986 wrote:
RGSS/2:

Q. How do I read a string of text from an Item, Skill, Weapon, or Armor's Note?


bump!
rockstar1986 wrote:
RGSS/2:

Q. How do I read a string of text from an Item, Skill, Weapon, or Armor's Note?


  1. # RGSS2
  2.  
  3. # Where item_id is the index of the item in the database view.
  4. $data_items[ item_id ].description
  5.  
  6. # Where weapon_id is the index of the weapon in the database view.
  7. $data_weapons[ weapon_id ].description
  8.  
  9. # Where armor_id is the index of the armor in the database view.
  10. $data_armors[ armor_id ].description
  11.  
  12. # Where skill_id is the index of the skill in the database view.
  13. $data_skills[ skill_id ].description
Expand to see the code.
It's actually...
  1. $data_items[item_id].note
  2. $data_weapons[weapon_id].note
  3. $data_armors[armor_id].note
  4. $data_skills[skill_id].note
  5. $data_enemies[enemy_id].note
Expand to see the code.

Note that when you're changing the note at runtime, you have to use the appropriate $game handlers, instead of $data ones. In general, though, $data is preferred.

On a side note regarding that topic, there is no RGSS code for that, as there is no note field in RPG Maker XP. Also, if you plan on utilizing the note field, you might want to take a look at my Database Flag Reader, linked in my signature, which does about all the work you need unless it's for simple I/O purposes.

Also, I know this is a massive and utterly shameless necropost, but yeah... I figure I'm fighting the power for this one, as having totally useless information in a FAQ thread isn't really gonna help anyone...

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=10513