Rurith
|
  |
| Joined: 05 Jul 2011 |
| Total Posts: 9218 |
|
|
| 23 Apr 2014 08:43 PM |
| So, I need to add numbers, so when I say then , I want a thingy that adds 1+ (tO Anything) Just need that code where it +'s 1 |
|
|
| Report Abuse |
|
|
Rurith
|
  |
| Joined: 05 Jul 2011 |
| Total Posts: 9218 |
|
| |
|
|
| 23 Apr 2014 08:48 PM |
var = 1
print(var) >>1 var = var + 1 print(v) >>2 |
|
|
| Report Abuse |
|
|
Rurith
|
  |
| Joined: 05 Jul 2011 |
| Total Posts: 9218 |
|
| |
|
|
| 23 Apr 2014 09:24 PM |
Dude, learn scripting... I think what you need is this: function Add(n1,n2,n3,n4,n5) return(n1+n2+n3+n4+n5) end Add(1+WhateverYour#Is) |
|
|
| Report Abuse |
|
|
|
| 23 Apr 2014 09:24 PM |
Dude, learn scripting... I think what you need is this: function Add(n1,n2,n3,n4,n5) return(n1+n2+n3+n4+n5) end Add(1+WhateverYour#Is) |
|
|
| Report Abuse |
|
|
|
| 23 Apr 2014 09:57 PM |
| ^ You called the function wrong... |
|
|
| Report Abuse |
|
|
|
| 23 Apr 2014 10:21 PM |
@ImaCheeseBurger You did it wrong
local function Add(...) local Addends={...} local Sum=0 for i,v in pairs(Addends) do Sum=Sum+v end return Sum end
Don't tell other people to learn how to script when yours can only have 5 arguments. Please don't take this offensively though. |
|
|
| Report Abuse |
|
|
|
| 23 Apr 2014 11:08 PM |
local function Add(...) local Sum=... for i=2,select("#",...) do Sum=Sum+select(i,...) end return Sum end
This function lets you add anything with an __add metamethod. You can give it Vector3s, Vector2s, regular numbers, etc.
Add(thing1,thing2,thing3)
This is equivalent to
thing1+thing2+thing3 |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
| |
|