Kingdaro

mineral thing w/ count

Nov 19th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mineral = {
  2.     ["Native Copper"]="Rusty looking",
  3.     ["Graphite"]="Black/Dirt looking",
  4.     ["Dolomite"]="White/crystal-like",
  5.     ["Calcite"]="Clear/Crystal like",
  6.     ["Pyrite"]="Gold looking",
  7.     ["Chalcopyrite"]="Gold looking",
  8.     ["Alabaster"]="No desc. Alabaster",
  9.     ["Selenite"]="Crystal glass like",
  10.     ["Satin spar"]="Pink shing",
  11.     ["Barite"]="Shiny",
  12.     ["Crystalline Quartz"]="Diamond look",
  13.     ["Rose Quartz"]="Pinkish/Crystal look",
  14.     ["Chert"]="Yellow/Tan color",
  15.     ["Chalcedony"]="Crystal look",
  16.     ["Orhtoclase Feldspar"]="Pinkish",
  17.     ["Plagioclase Feldspar"]="Yellowish",
  18.     ["Biotite Mica"]="Brown/Black flaky",
  19.     ["Muscovite Mica"]="Shiny/Flaky",
  20.     ["Talc"]="Grey", ["Kaolin"]="White/Chalky",
  21.     ["Hornblende"]="No desc. Hornblende",
  22.     ["Spodumene"]="White/grey",
  23.     ["Tourmaline"]="Green/blue color",
  24.     ["Magnetite"]="No desc. Magnetite",
  25.     ["Hematite"]="Rusty",
  26.     ["Limonite"]="Dark brown",
  27.     ["Bauxite"]="Orange/brown color",
  28.     ["Fluorite"]="Sea green",
  29.     ["Halite"]="Crystal like plastic",
  30.     ["Apatite"]="Food lol."
  31. }
  32.  
  33.  
  34.  
  35. local function getRandomIndexes(t)
  36.     local count = 0
  37.  
  38.     for i,v in pairs(t) do
  39.         count = count + 1
  40.     end
  41.  
  42.     local rand1 = math.random(count/3)
  43.     local rand2 = rand1 + math.random(count/3)
  44.     local rand3 = rand2 + math.random(count/3)
  45.  
  46.     local res1, res2, res3
  47.     local num = 1
  48.  
  49.     for index, _ in pairs(t) do
  50.         if num == rand1 then
  51.             res1 = index
  52.         end
  53.         if num == rand2 then
  54.             res2 = index
  55.         end
  56.         if num == rand3 then
  57.             res3 = index
  58.         end
  59.         num = num + 1
  60.     end
  61.  
  62.     return res1, res2, res3
  63. end
  64.  
  65. term.clear()
  66. term.setCursorPos(1,1)
  67. while true do
  68.     sel = math.random(1,3)
  69.     numq, numw, nume = getRandomIndexes(mineral)
  70.  
  71.     print("The mineral description is!")
  72.     print(mineral[numq].." ..")
  73.     print("")
  74.     print("The three ones are")
  75.  
  76.     if sel == 1 then
  77.         print(numq)
  78.         print(numw)
  79.         print(nume)
  80.     elseif sel == 2 then
  81.         print(numw)
  82.         print(numq)
  83.         print(nume)
  84.     else
  85.         print(numw)
  86.         print(nume)
  87.         print(numq)
  88.     end
  89.  
  90.     print("")
  91.     resp = read()
  92.     if resp == numq then
  93.         print("Correct!")
  94.         sleep(1)
  95.     else
  96.         print("Wrong.. The right one is..")
  97.         print(numq)
  98.         sleep(1)
  99.     end
  100.  
  101.     term.clear()
  102.     term.setCursorPos(1,1)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment