Advertisement
kkDav1337

Variables in Lua

Jun 28th, 2020
14,270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- Welcome Message
  2.  
  3. print("\nWelcome to Variable Lesson\n==========================================")
  4.  
  5. -- Variable Definition
  6. local a,b,c
  7.  
  8. -- Initialization
  9. a = 5
  10. b = 10
  11. c = 15
  12.  
  13. -- Print Message
  14.  
  15. print("This is value of a:", a) -- Print Message for Variable of A
  16. print("This is value of b:", b) -- Print Message for Variable of B
  17. print("This is value of c:", c) -- Print Message for Variable of C
  18.  
  19. -- Just something like new line
  20.  
  21. print("==========================================")
  22.  
  23. -- Swapping between Variables
  24.  
  25. b, c = a, b
  26.  
  27. print("This is variable b but with a value:", b) -- Variable b Swapped the value with a
  28. print("This is variable c but with b value:", c) -- Variable c Swapped the value with b
  29.  
  30. -- Just something like new line
  31.  
  32. print("==========================================")
  33.  
  34. -- Float Value Variable
  35.  
  36. f1 = 50.0 -- Float Value 1
  37. f2 = 40.0 -- Float Value 2
  38. f3 = 3.0 -- Float Value 3 , Used for Math operation down
  39.  
  40. print("This is the value of First Float:", f1)
  41. print("This is the value of Second Float:", f2)
  42. print("This is the value of Third Float:", f3)
  43.  
  44. -- Just something like new line
  45.  
  46. print("==========================================")
  47.  
  48. -- Simple math with Float values
  49.  
  50. print("First Float value divided by Third Float", f1/f3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement