Notifications
Clear all

[Closed] simulate a digital clock using Textplus

hi

Super noob alert

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

10 Replies

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)

1 Reply
(@esisb)
Joined: 10 months ago

Posts: 0

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

right now I used this:

mod(S,60)

as an expression and it works just fine

tnx

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>

wrong.

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)

1 Reply
(@gandhics)
Joined: 10 months ago

Posts: 0

OK… OK…
%<(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)

1 Reply
(@gandhics)
Joined: 10 months ago

Posts: 0

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…