fi5hii

Untitled

May 13th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. -- Function to set a variable remembering only the integer part
  2. local function setIntegerVariable(varName, value)
  3. if type(value) == "number" then
  4. _G[varName] = math.floor(value)
  5. else
  6. print("Error: Value is not a number.")
  7. end
  8. end
  9.  
  10. -- Example usage:
  11. local myVar = 12.34
  12. setIntegerVariable("myVar", myVar)
  13.  
  14. -- Accessing the variable
  15. print(myVar) -- Output: 12
Advertisement
Add Comment
Please, Sign In to add comment