simulate a digital clock using Textplus



Super noob alert :slight_smile:

OK what I wanna do is setting up a variable that goes up each second. but I want the variable resets to zero when it reaches lets say the value of 60.

here is a code I came up with. it works fine but only once:

a = s
if a < 60 then a else a - 60

I pretty much sure my question is super simple to you guys but I have no idea about scripting at all…sorry :slight_smile:


surely you would use modulus ?

I’ve tested to frame 20000…works…


modulus? you mean absolute value? but where and how should I use it? I didn’t exactly get what you mean…
could you please share the code you used? mine work only for the first 60 seconds…it resets to zero only the first time and then when it passes 60 for the second time, it gets higher…61-62 …
I want it to reset to zero every time it reaches 60


but everything is there in the pic…

use Expression

(modulus/modulo…whatever…it’s basic maths…look it up)


You don’t have to use any controller. You can directly put maxscript in the text window.
Try this
%<(mod sliderTime.frame 60) as integer>



ONE frame does not equal to ONE second

(and don’t bother to correct me for the one case when it does equal…that’s trivial)


oh I got it all wrong…I used abs as I thought you mean absolute value :slight_smile: (eg. making negative numbers to positive)

right now I used this:


as an expression and it works just fine



%<(mod (floor (sliderTime.frame/FrameRate)) 60) as integer>


isn’t there S (seconds) available in your method like in my expression ? that would be much simpler…

(or maybe even Time)


I’m just showing there is a way to directly input script in text window.


@gandhics How did you figure this out, because I didn’t find any documentation about this. It’s so much easier to just add scripts directly into the textinput…

This makes me wonder what other possible options there are besides:
%<> - script
%[] - values

Also, do you know if it is possible to add new macro value to the textplus object by means of scripts. Basically what you do with the user input via the ‘Set Value as Text’ dialog. I can find a workaround by linking a scripted controller to another property, but it would be nice to directly access the macro values and add one or two to them.

And is it just me, or does the textplus not always refresh the mesh when needed? There doesn’t seem to be a way to force this…