09-10-2017, 01:16 PM
(This post was last modified: 09-10-2017, 02:50 PM by LiTTleDRAgo.)
Very interesting discussion. I think I'll also add something.
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?
WTH is that '?' and ':' means? Is it a new math operation like '+' or '-'?
Nope, that is a bunch of 'if and else' stacked together.
Return to Game_Character#passable?. If that lines is dissected, it will became like this:
That's 10 lines from the previously only 1 lines!
Another example, this is 'if' but without 'else':
All 3 cases above result the same thing.
(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.