Stormworks: Build and Rescue

Stormworks: Build and Rescue

No hay suficientes valoraciones
Dynamic Up/Down counter
   
Premio
Favoritos
Favorito
Quitar
Etiquetas: v1.6.8
Tamaño
Publicado el
Actualizado el
161.882 KB
15 OCT 2022 a las 12:12 p. m.
5 DIC 2022 a las 10:18 a. m.
6 notas sobre cambios ( ver )

Suscríbete para descargar
Dynamic Up/Down counter

Descripción
Up/Down counter with an increment that can be multiplied.
LUA is not my primary programming language, so there might be stuff that can be improved. If so, please let me know!

Features:
-Variable increment (A feature the standard Up/Down counter does not have).
-Precise clamp.
-Option to turn the clamp off.
-Lots of comments in code to make it easier to understand.

Code:
-- Up/Down counter with changable Increment --LICENSE: Feel free to use it on any of your creations but leave this line unchanged. Made by MaxMustermann. x = 0 INCREMENT_X = 0.01 --The value that is later multiplied by "incrementMultipier" and then outputed CLAMP = true -- Clamps (restricts) the min/max output of the counter. ("MAX_VALUE", "MIN_VALUE") MAX_VALUE = 1 -- Highest possible value **CANT BE LESS THAN "MIN_VALUE" else the script will break! MIN_VALUE = -1 -- Lowest possible value **CANT BE GREATER THAN "MAX_VALUE" else the script will break! RESET_VALUE = 0 function calcActualChange() incrementMultipier = input.getNumber(1) -- Multiplier for "incrementX" **HAS TO BE MORE THAN 0 FOR "x" TO INCREASE** return (INCREMENT_X*incrementMultipier) end function onTick() increaseX = input.getBool(1) -- **Bool** from axis threshold (Put the seat axis at 100%) decreaseX = input.getBool(2) -- **Bool** from axis threshold (Put the seat axis at 100%) reset_counter = input.getBool(3) if reset_counter == true then -- Sets "x" to the value of "RESET_VALUE" if variable reset_counter is == true x = RESET_VALUE end if increaseX == true then if CLAMP == true then x = math.min((x+calcActualChange()), MAX_VALUE) -- Sets x to the lowest value. --If "x=x+calcActualChange()" would be **more** than "MAX_VALUE", "MAX_VALUE" is the lowest an therefore picked. else x = x+calcActualChange() -- Increases x if "CLAMP"=false. end end if decreaseX == true then if CLAMP == true then x = math.max((x-calcActualChange()), MIN_VALUE) -- Sets x to the highest value --If "x=x-calcActualChange()" would be **less** than MIN_VALUE", "MIN_VALUE" is the highest an therefore picked else x = x-calcActualChange() -- Decreases x if "CLAMP"=false. end end output.setNumber(1, x) -- Outputs x at composite channel 1. end
11 comentarios
Star Killer 18 ENE a las 11:04 a. m. 
I'm also having the problem of not finding it in game, I tried to resubscribe and wait for steam to register, but still nothing.
YarikBurnHorizon 27 JUL 2024 a las 6:55 p. m. 
I can give you an advanced fire control system.
YarikBurnHorizon 27 JUL 2024 a las 6:53 p. m. 
thank you. you best !
MaxMustermann  [autor] 5 DIC 2022 a las 11:12 a. m. 
Hi, try going into your steam libary right-click on Stormworks -> select "properties" -> go to the workshop tab -> select the Up/Down counter and click "unsubscribe" then go back to this page and download it again.
I hope this helps as it worked for me.
TMC Christian 5 DIC 2022 a las 10:57 a. m. 
That's the same concept for sure. I restarted steam and it downloaded an update, but in game there doesn't seem to be any change to it
MaxMustermann  [autor] 5 DIC 2022 a las 10:26 a. m. 
I actually made the first version of this for one of my ladder trucks to make the boom move slower when fully extended :D So quite similar application
TMC Christian 5 DIC 2022 a las 10:23 a. m. 
That was quick, thank you for that! I've been racking my head for months trying to figure out how to dynamically change the increment so I could slow the rotation of a turret as the camera zooms in for longer range shots, and this does that perfectly.
MaxMustermann  [autor] 5 DIC 2022 a las 10:19 a. m. 
You might have to close and reopen steam for the update to show up
MaxMustermann  [autor] 5 DIC 2022 a las 10:06 a. m. 
Hi! I have not implemented a reset functionality yet... But I'm adding it rn :steamthumbsup:
TMC Christian 5 DIC 2022 a las 9:52 a. m. 
Is there a way to add a reset function like the standard up/down counter?