Jump to content

Recommended Posts

Posted

 

local number = 10
number = math.clamp(number,1,5)

Errors out, 

The the docs read - This function clamps a number between a minimum and maximum limit and returns the result.

Even the standard lua call errors on me.  Math.Clamp () /  math.Clamp() / math.clamp() 

 

or simply:     ??

 

function math.clamp(numb, min, max)

   if numb <  min then return min
   elseif numb > max then return max
   else return numb end

end

 

  • Alienhead changed the title to What happen to the clamps ?
Posted
1 hour ago, Josh said:

"number" is a type in Lua, so I think that isn't a valid variable name.

Interestingly, it does work. In some online interpreter at least. I guess it's because variable doesn't have a type, only value has a type.

image.png.e3366e0734560d959762af768e6edf9f.png

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...