Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 RGSS scripting dissections and explinations
#48
Oh no, that's a misinterpretation...

&& = and
&& != then

&& is not a THEN, THEN is different syntax.

if a < b and a > 0
if a < b && a > 0

Those two are the same thing. So if you do this :
if a < b then a > 0

It will be wrong in all sense.

And so, about the logic from (array[2] > array[3]) && array.clear, I think I need rewording it for a bit.

What I used in there, is behavior of ruby (or perhaps all of programming language), not the logic "THEN".
When using && in a conditional, if the first sentence "(array[2] > array[3])" is wrong, the second sentence array.clear will not be executed.
That's why you can exploit it to replace "if" in some occasion.

Let's look at this example:
(0 + 1 == 1) && (1 + 1 == 2) && (2 + 2 == 4) && (4 + 4 == 5) && (5 + 5 == 10) && print "ALL CORRECT"

If looking at the sentences there, you can see that (4 + 4 == 5) is totally wrong, so if you dismantle it, it will look like this:

true && true && true && false && true && print "ALL CORRECT"
true and true and true and false and true and print "ALL CORRECT"

The process would stop at false and the program will not print "ALL CORRECT".
Or more correctly, the program will not read (5 + 5 == 10) and rest of the sentence at all.

Actually "or" / "||" also can be exploited into shortcut but I think I'll pass explaining it for now, maybe tomorrow.
Reply }


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

Possibly Related Threads…
Thread Author Replies Views Last Post
   Help iwth script (RGSS Player crash) Whisper 3 7,674 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,383 11-03-2015, 06:16 AM
Last Post: kyonides
   Scripting in VX vs VX Ace Miharu 5 8,207 02-21-2015, 10:10 AM
Last Post: Taylor
   Combat animations via scripting; How? ZeroSum 2 4,572 09-20-2013, 06:58 PM
Last Post: ZeroSum
Question  RGSS stoped to work Chaos17 5 6,930 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 9,916 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 10,612 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,984 04-12-2010, 03:21 AM
Last Post: DerVVulfman
   Beginner Scripting Tuts? KDawg08 1 3,685 03-31-2010, 11:03 PM
Last Post: Hsia_Nu



Users browsing this thread: