RGSS scripting dissections and explinations
#21
(09-07-2017, 06:26 AM)DerVVulfman Wrote: +=  Now that's a shortcut.   Instead of saying  a = a + 1, you say a += 1.   So each time we see a value of 'a', we add 1 to it.

-=  Another shortcut.  Just like above, this one subtracts from the value in question.

<  is a 'comparison' operator.  It means 'lesser than', and is used in checks like if a < b.   If the value of a is 15 and the value of b is 4, then it would be like if 15 is less than 3... Obviously not!  That test would FAIL.

And yeah, it is also used for the whole inheritance thing.  Laughing Pacman here does double duty.

>  is another 'comparison' operator.  It means 'greater than', and is used in checks like if a > b.   So again, if the value of a is 15 and the value of b is 4, then it would be like if 15 is greater than 3... NOW it works!  So that IF... block of code will run!

<= and >= respectively mean 'less than or equal to' and 'greater than or equal to'  Remember the test of if a < b?  If a was set to 5 and b was set to 5, then it would be if 5 was less than 5.... and again, FAIL.   But if we did if a <= b, it would work because it was not if a was less than OR EQUAL TO!!!

Equal signs!!!   What is different between = and   == ?   Well, the first replaces the contents of a variable and one does a comparison test.

a = 4 ....  this replaces the contents of variable 'a' with the value of '4'

if a == 4 .... this tests if the contents of variable 'a' equals '4'

Oh, the MODULO symbol!!!   It means the 'remainder'

%... otherwise the percentage symbol, it is used in programming to get the REMAINDER value of a division.  Like... um...  
If you divide 9 by 3, your value is 3, right?   There's no remainder.  It's clean and has nothing fractional.  But if you divide 9 by 2, you get 4 1/2 (or 4.5)  

NOW unless you tell the program that you are dealing with numbers with decimal values (we call them floats), you're only going to end up with whole numbers.  So an INTEGER version of 9 divided by 2 would actually equal 4!     That's where modulo comes in... it gets the remainder (or leftover part).  So the  9 % 2 would be '1'     It can handle dividing 8 by 2, and has a leftover 1 remaining.

EDIT:  Was I typing so long??????  Shocked

OHHHHHH so = equals will convert the 1st thing into the 2nd thing?! while == will see if they're the same!

ok so % is still a tad confusing? its like the smart way to divide?

yeah you type for a LOOONG time lol!

division is done with "/" right?

what does "\" do then?

or != I see that one pop up a few times
[Image: SP1-Writer.png]
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]

new logo for Yesteryear created by Lunarberry!
Reply }


Messages In This Thread
RE: RGSS scripting dissections and explinations - by Siletrea - 09-07-2017, 06:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Help iwth script (RGSS Player crash) Whisper 3 8,525 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,909 11-03-2015, 06:16 AM
Last Post: kyonides
   Scripting in VX vs VX Ace Miharu 5 9,080 02-21-2015, 10:10 AM
Last Post: Taylor
   Combat animations via scripting; How? ZeroSum 2 5,111 09-20-2013, 06:58 PM
Last Post: ZeroSum
Question  RGSS stoped to work Chaos17 5 7,744 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 10,875 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 11,903 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 4,225 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Scripting I think spazfire 7 10,168 04-12-2010, 03:21 AM
Last Post: DerVVulfman
   Beginner Scripting Tuts? KDawg08 1 4,134 03-31-2010, 11:03 PM
Last Post: Hsia_Nu



Users browsing this thread: 12 Guest(s)