Guest User

Error?

a guest
Aug 14th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.92 KB | None | 0 0
  1. --functions that make coding easier
  2. function reset ()
  3.     term.clear()
  4.     term.setCursorPos(1,1)
  5. end
  6.  
  7. function printColor (x,y)
  8.     term.setTextColor(y)
  9.     print(x)
  10.     term.setTextColor(colors.white)
  11. end
  12.  
  13. function line ()
  14.     print("")
  15. end
  16.  
  17. function tableCheck (inp,tab)
  18.     n = table.maxn(tab)
  19.     while n > 0 do
  20.         if inp == tab[n] then return n end
  21.         n = n-1
  22.     end
  23.    
  24.     return false
  25. end
  26. --item variables
  27. item = {}
  28. itemDmg = {}
  29. itemDmgType = {}
  30. itemEquip = {}
  31. itemEquipDef = {}
  32. itemQuest = {}
  33. itemDesc = {}
  34.  
  35. --item functions
  36. function itemRegister (name)
  37.     item[table.maxn(item)+1] = name
  38.     return
  39. end
  40.  
  41. function itemRegisterId (name,id)
  42.     item[id] = name
  43.     return
  44. end
  45.  
  46. function itemSetDmg (name,dmg)
  47.     itemDmg[tableCheck(name,item)] = dmg
  48.     return
  49. end
  50.  
  51. function itemSetDmgType (name,dmgtype)
  52.     itemDmgType[tableCheck(name,item)] = dmg
  53.     return
  54. end
  55.  
  56. function itemEquipable (name)
  57.     itemEquip[tableCheck(name,item)] = true
  58.     return
  59. end
  60.  
  61. function itemQuest (name)
  62.     itemQuest[tableCheck(name,item)] = true
  63.     return
  64. end
  65.  
  66. function itemSetDesc (name,desc)
  67.     itemDesc[tableCheck(name,item)] = desc
  68.     return
  69. end
  70.  
  71. --world functions
  72. function worldGen (size)
  73.     line()
  74.     print("Generating world terrain...")
  75.     local n = 100
  76.    
  77.     while n > 0 do
  78.         worldBiome[n] = 0
  79.         n = n-1
  80.     end
  81.     print("Adding snow...")
  82.    
  83.     snowside = math.random(1,2)
  84.     if snowside == 1 then local start = 15 else local start = 75 end
  85.     local n = 25
  86.    
  87.     while n > 0 do
  88.         worldBiome[start+n] = 1
  89.         n = n-1
  90.     end
  91.    
  92.     print("Adding sand...")
  93.    
  94.     local xx = math.random(1,2)
  95.     if xx == 1 then local start = 30 else start = 60 end
  96.     local n = 10
  97.    
  98.     while n > 0 do
  99.         worldBiome[n+start] = 2
  100.         n = n-1
  101.     end
  102.    
  103.     print("Generating hills...")
  104.    
  105.     local n = 100
  106.    
  107.     while n > 0 do
  108.         local xx = math.random(1,6)
  109.         if xx == 1 then worldHill[n] = 1 else worldHill[n] = 0 end
  110.         n = n-1
  111.     end
  112.    
  113.     print("Placing rocks in the dirt...")
  114.     local n = 100
  115.    
  116.     while n > 0 do
  117.         local xx = math.random(1,2)
  118.         if worldBiome[n] == 1 and xx == 1 then worldIce[n] = 1 elseif xx == 2 then worldIce[n] = 0 end
  119.         if worldBiome[n] ~= 2 and worldBiome[n] ~= 3 and worldBiome[n] ~= 4 and worldBiome[n] ~= 8 and worldBiome[n] ~= 9 and worldBiome[n] ~= 11 and worldBiome[n] ~= 13 and worldBiome[n] ~= 14 and worldBiome[n] ~= 15 then worldStone[n] = 1 elseif xx == 2 then worldStone[n] = 0 end
  120.         n = n-1
  121.     end
  122.     print("Adding clay...")
  123.    
  124.     local n = 100
  125.    
  126.     while n > 0 do
  127.         local xx = math.random(1,3)
  128.         if worldBiome[n] == 0 or worldBiome == 12 then
  129.             if xx == 1 then worldClay[n] = 1 else worldClay[n] = 0 end
  130.         end
  131.         n = n-1
  132.     end
  133.    
  134.     print("Generating caves...")
  135.     local n = 100
  136.        
  137.     while n > 0 do
  138.         local xx = math.random(1,6)
  139.         if worldBiome[n] == 4 or worldBiome[n] == 6 then
  140.             if xx == 1 or xx == 2 then worldCave[n] = 1 else worldCave[n] = 0 end
  141.         else
  142.             if xx == 1 then worldCave[n] = 1 else worldCave[n] = 0 end
  143.         end
  144.         n = n-1
  145.     end
  146.    
  147.     print("Generating jungle...")
  148.    
  149.     if snowside == 2 then local start = 10 else start = 70 end
  150.     local n = 20
  151.    
  152.     while n > 0 do
  153.         worldBiome[start+1] = 12
  154.         n = n-1
  155.     end
  156.     print("Adding shinies...")
  157.     local n = 100
  158.    
  159.     while n > 0 do
  160.         local xx = math.random(1,3)
  161.         if xx == 1 then
  162.             if worldBiome[n] == 0 then worldCopper[n] = 1 end
  163.         elseif xx == 2 then
  164.             worldCopper[n] = 0
  165.         end
  166.         n = n-1
  167.     end
  168.    
  169.     print("Creating dungeon...")
  170.     local xx = math.random(1,2)
  171.     if xx == 1 then
  172.         local n = 100
  173.        
  174.         while n > 0 do
  175.             if n == 8 then
  176.                 worldDungeon[n] = 1
  177.             else
  178.                 worldDungeon[n] = 0
  179.             end
  180.         end
  181.     elseif xx == 2 then
  182.         local n = 100
  183.        
  184.         while n > 0 do
  185.             if n == 92 then
  186.                 worldDungeon[n] = 1
  187.             else
  188.                 worldDungeon[n] = 0
  189.             end
  190.         end
  191.     end
  192.     print("Making the world evil...")
  193.         local xx = math.random(1,2)
  194.        
  195.         if snowside == 1 then local start = 10 else start = 70 end
  196.         local n = 25
  197.    
  198.         while n > 0 do
  199.             if xx == 1 then
  200.                 if worldBiome[start+n] == 1 then
  201.                     worldBiome[start+n] = 6
  202.                 elseif worldBiome[start+n] == 2 then
  203.                     worldBiome[start+n] = 8
  204.                 else
  205.                     worldBiome[start+n] = 3
  206.                 end
  207.             elseif xx == 2 then
  208.                 if xx == 1 then
  209.                     if worldBiome[start+n] == 1 then
  210.                         worldBiome[start+n] = 7
  211.                     elseif worldBiome[start+n] == 2 then
  212.                         worldBiome[start+n] = 9
  213.                     else
  214.                         worldBiome[start+n] = 4
  215.                     end
  216.                 end
  217.             end
  218.             n = n-1
  219.         end
  220.     print("Growing cacti...")
  221.     local n = 100
  222.    
  223.     while n > 0 do
  224.         if worldBiome[n] == 2 or worldBiome[n] == 8 or worldBiome[n] == 9 then
  225.             worldCacti[n] = 1
  226.         else
  227.             worldCacti[n] = 0
  228.         end
  229.         n = n-1
  230.     end
  231.     print("Planting trees...")
  232.     local n = 100
  233.    
  234.     while n > 0 do
  235.         if worldBiome[n] == 0 or worldBiome[n] == 1 or worldBiome[n] == 3 or worldBiome[n] == 4 or worldBiome[n] == 12 or worldBiome[n] == 13 then
  236.             worldTrees[n] = 1
  237.         else
  238.             worldTrees[n] = 0
  239.         end
  240.         n = n-1
  241.     end
  242.    
  243.     return
  244. end
  245.  
  246. --world variables
  247. worldBiome = {}
  248. worldHill = {}
  249. worldStone = {}
  250. worldIce = {}
  251. worldClay = {}
  252. worldCave = {}
  253. worldCopper = {}
  254. worldDungeon = {}
  255. worldCacti = {}
  256. worldTrees = {}
  257. worldGrass = {}
  258. worldChest = {}
  259. playerLoc = 50
  260.  
  261. --inventory variables
  262. inv = {}
  263.  
  264. --inventory functions
  265. function invAdd (name,amount)
  266.     inv[tableCheck(name,item)] = inv[tableCheck(name,item)]+amount
  267.     return
  268. end
  269.  
  270. function invTake (name,amount)
  271.     if inv[tableCheck(name,item)] < amount then return false
  272.     else
  273.         inv[tableCheck(name,item)] = inv[tableCheck(name,item)]-amount
  274.         return true
  275.     end
  276. end
  277.  
  278. function invGetAmout (name)
  279.     return inv[tableCheck(name,item)]
  280. end
  281.  
  282. --game
  283.  
  284. function menu ()
  285.     local cnf = 0
  286.     reset()
  287.     print("Choose a world size.")
  288.     line()
  289.     print("[1] Small")
  290.     print("[2] Medium")
  291.     print("[3] Large")
  292.     line()
  293.     term.setTextColor(colors.yellow)
  294.     term.write("? ")
  295.     term.setTextColor(colors.white)
  296.     local input = read()
  297.        
  298.     if input == "1" or input == "2" or input == "3" then worldGen(input-1) game() end
  299. end
  300.  
  301. function game ()
  302.     while true do
  303.         playerLoc = 50
  304.        
  305.         print(worldBiome[50])
  306.     end
  307. end
  308.  
  309. menu()
Advertisement
Add Comment
Please, Sign In to add comment