generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: What is tick()?

Previous Thread :: Next Thread 
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
13 Aug 2013 06:28 PM
Ive encountered it in the past a couple of times. I finally searched it up, twas a system made in 1970 or whatever.

It can be used to tell how long a part is instanced and such.

Although, I see people use it differently, rather than calculating the time of which an object is instance ._.

Halp pls
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
13 Aug 2013 06:33 PM
tick() is a function that returns the UNIX time of which the server has been running.
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
13 Aug 2013 06:37 PM
Odd, you usually return with a full, in depth explanation.

Let me make myself clearer, what would you use it for?
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
13 Aug 2013 06:42 PM
Prolly,

because he could tell by your question that u could not even read the answer when it was in front of you:

if u read tick()

a = tick()

Then read it some time later

b= tick()

then u can ask things like: How long ago was it that it read tick, last time:

ElapsedTime = b-a


It just clock which has been running, since 1970, and which u can read.
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
13 Aug 2013 06:43 PM
Hmm, I dont see a practical use for it. Hey, thats just me.

Unless..I guess plan 901 is a go after all.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Aug 2013 06:50 PM
I don't know what they hell these people are talking about.

Basically tick counts all the time that has passed since 1970 Jan 1st.

print(tick()) -- some long number

print(tick()/(60*60*24/365)) -- how many years have passed since then

print("The year is ".. 1970+tick()/(60*60*24/365))
Report Abuse
bohdan77 is not online. bohdan77
Joined: 10 Aug 2008
Total Posts: 7944
13 Aug 2013 06:58 PM
lordrambo, When trying to help someone please fix your scripts. :)

"The year is 5816723.6903153"
Report Abuse
Salinas23 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37141
13 Aug 2013 06:59 PM
Wowowowow what
I thought tick() was used for REAL random numbers.

==Salinas23, LMaDer since August 2012! Scripter since July 2013!
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
13 Aug 2013 07:01 PM
@Salinas
That's because you can use

    math.randomseed(tick())

before you use math.random() in order to have a new seed (the number that the other numbers are based off of - same seed = same number)

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
Salinas23 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37141
13 Aug 2013 07:01 PM
Oh that explains a lot
thanks :D

==Salinas23, LMaDer since August 2012! Scripter since July 2013!
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
13 Aug 2013 07:03 PM
You did break my concentration @ MrHebes, probably also my nose.

Unlike most Scripters, I have a hard time understanding non relatable parts of Lua

So I need a proper explanation.

Well, time to search google
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
13 Aug 2013 07:14 PM
It's completely relatable.

tick() returns the number of seconds since 00:00:00 on January 1st, 1970, accurate to the 3rd decimal place.

So essentially, it's a constantly increasing number that could be used for things like:
- Since the seconds are based on a date, you can use math to figure out the date and time
- You could create a stopwatch by using a function like this:

    local timeElapsed = 0
    local counting = false
    function startTimer()
        timeElapsed = 0
        counting = true
        local startTick = tick() -- Set the starting time to whatever tick() is at this precise moment
        while counting do
            wait()
            timeElapsed = tick() - startTick -- Change the elapsed time to the length of time elapsed since the startTick
        end
    end
    function stopTimer()
        counting = false
    end



~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
K1D4 is not online. K1D4
Joined: 13 Jun 2013
Total Posts: 10006
13 Aug 2013 07:15 PM
Good luck with the Attack on Titan game. ;]

[I see you're making one.]

◙ℐᾔᾔ◎√α⊥℮◙
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
13 Aug 2013 07:28 PM
I have to admit, it's quite close to useless. However, I was able to make a game that allows you to control your FPS, while using tick() to keep it on track. Along with using it with randomseed, I haven't been able to find any real uses for it.
http://www.roblox.com/Lag-Controlling-place?id=42873078

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
bohdan77 is not online. bohdan77
Joined: 10 Aug 2008
Total Posts: 7944
13 Aug 2013 07:32 PM
Mcbilly, Another use is timing something. Say you have a store in your game, and you want people to rent whatever you sell.
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
13 Aug 2013 07:33 PM
Personally, I've always used a wait for that, but using tick is an interesting idea.

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
13 Aug 2013 07:34 PM
LinkedSwords use tick(), you nobs.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Aug 2013 07:47 PM
print("The year is ".. 1970+tick()/(60*60*24)/365)

My order of operations was off. That will work.

print(1970+tick()/(60*60*24)/365 - math.floor(1970+tick()/(60*60*24)/365).. " Percent through the year "..math.floor(1970+tick()/(60*60*24)/365))

:3
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
13 Aug 2013 07:48 PM
does nawt

~ Oh, I'm sorry, did I break your concentration? ~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image