View Single Post
  #10  
Old 01-17-2014, 05:59 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by i8bit View Post
Not saying you guys are wrong, but for me, Starfire's script is the only one I can really understand. Till new to scripting..

I'm still confused on what Return is doing in script..?
Here you go [BlueMelon's method...]

PHP Code:
//This is a function for breaking down a large
//number and storing it as individual elements in an array
function numberToArray(temp.n) {
  
//defining temp.n as an absolute value -- no negatives
  
temp.abs(temp.n);
  
//setting blank array
  
temp.digits = {};
  
  
//make sure there is a number in temp.n
  
while(temp.!= 0) {
    
//if you don't know what % does,
    //look up "modulo" on google
    //this is inserting each digit into the
    //temp.digits array from earlier
    
temp.digits.insert(0temp.10);
    
temp.int(temp.n/10);
  }
  
//this returns the array we just set up...
  
return temp.digits;
}

function 
onCreated() {
  
temp.fullnumber 482;
  
  
//here's an example of what return does...
  //explained below...
  
temp.digits numberToArray(temp.fullnumber);
  echo(
temp.digits[0]); // 4
  
echo(temp.digits[1]); // 8
  
echo(temp.digits[2]); // 2

Return basically works like this:
you can set up a function to perform some actions, like sorting these numbers 54925 into an array. well once you've sorted them and put them into the array, you are telling the function to RETURN the data you've gathered or sorted when that function is called

in the example above temp.digits = The Array the function numberToArray(temp.fullnumber) is returning...

Hope that helps a bit...
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote