Ruby, RGSS & General Code Discussion
#7
(12-21-2012, 11:25 AM)Kain Nobel Wrote: I found an interesting little tidbit today! Actually I've found it before and forgot about it, but since I've been reminded...

Game_Battler#add_state

There
is a way for a method to call itself within its own definition,
but that is via the use of alias or alias_method. A child
method can call the definition of a parent's method by using a
super, a parent method can call other methods defined by it's
child class even if its not defined within its own class, but a method calling itself
just seems odd to me.

A freshly defined method shouldn't be able to call itself within it's own definition, should it?
That is actually a misconception. In RGSS, you can indeed have a method call itself recursively, just as you can in regular old Ruby. You only get the "stack level too deep" error if you actually make a stack that is too deep. Unfortunately for RGSS I remember this stack being really small (200 something if I remember correctly) and so recursive calls are not very useful when scripting. In this case, it is VERY unlikely states will be nested in a way to exceed the stack so this is an okay thing to do.
Reply }


Messages In This Thread
RE: Ruby, RGSS & General Code Discussion - by MechanicalPen - 12-22-2012, 05:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Possible means to speed up Bitmap TONE code? DerVVulfman 7 3,113 06-11-2023, 08:22 PM
Last Post: kyonides
   RGSS scripting dissections and explinations Siletrea 97 104,641 03-18-2019, 06:46 AM
Last Post: Siletrea
   Help iwth script (RGSS Player crash) Whisper 3 8,536 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,924 11-03-2015, 06:16 AM
Last Post: kyonides
   Custom Game_Event code lags too much! MechanicalPen 4 6,647 06-27-2013, 11:22 PM
Last Post: MechanicalPen
Question  RGSS stoped to work Chaos17 5 7,758 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   [Request] Tut. for RGSS Eldur 9 11,947 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [RUBY] Depack Thread Problem Narzew 1 4,393 07-20-2012, 01:16 PM
Last Post: Narzew
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 4,238 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Quick RGSS question - switches Ravenith 2 5,638 08-23-2009, 11:23 AM
Last Post: Ravenith



Users browsing this thread: 1 Guest(s)