Codea 2.3: Tween Needs Time > 0

Greetings! So in 2.3, tweens can’t have a time of zero? This seems to be undocumented so I’d like to clarify.

@Goatboy76 What would be the purpose of setting a tween to 0.

EDIT: A tween can be set to .0000001, that might be close enough to 0.

@dave1707 I don’t think there is a purpose. I found out the hard way that I was doing this in my project. Seems strange.

@Goatboy76 Functions and parameters change as a language evolves and its the programmers responsibility to adjust to these changes. You’ve already seen changes going from Lua 2.2 to 2.3 and you’re finding and adjusting to them. I’m sure there will be more as time goes on. It isn’t easy to update all of the documentation to show these changes. That could be a job all by itself.

@dave1707 “The Language is what gives a Programmer his power. It’s an energy field created by all the computer programs. It surrounds us and penetrates us. It binds the internet together.” Thanks

I frequently used tween.delay(0, ...) to make a function be called on the next frame. Apparently, it was always bumped up to 0.001, but in 2.3 that bump was removed and instead it just gives an error.

The tween library used to contain this code:

 -- Don't allow 0 duration tweens
  if time == 0 then time = 0.001 end

I guess it was deemed unnecessary

@SkyTheCoder Thats a neat trick.

@yojimbo2000 Good to know.

This was an intentional removal, I very much disliked the hack that was in-place to allow durations of 0 — because it didn’t actually result in a tween with a duration of 0. The API wasn’t being truthful for the sake of convenience.

You can achieve the same functionality with math.max(duration, 0.001)

That said, I can see the use of a 0 duration for tween.delay (it essentially means “next frame”). But perhaps this should be formalised rather than use a hack.

One idea is that tween.delay( function ) triggers a next frame callback (i.e., duration unspecified, rather than 0).