09-10-2017, 04:58 PM
(This post was last modified: 09-10-2017, 04:59 PM by DerVVulfman.)
Hey, ya came in on your birthday!
I agree with you regarding the usage of the single-quote (') vs double-quote (") options. It is true that double-quotes are more powerful and can give you more options, but they do use more memory resources and take more time to process.
LIKEWISE.... another reason to avoid the use of global variable in your scripts (ie the $ variables) is that while they can span throughout your game, they too use more memory resources and take more time.
Best to cover explanations why things work, not just what works. Not everyone has the same learning conditions. While some people may be geniuses in 3D modeling, the educational system might have not picked up other learning disabilities. Our Siletrea is one such person, a true Savant with 3D animations, but is autistic. Better beware. anyone seen Ben Affleck's 'The Accountant'?
So, let's break down what LiTTleDRAgo offered for the different options of comparing data
FIRST, our data itself: array = [23,40,320,3020] We're just naming this array (list of values)... 'array' Just something nice and neat. And it holds four values: 23, 40, 320 and 3020. AND... remember what I said about an array's 'index' value... the Index value of an array begins with '0' (zero), not '1'. The first value in this array is called index value 0, the second would be index value 1, the third would be index value 2, and the last would be index value '3'. Counting the indexes begin with 0 and not 1.
So if I ask for the value of array[2] in my code, I would get the value of 320
Now all three examples that LiTTleDRAgo do basically the same thing. If something happens, the array is cleared... erased... gets empty. The command array.clear will clear/erase the array. If he named his array 'frodo_baggins' instead of 'array', he would have used the command 'frodo_baggins.clear' instead. But that's something else when we get to understanding arrays, when you ask.
And I just realized that LiTTleDRAgo blew it as his array has only four values and indexes count from 0. I'm adjusting his examples as there is no data in an index value of '4'.... there is no fifth piece of data in the array.
THE FIRST example:
if array[2] > array[3]
array.clear
end
Very simple. This is your simple IF...end block. The first line is your comparison.... If it is true, it does everything down until it hits the 'end' statement for that block. In this case, it will do it's job if the value in 'array[2]' (or 320) is greater than the value in 'array[3]' (or 3020), And again, that goofy 'array.clear' statement just erases the data in the array.
THE SECOND example:
array.clear if array[2] > array[3]
THIS is how I like to shorten my code. This is also a variation of the IF...end block, except it can all be done on one line if your block of code is just that short.
The actual command of 'array.clear' is the first thing you see, but it has the actual "IF' condition right next to it. And the IF condition is also the same 'if the value of 320 is more than 3020'...
OR, you could say (...hehehe...)
canadians can get drunk if age > 18
......Sound familiar?
NOW FOR THE THIRD example...
(array[2] > array[3]) && array.clear
FIRST, notice that we're back to a layout where we check the condition first (array[2] > array[3]) and THEN only perform the actual code if the condition is true. [/b]&& array.clear[/b]
He put the actual test, the IF portion, in parenthesis. Remember how I said parenthesis holds values and the whole math thingie called 'precedence rules'? This keeps his whole comparison of 'array[2] > array[3]' clean and separate from everything else in that line of code.
Now AFTER that, he has && array.clear. You've seen how I said that the & symbol means 'and', right? Well, the '&&' symbol is called a logical operator and sorta means 'THEN'. So the statement is like if (arrays compared) THEN array.clear.
or....
( age > 18 ) & (location == canada) && canadians_can_get_drunk
Had to make sure you were in Canada too.
I agree with you regarding the usage of the single-quote (') vs double-quote (") options. It is true that double-quotes are more powerful and can give you more options, but they do use more memory resources and take more time to process.
LIKEWISE.... another reason to avoid the use of global variable in your scripts (ie the $ variables) is that while they can span throughout your game, they too use more memory resources and take more time.
Best to cover explanations why things work, not just what works. Not everyone has the same learning conditions. While some people may be geniuses in 3D modeling, the educational system might have not picked up other learning disabilities. Our Siletrea is one such person, a true Savant with 3D animations, but is autistic. Better beware. anyone seen Ben Affleck's 'The Accountant'?
So, let's break down what LiTTleDRAgo offered for the different options of comparing data
FIRST, our data itself: array = [23,40,320,3020] We're just naming this array (list of values)... 'array' Just something nice and neat. And it holds four values: 23, 40, 320 and 3020. AND... remember what I said about an array's 'index' value... the Index value of an array begins with '0' (zero), not '1'. The first value in this array is called index value 0, the second would be index value 1, the third would be index value 2, and the last would be index value '3'. Counting the indexes begin with 0 and not 1.
So if I ask for the value of array[2] in my code, I would get the value of 320
Now all three examples that LiTTleDRAgo do basically the same thing. If something happens, the array is cleared... erased... gets empty. The command array.clear will clear/erase the array. If he named his array 'frodo_baggins' instead of 'array', he would have used the command 'frodo_baggins.clear' instead. But that's something else when we get to understanding arrays, when you ask.
And I just realized that LiTTleDRAgo blew it as his array has only four values and indexes count from 0. I'm adjusting his examples as there is no data in an index value of '4'.... there is no fifth piece of data in the array.
THE FIRST example:
if array[2] > array[3]
array.clear
end
Very simple. This is your simple IF...end block. The first line is your comparison.... If it is true, it does everything down until it hits the 'end' statement for that block. In this case, it will do it's job if the value in 'array[2]' (or 320) is greater than the value in 'array[3]' (or 3020), And again, that goofy 'array.clear' statement just erases the data in the array.
THE SECOND example:
array.clear if array[2] > array[3]
THIS is how I like to shorten my code. This is also a variation of the IF...end block, except it can all be done on one line if your block of code is just that short.
The actual command of 'array.clear' is the first thing you see, but it has the actual "IF' condition right next to it. And the IF condition is also the same 'if the value of 320 is more than 3020'...
OR, you could say (...hehehe...)
canadians can get drunk if age > 18
......Sound familiar?
NOW FOR THE THIRD example...
(array[2] > array[3]) && array.clear
FIRST, notice that we're back to a layout where we check the condition first (array[2] > array[3]) and THEN only perform the actual code if the condition is true. [/b]&& array.clear[/b]
He put the actual test, the IF portion, in parenthesis. Remember how I said parenthesis holds values and the whole math thingie called 'precedence rules'? This keeps his whole comparison of 'array[2] > array[3]' clean and separate from everything else in that line of code.
Now AFTER that, he has && array.clear. You've seen how I said that the & symbol means 'and', right? Well, the '&&' symbol is called a logical operator and sorta means 'THEN'. So the statement is like if (arrays compared) THEN array.clear.
or....
( age > 18 ) & (location == canada) && canadians_can_get_drunk
Had to make sure you were in Canada too.