RGSS scripting dissections and explinations
#44
Very interesting discussion. I think I'll also add something.

(09-10-2017, 03:36 AM)DerVVulfman Wrote:  print "#{@substituted_player.name}, the kind of old hockey player, steps out right now and gets a seat in no time." This statement is printing out... => "Stan, the kind of old hockey player, steps out right now and gets a seat in no time."

This only works with String that using double quote ( " " ).
Single quote ( ' ' ) is faster than double quote, but lacks in flexibility.

That means, this will not work:
print '#{@substituted_player.name}, the kind of old hockey player, steps out right now and gets a seat in no time.'

So you have to do:
print @substituted_player.name [b]+ ', the kind of old hockey player, steps out right now and gets a seat in no time.'[/b]
Oh, that's too troublesome and kinda looked uglier than before.

If that's really the case, then is single quote is useless / inferior / trash / etc?
My answer is no, as a scripter I believe that we have to reduce the resources (RAM) consumption as high as possible.

I really want to know others opinion about this.



And I can't believe no one mentioning shortcut in ruby. This trick is essential for reducing script lines.

Why is script lines is important?
This is because of RMXP weird behavior. When the script lines exceeds 10k, something supernatural happens (glitch, increase starting time, hang, etc).
Also, which one is nicer to your eyes, looking at 10k++ lines script or less than 1k lines script?

But if your script isn't complicated and didn't require thousands of lines, this trick isn't that important.

Let's look at Game_Character#passable?
Code:
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)

WTH is that '?' and ':' means? Is it a new math operation like '+' or '-'?
Nope, that is a bunch of 'if and else' stacked together.

Content Hidden


Return to Game_Character#passable?. If that lines is dissected, it will became like this:
Content Hidden

That's 10 lines from the previously only 1 lines!


Another example, this is 'if' but without 'else':
Content Hidden

All 3 cases above result the same thing.
Reply }


Messages In This Thread
RE: RGSS scripting dissections and explinations - by LiTTleDRAgo - 09-10-2017, 01:16 PM

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,112 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,227 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: 19 Guest(s)