D4Programs

Logbook Generation

May 8th, 2021 (edited)
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. systems = {'Sol','Proxima','Centauri','Betelgeuse'}
  2. objectives = {{'Independent Courier',2,'Take package to Proxima station','Give package to Rep. Pruitt'},{'Intelligence Gathering',3,'Head to Centauri station','Access files via Deck B','Return Files to Lt. Montague'}}
  3.  
  4. while true do
  5.     update = commands.scoreboard("players test @a Update 1")
  6.     if update then
  7.         page1 = "Visited Systems"
  8.         pageob = ""
  9.         commands.clear("@a written_book")
  10.         for n = 1, #systems do
  11.             testa = commands.scoreboard("players test @a Visit_" .. systems[n] .. " 1")
  12.             if testa then
  13.                 page1 = page1 .. "\\\\n- " .. systems[n]
  14.             end
  15.         end
  16.         for i = 1, #objectives do
  17.                 valid, response2 = commands.scoreboard("players test @a Objective" .. i .. " 1")
  18.                 if valid then
  19.                     page = '"[\\"\\",{\\"text\\":\\"' .. objectives[i][1] .. '\\\\n\\\\n\\"},{\\"text\\":\\"'
  20.                     complete = commands.scoreboard("players test @a Objective".. i .. " " .. objectives[i][2]+1)
  21.                     if complete then
  22.                         for j = 1, objectives[i][2] do
  23.                             page = page .. objectives[i][2+j]
  24.                             if j < objectives[i][2] then
  25.                                 page = page .. "\\\\n"
  26.                             end
  27.                         end
  28.                         page = page .. '\\",\\"strikethrough\\":true}]"'
  29.                     else
  30.                         for j = 1, objectives[i][2] do
  31.                             pass = commands.scoreboard("players test @a Objective" .. i .. " " .. j .. " " .. j)
  32.                             if pass then
  33.                                 current = j
  34.                             end
  35.                        end
  36.                        for j = 1, current-1 do
  37.                            page = page .. objectives[i][2+j] .. "\\\\n"
  38.                        end
  39.                        page = page .. '\\",\\"strikethrough\\":true},{\\"text\\":\\"' .. objectives[i][current] .. '"color\\":\\"reset\\"}]",'
  40.                        pageob = pageob .. page
  41.                     end
  42.                 end    
  43.         end        
  44.         commands.give('@a written_book 1 0 {title:"Logbook",author:"Galactic Authority ",pages:["{text:\\"' .. page1 .. '\\"}",' .. pageob .. ']}')
  45.         commands.scoreboard("players set @a Update 0")
  46.         print(response[1])
  47.     end
  48. end
Add Comment
Please, Sign In to add comment