Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 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 6,535 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,351 11-03-2015, 06:16 AM
Last Post: kyonides
   Scripting in VX vs VX Ace Miharu 5 8,167 02-21-2015, 10:10 AM
Last Post: Taylor
   Combat animations via scripting; How? ZeroSum 2 4,557 09-20-2013, 06:58 PM
Last Post: ZeroSum
Question  RGSS stoped to work Chaos17 5 6,880 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 9,852 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 10,550 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 3,853 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Scripting I think spazfire 7 8,918 04-12-2010, 03:21 AM
Last Post: DerVVulfman
   Beginner Scripting Tuts? KDawg08 1 3,672 03-31-2010, 11:03 PM
Last Post: Hsia_Nu



Users browsing this thread: