Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 RGSS scripting dissections and explinations
#60
(01-23-2018, 09:55 PM)kyonides Wrote: Here's another curious thing about classes in Ruby, they are not static, meaning you can add new methods at will. How many methods? That depends on you only! Getter methods like those created by attr_reader belong to their own class and not the copies you make of their class.

Class Game_Actor
attr_reader :age, :height, :weight, :hunger
def max_age
100
end
end

$game_actors[50] = Game_Actor.new(50)
$game_actors[50].name = "Evil Pod Pod"
$game_actors[50].age = 0

Here comes the explanation, I created a new actor namely Evil Pod Pod, even if you ask how long Aluxes, the first hero, should ever live or need to get Evil Pod Pod's end of cycle date, they both would only live 100 hours or 100 days or 100 years because we have not determine the basic life unit we will use to set the duration of their life cycles. Why do they all have the same  time limit? Because methods like max_age are class specific for they make no distinction between Aluxes or Evil Pod Pod, and they do not return a variable with a value, the maximum age, specific for the idiotic fighter or the newborn cat-droid. Variables like @age do belong to their owners, that idiot and that evil robot respectively.

$game_actors[1].age = 16
$game_actors[50].age = 0

Ask them how old they are...

p $game_actors[1].age
16
While Evil Pod Pod would reply she is not even one year old because she was born last October??
great info to know thank you very much!

lol Pod-Pod was technically "born" in 2011 as thats when she was designed! for official ingame though her birthdays not for another 595 years
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }


Messages In This Thread
RE: RGSS scripting dissections and explinations - by Siletrea - 01-23-2018, 10:13 PM

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



Users browsing this thread: