Advertisement
rickydaan

[CC Lua] Tutorial Part 1

Apr 11th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. ~~~~@ Intro @~~~~
  2.  
  3. First of all, Im Rickydaan, a Very good CC Lua scripter. Im here to learn you guys the steps about CC Lua, So u guys become the same good as me!
  4.  
  5. Today we will learn:
  6. "Basic steps"
  7. "Shell and Os functions"
  8. "Variables"
  9. "Using the read() function"
  10. "If / Elseif / Else / End " function
  11.  
  12. So we know we will be learning "CC Lua" Some things WONT work in real Lua. Each Lua program got unique functions!
  13.  
  14. ~~~~@ Basic Steps @~~~~
  15.  
  16. First of all Lets make a terminal.
  17. There are some basic intregated programs. We will use: "lua" to toy arround
  18. Type lua
  19. Then lets "print" something on the screen.
  20. Type:
  21. print("Hello World")
  22. once u opened the lua file.
  23. Amazing isnt it?
  24. I will be using words as: "Strings" "Brackets" "Booleans"
  25. Strings = ""
  26. Brackets = {}
  27. Booleans = ()
  28.  
  29. ~~~~@ Shell and Os functions @~~~~
  30.  
  31. There are different functions:
  32. WARNING: CaseSensitive
  33.  
  34. shell.run("PROGRAMNAME") -- Runs another program from program running
  35. shell.getRunningProgram() -- Gets the name of the program running
  36. shell.exit() -- Exits the program
  37. shell.programs() -- Lists all programs
  38.  
  39. -- Find more typing: help shellapi --
  40.  
  41. OS:
  42.  
  43. os.shutdown() -- Clears screen and you wont be able to do ANYTHING
  44. os.version() -- Gets the version of CC?
  45. os.reboot() -- Shutdowns and starts PC
  46. os.sleep( TIME !! NO STRINGS !! ) -- Let the PC "Freeze" for xxx seconds
  47. os.setComputerLabel( LABEL ) -- Sets a computer label
  48. os.getComputerLabel() -- Gets the computer label
  49.  
  50. -- Find more typing help os --
  51.  
  52. Term:
  53.  
  54. term.clear() -- Clears the screen
  55. term.setCursorPos(x,y) -- Sets the cursor pos to xxx yyy
  56. term.getCursorPos() -- Gets the cursor pos (2 Variables required)
  57.  
  58. -- Find more help typing help term --
  59.  
  60. ~~~~@ Variables @~~~~
  61. A Variable (var) is also used to "Store" a "Strings content" or a "number's content "
  62. Here is a small script using a variable:
  63.  
  64. @@
  65. a = "Lol"
  66. print(a)
  67. @@
  68.  
  69. It will print a, A variable is called WITHOUT strings.
  70.  
  71.  
  72. ~~~~@ Using the Read() function @~~~~
  73.  
  74. This will be a further explination of the Variables.
  75. A read() function reads a input -- So it will let you type!
  76.  
  77. Heres a example of printing a read() value:
  78.  
  79. @@
  80. term.clear()
  81. term.setCursorPos(1,1)
  82. print("Input something!")
  83. input = read()
  84. print("Lemme think...")
  85. sleep(2)
  86. term.clear()
  87. term.setCursorPos(1,1)
  88. print("You printed " .. input .. "!")
  89. @@
  90.  
  91. The dots is to say like: Strings .. Variable!!!
  92.  
  93. Heres a expample of hiding it (the read() becomes read("X")
  94.  
  95. @@
  96. term.clear()
  97. term.setCursorPos(1,1)
  98. print("Input something!")
  99. input = read("X")
  100. print("Lemme think...")
  101. sleep(2)
  102. term.clear()
  103. term.setCursorPos(1,1)
  104. print("You printed " .. input .. "!")
  105. @@
  106.  
  107. ~~~~@ If, Elseif. Else, End@~~~~
  108. A IF always needs to be CLOSED with a end. Lets do a password!
  109.  
  110. @@
  111. term.clear()
  112. term.setCursorPos(1,1)
  113. print("PASSWORD PLEASE")
  114. a = read("X")
  115. if a == "password" then
  116. print("GOOD")
  117. else
  118. print("BAD")
  119. end
  120. @@
  121.  
  122. See? if a (VARIABLE) == "password" (password is the password) then (Then xxx happens)
  123. The Then needs also to be done at elseif
  124.  
  125.  
  126. See y'a next time!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement