compy111
|
  |
| Joined: 02 Apr 2009 |
| Total Posts: 583 |
|
|
| 23 Jun 2013 10:49 AM |
I always thought round is used to round a value like 3.9995 into 4 but now it says round is a nil value. What's wrong?
parts = game.Workspace:GetChildren() for i=1, #parts do if parts[i].ClassName == "Part" then print("Part being relocated") newx = (round(parts[i].Position.X/4))*4 newy = (round(parts[i].Position.Y/4))*4 newz = (round(parts[i].Position.Z/4))*4 parts[i].Position = Vector3.New(newx, newy, newz) end end
(The reason I make this script is because I built a huge church, looks quite cool and the stamper tool somehow messed it up and there are gaps in the walls at some locations) |
|
|
| Report Abuse |
|
|
Regress
|
  |
| Joined: 23 Jul 2011 |
| Total Posts: 119 |
|
|
| 23 Jun 2013 11:00 AM |
I don't think theres a round operator in lua, but there are plenty of hackish methods for it.
http://lua-users.org/wiki/SimpleRound |
|
|
| Report Abuse |
|
|
| |
|
compy111
|
  |
| Joined: 02 Apr 2009 |
| Total Posts: 583 |
|
|
| 23 Jun 2013 11:20 AM |
The only thing you chqnged is *4 into *3 isn't it? It has to be *4. Just want to get all parts (all parts are 4 by 4 by 4) back on the place they should be at. |
|
|
| Report Abuse |
|
|
| |
|
compy111
|
  |
| Joined: 02 Apr 2009 |
| Total Posts: 583 |
|
|
| 23 Jun 2013 11:28 AM |
4 can't be a nil value, 4 is 4. It says round is a nil value. Not 4. |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 11:37 AM |
You can make a supervisor code for your desired rounding.
This is just an improvised example.. Haven't needed to do this in a long time...
round = 1 -- 2,-1,0(decimal), 1,2
number = 123.4 wholelength = tostring(tonumber(math.floor(number))) decimal = tonumber(string.sub(number,#wholelength,(#wholelength+1+round))) if decimal == 5 or decimal >= 5 then number = tonumber(wholelength)+1 else number = tonumber(wholelength) end
A.K.A. math.floor() |
|
|
| Report Abuse |
|
|