Stormworks: Build and Rescue

Stormworks: Build and Rescue

Frag2000 Oct 2, 2020 @ 12:06pm
Is the lua math.clamp call working?
Hi guys,

I am using clamp all the time with the logic map ... but if I use in it lua ...it crash my script. Wondering if I miss something or the lua system simply cannot handle it.

Example:

inSeatRudder = math.clamp(inSeatRudder,-0.150,0.150)
< >
Showing 1-2 of 2 comments
Ra-Ra-Rasputin Oct 2, 2020 @ 1:13pm 
There's no clamp in standard LUA library, so math.clamp isn't a thing, not sure where you'd be getting the method arguments as it doesn't exist.

You can make your own like this:
function math.clamp(n, low, high) return math.min(math.max(n, low), high) end
(Not mine, just nicking and editing it)
Last edited by Ra-Ra-Rasputin; Oct 2, 2020 @ 1:14pm
Muzzleflash Oct 2, 2020 @ 1:23pm 
Though it is really strange they went to the effort to define for the functions-block environment, and not also make it available in Lua scripts.
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Oct 2, 2020 @ 12:06pm
Posts: 2