RGSS scripting dissections and explinations
#41
I hate to highlight stuff on my phone -_-

Err, they wield an L shaped stick that they use to hit a black disk... yeah, it's a cold place with an icy floor...

Substitute = Replace = Exchange was just a way to tell you that they are synonyms or words with similar meanings, not actual classes or modules.

THERE IS NO SPECIFIC CLASS for substitutions, mainly because strings or those arrays of many characters set in a row and surrounded by quotes, either ' ' or " " are able to let you substitute some of its characters. We have showed you two ways to substitute characters, but there are two additional methods that may replace any character, but they may also use regex or regexp or regular expressions. You should not use regular expressions if you havent fully understand expression substitutions. Expressions are either idioms or words or weird characters like %s (a percent symbol and some s character), you place them inside strings when they may have changing values.

Lets say that you change Pod Pod's name during gameplay to Evil Pod Pod, let's supposed a chip malfunctions and she becomes quite evil.

class Window_ActorName < Window_Base
  def initialize(x, y, 160, 64)
    super
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.draw_text(0, 0, width - 32, 32, $game_party.actors[0].name, 1)
  end
end

There we defined a new window with some unknown x and y coordinates, 160 as its width and 64 as its height.

super is a pseudo variable, it helps you call our window's parent class, Window_Base. Our window passed x, y, width and height to Window_Base because it is mandatory, you would get an error otherwise. Since super was left inside the initialize method, it called Window_Base initialize method to set our window's x and y coordinates, its width and its height. Even if you cannot read it here, it also set the windowskin, that ugly blue box with a thin white border.

self.contents is a Bitmap, remember its a class that handles text and drawings of any color.  draw_text prints our labels or texts for us on screen inside that horrible blue box. Its first parameter is x, followed by y, a custom width, a custom height, our text and optionally 0 1 or 2 as a way to tell it to print our text aligned to the left hand side, centered or to the right hand side respectively.

What's our text here? $game_party.actors[0].name

$game_party equals a copy of Game_Party class where you can find an array named @actors. There it stored your game's heroes including Pod Pod or Evil Pod Pod XD

$game_party.actors[0] equals your first hero in the array. If she's Pod Pod then its name on screen will be Pod Pod.
"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 }


Messages In This Thread
RE: RGSS scripting dissections and explinations - by kyonides - 09-10-2017, 02:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Help iwth script (RGSS Player crash) Whisper 3 8,529 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,915 11-03-2015, 06:16 AM
Last Post: kyonides
   Scripting in VX vs VX Ace Miharu 5 9,090 02-21-2015, 10:10 AM
Last Post: Taylor
   Combat animations via scripting; How? ZeroSum 2 5,113 09-20-2013, 06:58 PM
Last Post: ZeroSum
Question  RGSS stoped to work Chaos17 5 7,747 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 10,884 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 11,907 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 4,228 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Scripting I think spazfire 7 10,170 04-12-2010, 03:21 AM
Last Post: DerVVulfman
   Beginner Scripting Tuts? KDawg08 1 4,137 03-31-2010, 11:03 PM
Last Post: Hsia_Nu



Users browsing this thread: 14 Guest(s)