Hi, im a newbie scripter and im trying learn about
math function. especcialy math.ceil or math.floor
i made a system before that rounds seconds
like if second is 45.7 it rounds it to 46 etc.
but i used a lot of if / elseif staircase to do that.
i want to learn how to do it with math.ceil and math.floor
can you guys show me how?
my current code :
if MaxTimesec > 1.5 and MaxTimesec < 2 then
MaxTimesec = 2
else if MaxTimesec < 1.5 and MaxTimesec > 1 then
MaxTimesec = 1
else if MaxTimesec < 0.5 and MaxTimesec > 0 then
MaxTimesec = 0
else if MaxTimesec > 0.5 and MaxTimesec < 1 then
MaxTimesec = 1
else if MaxTimesec > 2.5 and MaxTimesec < 3 then
MaxTimesec = 3
else if MaxTimesec < 2.5 and MaxTimesec > 2 then
MaxTimesec = 2
else if MaxTimesec > 3.5 and MaxTimesec < 4 then
MaxTimesec = 4
else if MaxTimesec < 3.5 and MaxTimesec > 3 then
MaxTimesec = 3
else if MaxTimesec > 4.5 and MaxTimesec < 5 then
MaxTimesec = 5
else if MaxTimesec < 4.5 and MaxTimesec > 4 then
MaxTimesec = 4
else if MaxTimesec > 5.5 and MaxTimesec < 6 then
MaxTimesec = 6
else if MaxTimesec < 5.5 and MaxTimesec > 5 then
MaxTimesec = 5
else if MaxTimesec > 6.5 and MaxTimesec < 7 then
MaxTimesec = 7
else if MaxTimesec < 6.5 and MaxTimesec > 6 then
MaxTimesec = 6
else if MaxTimesec > 7.5 and MaxTimesec < 8 then
MaxTimesec = 8
else if MaxTimesec < 7.5 and MaxTimesec > 7 then
MaxTimesec = 7
else if MaxTimesec > 8.5 and MaxTimesec < 9 then
MaxTimesec = 9
else if MaxTimesec < 8.5 and MaxTimesec > 8 then
MaxTimesec = 8
else if MaxTimesec > 9.5 and MaxTimesec < 10 then
MaxTimesec = 10
else if MaxTimesec < 9.5 and MaxTimesec > 9 then
MaxTimesec = 9
print(MaxTimesec)
else if MaxTimesec > 10.5 and MaxTimesec < 11 then
MaxTimesec = 11
else if MaxTimesec < 10.5 and MaxTimesec > 10 then
MaxTimesec = 10
else if MaxTimesec < 11.5 and MaxTimesec > 11 then
MaxTimesec = 11
else if MaxTimesec > 12.5 and MaxTimesec < 13 then
MaxTimesec = 13
else if MaxTimesec < 12.5 and MaxTimesec > 12 then
MaxTimesec = 12
else if MaxTimesec > 13.5 and MaxTimesec < 14 then
MaxTimesec = 14
else if MaxTimesec < 13.5 and MaxTimesec > 13 then
MaxTimesec = 13
else if MaxTimesec > 14.5 and MaxTimesec < 15 then
MaxTimesec = 15
else if MaxTimesec < 14.5 and MaxTimesec > 14 then
MaxTimesec = 14
else if MaxTimesec > 15.5 and MaxTimesec < 16 then
MaxTimesec = 16
else if MaxTimesec < 15.5 and MaxTimesec > 15 then
MaxTimesec = 15
else if MaxTimesec > 16.5 and MaxTimesec < 17 then
MaxTimesec = 17
else if MaxTimesec < 16.5 and MaxTimesec > 16 then
MaxTimesec = 16
else if MaxTimesec > 17.5 and MaxTimesec < 18 then
MaxTimesec = 18
else if MaxTimesec < 17.5 and MaxTimesec > 17 then
MaxTimesec = 17
else if MaxTimesec > 18.5 and MaxTimesec < 19 then
MaxTimesec = 19
else if MaxTimesec < 18.5 and MaxTimesec > 18 then
MaxTimesec = 18
else if MaxTimesec > 19.5 and MaxTimesec < 20 then
MaxTimesec = 20
else if MaxTimesec < 19.5 and MaxTimesec > 19 then
MaxTimesec = 19
else if MaxTimesec > 20.5 and MaxTimesec < 21 then
MaxTimesec = 21
else if MaxTimesec < 20.5 and MaxTimesec > 20 then
MaxTimesec = 20
else if MaxTimesec < 21.5 and MaxTimesec > 21 then
MaxTimesec = 21
else if MaxTimesec > 22.5 and MaxTimesec < 23 then
MaxTimesec = 23
else if MaxTimesec < 22.5 and MaxTimesec > 22 then
MaxTimesec = 22
else if MaxTimesec > 23.5 and MaxTimesec < 24 then
MaxTimesec = 24
else if MaxTimesec < 23.5 and MaxTimesec > 23 then
MaxTimesec = 23
else if MaxTimesec > 24.5 and MaxTimesec < 25 then
MaxTimesec = 25
else if MaxTimesec < 24.5 and MaxTimesec > 24 then
MaxTimesec = 24
else if MaxTimesec > 25.5 and MaxTimesec < 26 then
MaxTimesec = 26
else if MaxTimesec < 25.5 and MaxTimesec > 25 then
MaxTimesec = 25
else if MaxTimesec > 26.5 and MaxTimesec < 27 then
MaxTimesec = 27
else if MaxTimesec < 26.5 and MaxTimesec > 26 then
MaxTimesec = 26
else if MaxTimesec > 27.5 and MaxTimesec < 28 then
MaxTimesec = 28
else if MaxTimesec < 27.5 and MaxTimesec > 27 then
MaxTimesec = 27
else if MaxTimesec > 28.5 and MaxTimesec < 29 then
MaxTimesec = 29
else if MaxTimesec < 28.5 and MaxTimesec > 28 then
MaxTimesec = 28
else if MaxTimesec > 29.5 and MaxTimesec < 30 then
MaxTimesec = 30
else if MaxTimesec < 29.5 and MaxTimesec > 29 then
MaxTimesec = 29
else if MaxTimesec > 30.5 and MaxTimesec < 31 then
MaxTimesec = 31
else if MaxTimesec < 30.5 and MaxTimesec > 30 then
MaxTimesec = 30
else if MaxTimesec < 31.5 and MaxTimesec > 31 then
MaxTimesec = 31
else if MaxTimesec > 32.5 and MaxTimesec < 33 then
MaxTimesec = 33
else if MaxTimesec < 32.5 and MaxTimesec > 32 then
MaxTimesec = 32
else if MaxTimesec > 33.5 and MaxTimesec < 34 then
MaxTimesec = 34
else if MaxTimesec < 33.5 and MaxTimesec > 33 then
MaxTimesec = 33
else if MaxTimesec > 34.5 and MaxTimesec < 35 then
MaxTimesec = 35
else if MaxTimesec < 34.5 and MaxTimesec > 34 then
MaxTimesec = 34
else if MaxTimesec > 35.5 and MaxTimesec < 36 then
MaxTimesec = 36
else if MaxTimesec < 35.5 and MaxTimesec > 35 then
MaxTimesec = 35
else if MaxTimesec > 36.5 and MaxTimesec < 37 then
MaxTimesec = 37
else if MaxTimesec < 36.5 and MaxTimesec > 36 then
MaxTimesec = 36
else if MaxTimesec > 37.5 and MaxTimesec < 38 then
MaxTimesec = 38
else if MaxTimesec < 37.5 and MaxTimesec > 37 then
MaxTimesec = 37
else if MaxTimesec > 38.5 and MaxTimesec < 39 then
MaxTimesec = 39
else if MaxTimesec < 38.5 and MaxTimesec > 38 then
MaxTimesec = 38
else if MaxTimesec > 39.5 and MaxTimesec < 40 then
MaxTimesec = 40
else if MaxTimesec < 39.5 and MaxTimesec > 39 then
MaxTimesec = 39
else if MaxTimesec > 40.5 and MaxTimesec < 41 then
MaxTimesec = 41
else if MaxTimesec < 40.5 and MaxTimesec > 40 then
MaxTimesec = 40
else if MaxTimesec < 41.5 and MaxTimesec > 41 then
MaxTimesec = 41
else if MaxTimesec > 42.5 and MaxTimesec < 43 then
MaxTimesec = 43
else if MaxTimesec < 42.5 and MaxTimesec > 42 then
MaxTimesec = 42
else if MaxTimesec > 43.5 and MaxTimesec < 44 then
MaxTimesec = 44
else if MaxTimesec < 43.5 and MaxTimesec > 43 then
MaxTimesec = 43
else if MaxTimesec > 44.5 and MaxTimesec < 45 then
MaxTimesec = 45
else if MaxTimesec < 44.5 and MaxTimesec > 44 then
MaxTimesec = 44
else if MaxTimesec > 45.5 and MaxTimesec < 46 then
MaxTimesec = 46
else if MaxTimesec < 45.5 and MaxTimesec > 45 then
MaxTimesec = 45
else if MaxTimesec > 46.5 and MaxTimesec < 47 then
MaxTimesec = 47
else if MaxTimesec < 46.5 and MaxTimesec > 46 then
MaxTimesec = 46
else if MaxTimesec > 47.5 and MaxTimesec < 48 then
MaxTimesec = 48
else if MaxTimesec < 47.5 and MaxTimesec > 47 then
MaxTimesec = 47
else if MaxTimesec > 48.5 and MaxTimesec < 49 then
MaxTimesec = 49
else if MaxTimesec < 48.5 and MaxTimesec > 48 then
MaxTimesec = 48
else if MaxTimesec > 49.5 and MaxTimesec < 50 then
MaxTimesec = 50
else if MaxTimesec < 49.5 and MaxTimesec > 49 then
MaxTimesec = 49
else if MaxTimesec > 50.5 and MaxTimesec < 51 then
MaxTimesec = 51
else if MaxTimesec < 50.5 and MaxTimesec > 50 then
MaxTimesec = 50
else if MaxTimesec < 51.5 and MaxTimesec > 51 then
MaxTimesec = 51
else if MaxTimesec > 52.5 and MaxTimesec < 53 then
MaxTimesec = 53
else if MaxTimesec < 52.5 and MaxTimesec > 52 then
MaxTimesec = 52
else if MaxTimesec > 53.5 and MaxTimesec < 54 then
MaxTimesec = 54
else if MaxTimesec < 53.5 and MaxTimesec > 53 then
MaxTimesec = 53
else if MaxTimesec > 54.5 and MaxTimesec < 55 then
MaxTimesec = 55
else if MaxTimesec < 54.5 and MaxTimesec > 54 then
MaxTimesec = 54
else if MaxTimesec > 55.5 and MaxTimesec < 56 then
MaxTimesec = 56
else if MaxTimesec < 55.5 and MaxTimesec > 55 then
MaxTimesec = 55
else if MaxTimesec > 56.5 and MaxTimesec < 57 then
MaxTimesec = 57
else if MaxTimesec < 56.5 and MaxTimesec > 56 then
MaxTimesec = 56
else if MaxTimesec > 57.5 and MaxTimesec < 58 then
MaxTimesec = 58
else if MaxTimesec < 57.5 and MaxTimesec > 57 then
MaxTimesec = 57
else if MaxTimesec > 58.5 and MaxTimesec < 59 then
MaxTimesec = 59
else if MaxTimesec < 58.5 and MaxTimesec > 58 then
MaxTimesec = 58
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end