Proper Script Placement and Usage for RGSS 1 through 3
#1
Proper Script Placement for Custom Scripts

In this occasion I want to make a few recommendations concerning where to paste your beloved custom scripts in the maker's script editor. I hope they will prevent you from making those terrible mistakes that usually make your game crash like a car driven by a drunkard. Shocked

Rule 1: Scripts that rewrite an already existing method or even a whole class, need to be placed BEFORE all other scripts that aliased those methods.

Rule 2: Do exactly the opposite for any scripts that include aliased methods.

Rule 3: Parent classes should always be placed before their child classes either on a previous section or at the top of the same page where their child classes are currently located. It's excessively important for inheritance!!

Rule 4: Respect the script pack order at all costs! Scripters should not be blamed for people that misplace their scripts even if the scripters have provided a demo showing you how to place them in your script editor!

Friendly Suggestion 1: Never edit any default script right in their original section of the script editor's list. Use a new section that you can remove at any given time if you messed up with your game system and it is no longer working properly.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#2
Proper Script Usage for Custom Scripts

Never try to edit a script that doesn't offer you some getter or setter method or an extra variable or array or hash or Constant.
Angry Learn some basic scripting first!

Many scripters get bored of listening to lazy game developers that pretend to be top notch but know nothing about coding and still state stuff like a script is crappy. Most of the time its the users' fault! Laughing They don't know any RGSS or Ruby or JS or anything and they change complex stuff and later complain about what they have broken. Laughing + Tongue sticking out

Don't use Constants as simple variables! Angry

They are named Constants because their contents should remain the same!! Shocked So if it's a boolean or a number or an array or a hash, leave it as it is! Only change them if the scripter told you what values were valid there! Winking

Scripts Are No Miracle Workers! Laughing + Tongue sticking out

They are just some tools to let you extend a game engine's list of available features. Scripts have limitations like practically having no access to low level functions unless you get libraries like the incompatible and forgotten and deprecated Win32API. Of course modern replacements of your game engine might let you use a lot more features by default or by loading custom rubygems available online. Laughing Don't forget to install them on your system to test the rubygems! Happy with a sweat

High Level Programming Languages Usually Are Not as Fast as Low Level Ones! Sad

Even so languages like Ruby (version 2.x and above) really care about speed and get improved every single time they find a way to do so. Yeah, that's the price you pay for making a language as human readable as possible. Happy with a sweat Still, Python, Ruby and others let you compile your code to bytecode to make them run in no time. They can also be compiled if needed. Compiling stuff makes it a closed project for average users like you. Sad High level languages actually let you extend a language at some specific point or at any time in Ruby's case! Laughing You're free to create as many classes and modules are you wish.

Do Not Rely on Global $Variables! Angry

Most of the time newbies come up with their so called amazing scripts but forget one thing... They create too many $variables!! Sad That's a hard blow for your game! You could end up cutting off its head... if it ever had any. Laughing They consume most resources so spare them as much as possible. Only depend on them if you excessively need dinamic loading or stuff updating. In my experience changing stuff like $game_temp might end up getting quite ugly in the RM series. Still, you could load stuff like items list to a module's variable if you wanted.

X Y Coordinates

Thank Descartes for his contribution since he let us use them in silly stuff like videogames. Laughing In the RM series you set a sprite or window or event at some coordinate by setting their x and y cartesian coordinate system. In the original version and even in OpenGL rendering IIRC, the X 0 and Y 0 position is located at the lower left corner of your paper or monitor or phone screen. Most applications place it at the upper left corner and the RM series are part of this trend.

In RGSS every single tile has a fixed width of 32 pixels and the same is valid for its height. If talking about maps every single position should be multiplied by 32 to let you know it's real position on the map. On scenes that isn't necessary at all. Laughing Curiously there are times when sprites or windows might get placed on screen even if they are supposed to be located outside the current view (called the camera view IIRC). I'm not sure if that's a feature or a bug. Laughing

Usually windows ask you to pass one or more arguments concerning its actual coordinates or its width and height. Window_Command only asks you to send it some width and array of strings to be used as labels for every single option you'd ever need. Sprites don't necessarily need that, but you can pass a custom Viewport or later on call their setter methods to define its x and y coordinates. Their default values are well known, they're 0 and 0.

Passing Strings as Arguments

If you want to pass anything that is not a string to let the RM print it, use the .to_s method by appending it there. There's also a feature called interpolation and printf but they might be kind of advanced for most people. The only valid exceptions to this rules are puts and print, they might get ANY value and they'll try to print it at all costs. Happy with a sweat

Fear the Devious Loops! Laughing

Never place methods or complicated stuff there, especially if you don't need to keep updating them every single frame! Every single unnecessary stuff located there will slow down your script! Sad So don't even dare to place a second or third loop there ever!! Angry

Your Main Task

All scene scripts need a main method. Either you define it in your class or its parent class but you can never ever skip it! Angry You won't see anything related to it if you never defined it! Sad Actually your game should crash immediately! Happy with a sweat Never include a main method in Sprites or Windows!!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   RPG Developer Bakin: Material Albedo (with C# script) JayRay 0 1,474 01-19-2023, 04:59 AM
Last Post: JayRay
   When NOT to Use a Script kyonides 0 1,825 12-10-2021, 09:09 AM
Last Post: kyonides
   Script Writing and Usage: A canine perspective DerVVulfman 0 4,140 09-27-2019, 05:03 AM
Last Post: DerVVulfman
   RMVX Ace Script Call Eventing Procedures. JayRay 0 7,565 10-26-2013, 08:25 PM
Last Post: JayRay
Brick  WIP - Randomly Generating Terrain - RGSS azrith001 0 4,216 07-12-2012, 07:21 PM
Last Post: azrith001
   Next level RGSS - From beginner to expert deValdr 2 7,496 08-30-2011, 11:25 PM
Last Post: deValdr
   Creating a Proper Game Doc United Washcloth Express 2 6,837 02-22-2010, 11:33 PM
Last Post: Ace
   RGSS Roadguide Trickster 0 4,954 12-07-2008, 06:21 AM
Last Post: Trickster
   Regular Expressions in RGSS (Regexp) Zeriab 0 4,630 12-07-2008, 04:26 AM
Last Post: Zeriab



Users browsing this thread: 1 Guest(s)