Advertisement
ecoMeco

tntta-install

Aug 27th, 2016
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.63 KB | None | 0 0
  1. local level_dir = "levels"
  2. local levels    = {
  3.     ["level1"] = {toggles={},nextlevel="level2",name="Try not to touch anything",spawn={5,5},finish={17,12},level={{2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32},{2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32,[0]=2},{2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,1,1,1,1,2,2,32,32,32,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,1,1,2,1,1,2,32,1,1,32,32,32,32,32,32,32,32,32,32,32,32,32,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,1,1,2,1,2,1,1,2,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,1,1,1,1,2,1,2,1,2,1,1,2,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{2,2,2,2,2,2,2,2,2,2,2,2,2,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{1,1,1,1,1,1,1,1,1,1,1,1,1,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{1,1,1,1,1,1,1,1,1,1,1,1,1,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{1,1,1,1,1,1,1,1,1,1,1,1,1,32,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32},{1,1,1,1,1,1,1,1,1,1,1,1,1,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}},walls={[32]=true,[2]=true}};
  4.     ["level2"] = {toggles={},nextlevel="level3",name="Tip: some tiles are not solid",spawn={5,5},finish={24,13},level={{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{128,128,1,1,1,1,1,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,256,256,256,256,256,256,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,128,128,128,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,256,256,256,256,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,256,256,256,256,256,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,256,256,256,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,256,256,256,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,256,256,256,256},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,128,[0]=1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,128,[0]=1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}},walls={[128]=true}};
  5.     ["level3"] = {toggles={{23,4,32768,false},{31,12,8,false}},nextlevel="level4",name="And you can toggle tiles!",spawn={5,2},finish={13,13},level={{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32768,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32768,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,32768,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1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,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}},walls={[128]=true,[32768]=true,[8]=true}};
  6.     ["level4"] = {toggles={{3,12,16384,false}},nextlevel="",name="Now for the real challange",spawn={5,5},finish={49,6},level={{1,1,1,1,1,1,1,1,1,1,1,1,1,128,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,128,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,1,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,16384,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,128,256,128,256,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1,1,1,16384,128,128,128,1,1,1,1,1,1,1,1,1,1,1,128,256,256,128,256,256,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,128,128,1,1,1,16384,128,128,128,1,1,1,1,1,1,1,1,1,1,1,128,256,256,128,256,128,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256},{1,1,1,1,1,1,128,128,16384,1,16384,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,128,256,256,128,256,128,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256},{1,1,1,1,1,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,128,256,256,128,256,256,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,128,128,128,128,16384,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,128,256,128,256,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,1,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,1,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,128,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,128,128,128,128,128,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,1,128}},walls={[256]=true,[128]=true,[16384]=true}};
  7. }
  8.  
  9. local function game_is_packman()
  10.     return fs.exists("/usr/bin/tntta") and not fs.isDir(shell.resolve("/usr/bin/tntta"))
  11. end
  12.  
  13. local function game_getFile(fname)
  14.     if game_is_packman() then
  15.         return fs.combine("/etc/tntta/levels", fname) .. ".lvl"
  16.     end
  17.  
  18.     return shell.resolve(fs.combine(level_dir, fname)) .. ".lvl"
  19. end
  20.  
  21. local function level_unpack(name, level)
  22.     name = game_getFile(name)
  23.  
  24.     local lvlFile = fs.open(name, "w")
  25.         lvlFile.write("return " .. textutils.serialize(level))
  26.     lvlFile.close()
  27.  
  28.     print("Unpacked level " .. name .. " to " .. level_dir)
  29. end
  30.  
  31. local function install_game()
  32.     if game_is_packman() and (fs.exists(shell.resolve("tntta.lua")) and fs.isDir(shell.resolve("tntta.lua"))) then
  33.         error("Game is already installed")
  34.     end
  35.  
  36.     shell.run("pastebin", "get", "7tbpQp9t", "tntta.lua")
  37.     shell.run("pastebin", "get", "z6N2ivxm", "tntta-edit.lua")
  38. end
  39.  
  40. local function install_levels()
  41.     if game_is_packman() then
  42.         if fs.exists("/etc/tntta/levels") and fs.isDir("/etc/tntta/levels") then
  43.             print("Level directory already exists. Are you sure [yN]")
  44.             local k = os.pullEvent("key")
  45.             if k ~= keys.y then
  46.                 return
  47.             end
  48.         end
  49.  
  50.         level_unpack(k, v)
  51.         return
  52.     end
  53.  
  54.     if fs.exists(shell.resolve(level_dir)) and fs.isDir(shell.resolve(level_dir)) then
  55.         print("Level directory already exists. Are you sure [yN]")
  56.         local k = os.pullEvent("key")
  57.         if k ~= keys.y then
  58.             return
  59.         end
  60.     else
  61.         fs.makeDir(shell.resolve(level_dir))
  62.     end
  63.  
  64.     for k, v in pairs(levels) do
  65.         level_unpack(k, v)
  66.     end
  67. end
  68.  
  69. local function main()
  70.     install_levels()
  71.     if not game_is_packman() then install_game() end
  72. end main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement