Jump to content

Is Lua really limited?


ShayF2

Recommended Posts

Posted

Who here has had a limitation with lua? A point where they wanted to do something and they couldn't with lua. Respond your limits, see how far you can really go.

Posted

A simple sleep() function that can accurately do less than 50ms  (cant rely on counting frames or anything like that)

I think something could be rigged up with  coroutines and os.clock(), but I cant think of a way to condense it to where I just have to call the function once

Posted (edited)

@spenkbang

local seconds = 0

local timer = setTimer(function() seconds = seconds + 1 end, 1000, 0)

function stopCount()
	killTimer(timer)
	return seconds
end

or you can try a loop function

local seconds = 0

function startCount()
	seconds = seconds + 1
	return continue()
end

function continue()
	seconds = seconds + 1
	return startCount()
end

function stopCount()
	continue = function() end
	return seconds
end

Which can go less than 50 ms, this should be capable of getting close to 1ms

Edited by ShayF

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...