Advertisement
jBlume

Simified programing notes for Dummies

Jul 15th, 2023 (edited)
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. sleep(x) -- Turtle waits for x seconds
  2. break --should stop the program??
  3.  
  4. local --not sure. I think it sets a variable status
  5.  
  6. while true do --program will run as long as condition is met.. true can be a condition like x>16
  7. while not (command) do --will run command, but if unable to will run to do command. Eg while command can run it == true but if unable then command ==false and so the following condition is ran
  8.  
  9. for i=1,16 do -- runs program 1 thru 16 cycles. 1, 10, 2 will cycle 1-10 but only every +2 cycle so 1 3 5 7 9
  10.  
  11. if (condition) then --activates if the condition is met
  12. else --if the if condition is not met then do the following instead
  13. elseif -- not sure. May be the same as writing an if condition after an else
  14. break --stios the loop and continues program
  15.  
  16. repeat --requires further understanding
  17.  
  18. term.write("Who's that Pokemon?") --asks question and awaits a response
  19. read() --reads response. x = read() will set x to the response
  20.  
  21. function name(x) --creates a mini program that can just be inserted in other places. Create all functions first. X is a variable that can be changed when using the function eg name(5) will have x=5 inside the function. Knowing as passing a variable
  22. return variable --similar to a break. Stops the function and sends variable info to continue program. Best used in a "while not condition do" loop
  23.  
  24. --arrays
  25. local pokemon = {"name1", "name2", "name3"}
  26. --creates a list under the program pokemon[]. Eg. pokemon[2] will pull up name2
  27. --for loop + print to generate list
  28. for p=1,3 do
  29.  print (pokemon[p])
  30. end
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement