|
| 24 Feb 2016 08:00 PM |
| Isnt it a variable for something in a function that will be called at the end of the script? |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 08:01 PM |
| I know there are default parameters relevant to something in the event but ive seen people put random variables. |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 08:03 PM |
A variable is something that you can store other things inside, such as a table, or a string.
Example:
x = (1 + 2) -- This sets "x" as a variable that stores the string "(1+2)"
print(x) -- This prints the variable. The outcome would be:
3
~MightyDantheman |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 24 Feb 2016 08:08 PM |
parameters are the variables given to the function to call it
arguments are the variables in the function call
function foo(a,b) -- a and b are parameters print(a,b) end
foo("bar","rab") -- "bar" and "rab" are arguments
|
|
|
| Report Abuse |
|
|
Moronism
|
  |
| Joined: 08 Feb 2010 |
| Total Posts: 451 |
|
|
| 24 Feb 2016 08:12 PM |
Parameters are localized versions of arguments "passed" to a given function.
Example:
Money = 100;
function New_Money(M)
M = M - 1;
return M;
end
print(New_Money(Money)); --This would print 99
Note that within the function known as "New_Money", "M" is the single parameter available.
Since "M" is a local variable, the modifications to M will not extend to the variable "Money." It is limited solely to the scope of the function it was created within.
Thus, "Money" will still be equivalent to 100. |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 09:22 PM |
You tardbag, M is not a local variable.
-MetallicFrog | 15,000 posts | Scripter | Builder | |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Feb 2016 09:33 PM |
But his explanation is wrong.
'Since "M" is a local variable, the modifications to M will not extend to the variable "Money." It is limited solely to the scope of the function it was created within.' That's not why it does that bud |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 09:34 PM |
Sorry, I forgot about the title. :T
~MightyDantheman |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 09:46 PM |
No, what I'm saying is that it's not local in the sense that I could print(M) outside of the function.
-MetallicFrog | 15,000 posts | Scripter | Builder | |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 24 Feb 2016 09:50 PM |
Really? I always thought it needed a prefix of local. Must be my mistake, thanks for letting me know! My knowledge grows again! *And the crowd starts clapping in happiness for me*
-MetallicFrog | 15,000 posts | Scripter | Builder | |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Feb 2016 09:52 PM |
| Parameters are local variables, M can only be accessed from inside that function. |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 09:53 PM |
Well, that would explain why. Thanks for letting me know- but do you care to take a look at my rating thread? I need some opinions from experienced people, I've only been coding and building for a short period.
-MetallicFrog | 15,000 posts | Scripter | Builder | |
|
|
| Report Abuse |
|
|
|
| 24 Feb 2016 09:54 PM |
| That makes sense so after the ends i would have to re define it. |
|
|
| Report Abuse |
|
|