[Solved] Fix TimeDelta() for RGB color picker

I’m attempting to fix my code and use TimeDelta to add/subtract values from my color pickers. They can’t have decimals, so I have ceil in the expression, but using floor gives the same result. What am I doing wrong?

Here’s the UI showing 257 on the red bucket (needs to not exceed 255)…

And here are the events for it.

Quickly glancing, you can try an event/sub-event that triggers once when the colour picker touch is released, and the chosen colour is over 255 (or under 0), then setting it back to 255, and doing the normal “set colour” event.

Out of curiousity, what happens when the colour picker goes above 255? I assume it’s just the same as 255 colour value.

1 Like

If it’s anything like when I tried to make flashing text, if it goes above 255 it’ll go invisible.

Edit: Before I forget, @Phenomena, they have a new Clamp function that may fix this for you. It’s not on the wiki, but it’s in the expression builder. I’d say do clamp(Whateveryou’redoingwithTimedelta,0,255) and see if that helps.

Double edit: To be clear, you can’t clamp TimeDelta, you’d clamp “area.r”. So it’d be “Change the Text of color_value: set to ToString(clamp(GlobalVariable(area.r),0,255))”

1 Like

Thanks both!

Clamp didn’t do the trick (I tried it before), but the sub-event idea seems to be working like a charm. I set it where if any of the values are equal to or greater than 256, do 255 to the variable and update the text. Same for subtracting color except if the condition is less than 0, do 0 to the variable & text.


It turns black like in the image.

Sorry, I should have specified that the frame is selected here and I haven’t updated the variable names yet to be frame.r, etc.

Now I want the work day to be over so I can fix all the other events and get it uploaded :grin:

Mods; I’ll mark this as solved at that point as I want to be absolutely sure it’s fixed first.

Clamp should definitely work. Take a look at my issue and resolution here. I actually solved my issue testind for yours. :smile:


I’m not at my laptop right now, but it didn’t work for this. It did force the variable in the text object to not exceed 255, but that was only part of the problem - modifying the text object doesn’t change the color of the sprite in this case.

I appreciate both suggestions either way :relaxed:

Yeah. My setup had a text object displaying the variable too. The event setup in my last screenshot shoooould work, but no worries if you solved it another way.

1 Like

On closer look, but still at a glance on the go here, I see what you mean now and how it should work. I might experiment with both suggestions and see which is fastest on all the editing. Thanks!

1 Like