Marlingaming

Online Page Laws

Jan 10th, 2022 (edited)
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. --this online program displays all Laws
  2. local Pg = 1
  3. local Laws = {"All Citizens must live within or on the outskirts of a Legal settlement","No one is allowed to steal items", "the use/Ownership of a Coin Press is Only allowed for those given the Permission to do so by the Appropriate Government Organizations", "The Destruction of Public Transportation Infrastructure without Repairing is Illegal unless given Proper permission by the Appropriate Government Bodies"}
  4. local MaxPg = #Laws/6
  5.  
  6. local function Clear()
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. end
  10.  
  11. local function DisplayTabTop()
  12. print("-----Laws-----")
  13. if MaxPg > 1 then
  14.     print("Pg"..Pg..", a < > d, c to exit")
  15. else
  16.     print("Pg"..Pg..", c to exit")
  17. end
  18. end
  19.  
  20. local function DrawPage()
  21. local PgSpot = ((Pg * 9) - 8)
  22. local Items = 6
  23. if #Laws < 6 then Items = #Laws end
  24. for i = PgSpot, Items do
  25.     print(i.." - "..Laws[i])
  26. end
  27. end
  28.  
  29. function PageInteraction()
  30. Clear()
  31. DisplayTabTop()
  32. DrawPage()
  33. local event
  34. repeat
  35.     event = {os.pullEvent("key")}
  36. until event[2] == keys.a or event[2] == keys.d or event[2] == keys.c
  37. if event[2] == keys.a and Pg > 1 then
  38.     Pg = Pg - 1
  39.     PageInteraction()
  40. elseif event[2] == keys.d and Pg < MaxPg then
  41.     Pg = Pg + 1
  42.     PageInteraction()
  43. elseif event[2] == keys.c then
  44.     shell.run("os/os_Programs/os_MainScript")
  45. else
  46.     PageInteraction()
  47. end
  48. end
  49.  
  50. PageInteraction()
Add Comment
Please, Sign In to add comment