Quote:
Originally Posted by screen_name
Now, I've seen this in other scripts as well. Just a few questions;
1. Can you explain why the temp. is not required or that just the way it is and I better accept it?
2. Also, does it only apply to temp.variables?
3. Are there any exceptions to this rule? I've noticed that you can use pc[0....10] or whatever to access variables created with temp.pc = player.chat.tokenize();
|
1) For
for() loops, yes.
2) If you mean using a
for() loop, no, but in most cases you'll want to unless you plan to loop through an array of things, find something specific, and use the data somewhere else.
3)
player.chat.tokenize() separates the player's chat at every space (" ") and put it in an array (
tokenize() can also separate at other points by using a string inside the
()). Using that in
temp.pc just makes it so you can access that data using
temp.pc (needed when defining it) or
pc (any time after defining it) and can only be called inside the function it was defined in.
Array sizes start at
0 for the first param and end at the number 1 less than the last param (in normal counting). Params are accessed using
[#]. As an example:
PHP Code:
function onCreated() {
temp.array = { 1,2,3 };
if (array[0] == 1)
echo("first param at [0]");
if (array[1] == 2)
echo("second param at [1]");
if (array[2] == 3)
echo("third param at [2]");
}