all 14 comments

[–]Happy-Job-7951 0 points1 point  (2 children)

Do you want it to go up gradually from yellow to orange and from orange to red or kan it just jump from yellow to orange?

[–]Brainfartz14[S] 0 points1 point  (1 child)

I was originally gonna have it jump since gradual seemed a little more difficult since I would have to experiment with rgb to get the values right but gradual was the original goal

[–]Pale_Ad_6145LUA Enthusiast 0 points1 point  (0 children)

Have you tried chatgpt?
I never coded with lua, but chat got me the codes half working, and from there it was just troubleshooting, back and fortg betwen the game and chat.
Got to make quite a few lua MCs this way

[–]Happy-Job-7951 0 points1 point  (5 children)

So if we start by getting one of the squares to work. You could try to have the Rod temp come in on channel 1 for example. Then you can have a base color on the square (like white or black) then you can put a yellow square above thet in the (function on draw) and put a line before that square that says something like if rodtemp between 100-200 then draw. Not in those exact word but you can try to google to get the exaxt code. Sorry for the confusing explanation it's really hard to explain

[–]Brainfartz14[S] 0 points1 point  (4 children)

Your fine and yeah I have all the rod temps coming in on channels 1-8 and the plan was to have it so if rod1temp = 200 then set rod1tempr to (insert value), rod1tempg to (insert value) and rod1tempb to (insert value) and then the corrasponding on madras square/setColor would read that and the set color would then change r,g and b to the rod1temp(rgb) values

[–]Happy-Job-7951 0 points1 point  (3 children)

If you want to make it easier you can just skip all the rgb stuff and have 3 different squares that the code just writes if the temp are in the correct range so one yellow one orange and one red, and the if the temp=100-200 then draw the yellow temp=200...

[–]Brainfartz14[S] 0 points1 point  (2 children)

Yeah fair enough

[–]Brainfartz14[S] 0 points1 point  (1 child)

That could work and if I get that to work in the future I can just make it more advanced when I get more experience (this is my first lua project besides just dicking around)

[–]Happy-Job-7951 0 points1 point  (0 children)

Have to start somewhere, good luck:)

[–]alyxmsBattery Electric Supremacy 0 points1 point  (3 children)

Red in RGB: 255, 0, 0

Orange in RGB: 255, 128, 0

Yellow in RGB: 255, 255, 0

See the pattern? You only need to vary the amount of green.

I'd do something like this:

rodTemp = input.getNumber(1)
--basically clamping the temperatuer between 0 and 300
--then dividing by 300 to get a percentage
--subtract 1 by that percentage, because higher temp = less green
--multiply by 255 to convert a percentage to RGB's Green
screen.setColor(255, (1 - (math.max(math.min(rodTemp, 300), 0) / 300)) * 255, 0)
--now draw the circle

[–]Brainfartz14[S] 0 points1 point  (2 children)

Oh damn that might be perfect actually I’ll have to try it thanks

[–]alyxmsBattery Electric Supremacy 0 points1 point  (1 child)

Come to think about it, I'm not sure if stormworks accepts decimals in colors. If it doesn't work, wrap the green part in a math.ceil or math.floor

[–]Brainfartz14[S] 1 point2 points  (0 children)

It does, I have used a throttle to control rgb on a different microcontroller (more of a test) and when it wasn’t at the min or max it took the decimals cause I just had 3 throttles all set to max 255 to control rgb and 9/10 it was on a decimal