View Single Post
  #5  
Old 08-22-2009, 07:27 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by screen_name View Post
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();
I meant parameter names with what I stated but it's also true with temp. vars.

If I do this:

PHP Code:
function myFunction(foobar) {

I could read the values of foo and bar by just using the words foo and bar without any prefixes (i.e player.chat = foo SPC bar; or so).

Now, with regards to temporary variables, you only need to use the temp. prefix when first defining them and then all other instances after that you don't need to. It's similar to the whole parameter naming I mentioned above where at first you just need to tell the engine that you're defining a temporary variable for the function, once you have defined it, you no longer need to use a prefix to access it.

So:

PHP Code:
function myFunction() {
  
temp.fooBar "apples";
  
player.chat fooBar;

Of course, you could still use the temp. prefix if you would like but it isn't necessary:

PHP Code:
function myFunction() {
  
temp.fooBar "apples";
  
player.chat temp.fooBar;

^Would work the same.


This doesn't work with this. vars., since this. vars can be accessed throughout the entire script whereas temp. vars are restricted to the function they are created in.
Reply With Quote