Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- simple function so you don't have to do the conversion from ticks to seconds when using computercraft
- function TicksToSeconds(s)
- s = string.lower(s)
- local endOfString = string.sub(s, -1)
- local number = string.sub(s, 1, -2)
- if (endOfString == "s") then
- return tonumber(number)
- elseif (endOfString == "t") then
- return ( tonumber(number) * 0.05 ) --one tick happens every 0.05 seconds
- else
- error("inputed string is not seconds nor ticks")
- end
- end
- -- examples
- print(TicksToSeconds("15t")) -- 15 ticks is 0.75 seconds
- print(TicksToSeconds("1s")) -- 1 second is still 1 second
- print(TicksToSeconds("1a")) -- wrong format will give an error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement