Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Guide to LUA programming")
- print("By MatthewGB")
- sleep(1)
- print("To start off programming, and test simple scripts, I recommend using the 'lua' command in the Craft-OS, which will open the interactive lua prompt. First off, you will learn the simple commands to put text on the screen, using print() and write(). Inside the brackets you can put almost any variable type, such as an integer(A number), a float(A decimal number), a string(Some text) or a boolean(True/False). You can also leave the brackets empty, to print nothing. The difference between the print() and write() is that after the print command, it will skip to the next line, whereas the write command won't.")
- print("Press enter to continue")
- read()
- print("Here's a few examples to try in the lua prompt:")
- print("- print('Some Text')")
- print("- write(3.14159)")
- print("- print(true)")
- print("- write(666)")
- print("Press enter to continue")
- read()
- print("Note that the write command can't really be tested in the lua prompt. To exit the lua prompt, type 'exit()'. Next you'll assign some variables various values, perform calculations on them, and print them. To make a variable enter the following: ")
- print("- var = 5")
- print("To reference to the variable, use the name 'var'. Var has a value of 5. Make another variable.")
- print("- var2 = 10")
- print("Another variable, called 'var2' and has a value of 10. Now make a third variable, where is value is the first two variables added up.")
- print("- var3 = var + var2")
- print("You could also substract them by replacing '-', multiply with '*' or divide with '/'.")
- print("You can also change the value of a variable the same way as you first created it.")
- print("- var = var + 1")
- print("This would increase the value of var by 1. It re-assigns a value to itself witch is it's previous value + 1. You can also print these variables:")
- print("- print(var)")
- print("- write(var2)")
Advertisement
Add Comment
Please, Sign In to add comment