Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get vxLQ1fVb element
- -- std pb vxLQ1fVb element
- local scr_x, scr_y = term.getSize()
- -- for state, 1=gas, 2=liquid, 3=solid
- elements = {
- [1] = {
- name = "hydrogen",
- symbol = "H",
- mass = 1.008,
- group = 1,
- period = 1,
- state = 1,
- eleconfig = "",
- },
- [2] = {
- name = "helium",
- symbol = "He",
- mass = 4.002602,
- group = 18,
- period = 1,
- state = 1,
- eleconfig = "",
- },
- [3] = {
- name = "lithium",
- symbol = "Li",
- mass = 6.94,
- group = 1,
- period = 2,
- state = 3,
- eleconfig = "",
- },
- [4] = {
- name = "beryllium",
- symbol = "Be",
- mass = 9.0121831,
- group = 2,
- period = 2,
- state = 3,
- eleconfig = "",
- },
- [5] = {
- name = "boron",
- symbol = "B",
- mass = 10.81,
- group = 13,
- period = 2,
- state = 3,
- eleconfig = "",
- },
- [6] = {
- name = "carbon",
- symbol = "C",
- mass = 12.011,
- group = 14,
- period = 2,
- state = 3,
- eleconfig = "",
- },
- [7] = {
- name = "nitrogen",
- symbol = "N",
- mass = 14.007,
- group = 15,
- period = 2,
- state = 1,
- eleconfig = "",
- },
- [8] = {
- name = "oxygen",
- symbol = "O",
- mass = 15.999,
- group = 16,
- period = 2,
- state = 1,
- eleconfig = "",
- },
- [9] = {
- name = "fluorine",
- symbol = "F",
- mass = 18.998403163,
- group = 17,
- period = 2,
- state = 1,
- eleconfig = "",
- },
- [10] = {
- name = "neon",
- symbol = "Ne",
- mass = 20.1797,
- group = 18,
- period = 2,
- state = 1,
- eleconfig = "",
- },
- [11] = {
- name = "sodium",
- symbol = "Na",
- mass = 22.98976928,
- group = 1,
- period = 3,
- state = 3,
- eleconfig = "",
- },
- [12] = {
- name = "magnesium",
- symbol = "Mg",
- mass = 24.305,
- group = 2,
- period = 3,
- state = 3,
- eleconfig = "",
- },
- [13] = {
- name = "aluminum",
- symbol = "Al",
- mass = 26.9815385,
- group = 13,
- period = 3,
- state = 3,
- eleconfig = "",
- },
- [14] = {
- name = "silicon",
- symbol = "Si",
- mass = 28.085,
- group = 14,
- period = 3,
- state = 3,
- eleconfig = "",
- },
- [15] = {
- name = "phosphorus",
- symbol = "P",
- mass = 30.973761998,
- group = 15,
- period = 3,
- state = 3,
- eleconfig = "",
- },
- [16] = {
- name = "sulfur",
- symbol = "S",
- mass = 32.06,
- group = 16,
- period = 3,
- state = 3,
- eleconfig = "",
- },
- [17] = {
- name = "chlorine",
- symbol = "Cl",
- mass = 35.45,
- group = 17,
- period = 3,
- state = 1,
- eleconfig = "",
- },
- [18] = {
- name = "argon",
- symbol = "Ar",
- mass = 39.945,
- group = 18,
- period = 3,
- state = 1,
- eleconfig = "",
- },
- [19] = {
- name = "potassium",
- symbol = "K",
- mass = 39.0953,
- group = 1,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [20] = {
- name = "calcium",
- symbol = "Ca",
- mass = 40.075,
- group = 2,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [21] = {
- name = "scandium",
- symbol = "Sc",
- mass = 44.955905,
- group = 3,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [22] = {
- name = "titanium",
- symbol = "Ti",
- mass = 47.587,
- group = 4,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [23] = {
- name = "vanadium",
- symbol = "V",
- mass = 50.9,
- group = 5,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [24] = {
- name = "chromium",
- symbol = "Cr",
- mass = 51.9961,
- group = 6,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [25] = {
- name = "manganese",
- symbol = "Mn",
- mass = 54.938044,
- group = 7,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [26] = {
- name = "iron",
- symbol = "Fe",
- mass = 55.845,
- group = 8,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [27] = {
- name = "cobalt",
- symbol = "Co",
- mass = 58.933194,
- group = 9,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [28] = {
- name = "nickel",
- symbol = "Ni",
- mass = 58.6934,
- group = 10,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [29] = {
- name = "copper",
- symbol = "Cu",
- mass = 63.546,
- group = 11,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [30] = {
- name = "zinc",
- symbol = "Zn",
- mass = 65.38,
- group = 12,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [31] = {
- name = "gallium",
- symbol = "Ga",
- mass = 69.723,
- group = 13,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [32] = {
- name = "germanium",
- symbol = "Ge",
- mass = 72.63,
- group = 14,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [33] = {
- name = "arsenic",
- symbol = "As",
- mass = 74.921595,
- group = 15,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [34] = {
- name = "selenium",
- symbol = "Se",
- mass = 78.971,
- group = 16,
- period = 4,
- state = 3,
- eleconfig = "",
- },
- [35] = {
- name = "bromine",
- symbol = "Br",
- mass = 79.904,
- group = 17,
- period = 4,
- state = 2,
- eleconfig = "",
- },
- [36] = {
- name = "krypton",
- symbol = "Kr",
- mass = 83.798,
- group = 18,
- period = 4,
- state = 1,
- eleconfig = "",
- },
- [37] = {
- name = "rubidium",
- symbol = "Rb",
- mass = 85.4678,
- group = 1,
- period = 5,
- state = 1,
- eleconfig = "",
- },
- [38] = {
- name = "strontium",
- symbol = "Sr",
- mass = 87.62,
- group = 2,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [39] = {
- name = "yttrium",
- symbol = "Y",
- mass = 88.90584,
- group = 3,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [40] = {
- name = "zirconium",
- symbol = "Zr",
- mass = 91.224,
- group = 4,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [41] = {
- name = "niobium",
- symbol = "Nb",
- mass = 92.90637,
- group = 5,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [42] = {
- name = "molybdenum",
- symbol = "Mo",
- mass = 95.95,
- group = 6,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [43] = {
- name = "technetium",
- symbol = "Tc",
- mass = 98,
- group = 7,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [44] = {
- name = "ruthenium",
- symbol = "Ru",
- mass = 101.07,
- group = 8,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [45] = {
- name = "rhodium",
- symbol = "Rh",
- mass = 102.9055,
- group = 9,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [46] = {
- name = "palladium",
- symbol = "Pd",
- mass = 106.42,
- group = 10,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [47] = {
- name = "silver",
- symbol = "Ag",
- mass = 107.8682,
- group = 11,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [48] = {
- name = "cadmium",
- symbol = "Cd",
- mass = 112.414,
- group = 12,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [49] = {
- name = "indium",
- symbol = "In",
- mass = 114.818,
- group = 13,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [50] = {
- name = "tin",
- symbol = "Sn",
- mass = 118.710,
- group = 14,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [51] = {
- name = "antimony",
- symbol = "Sb",
- mass = 121.760,
- group = 15,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [52] = {
- name = "tellurium",
- symbol = "Te",
- mass = 127.6,
- group = 16,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [53] = {
- name = "iodine",
- symbol = "I",
- mass = 126.90447,
- group = 17,
- period = 5,
- state = 3,
- eleconfig = "",
- },
- [54] = {
- name = "xenon",
- symbol = "Xe",
- mass = 131.293,
- group = 18,
- period = 5,
- state = 1,
- eleconfig = "",
- },
- [55] = {
- name = "cesium",
- symbol = "Cs",
- mass = 132.90545196,
- group = 1,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [56] = {
- name = "barium",
- symbol = "Ba",
- mass = 137.327,
- group = 2,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [57] = {
- name = "lanthanum",
- symbol = "La",
- mass = 138.90547,
- group = 4,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [58] = {
- name = "cerium",
- symbol = "Ce",
- mass = 140.116,
- group = 5,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [59] = {
- name = "praseodymium ",
- symbol = "Pr",
- mass = 140.90766,
- group = 6,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [60] = {
- name = "neodymium",
- symbol = "Nd",
- mass = 144.242,
- group = 7,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [61] = {
- name = "promethium",
- symbol = "Pm",
- mass = 145,
- group = 8,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [62] = {
- name = "samarium",
- symbol = "Sm",
- mass = 150.36,
- group = 9,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [63] = {
- name = "europium",
- symbol = "Eu",
- mass = 151.964,
- group = 10,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [64] = {
- name = "gadolinium",
- symbol = "Gd",
- mass = 157.25,
- group = 11,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [65] = {
- name = "terbium",
- symbol = "Tb",
- mass = 158.92535,
- group = 12,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [66] = {
- name = "dysprosium",
- symbol = "Dy",
- mass = 162.5,
- group = 13,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [67] = {
- name = "holmium",
- symbol = "Ho",
- mass = 164.93033,
- group = 14,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [68] = {
- name = "erbium",
- symbol = "Er",
- mass = 167.259,
- group = 15,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [69] = {
- name = "thulium",
- symbol = "Tm",
- mass = 168.93422,
- group = 16,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [70] = {
- name = "ytterbium",
- symbol = "Yb",
- mass = 173.045,
- group = 17,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [71] = {
- name = "lutetium",
- symbol = "Lu",
- mass = 174.9668,
- group = 18,
- period = 9,
- state = 3,
- eleconfig = "",
- },
- [72] = {
- name = "hafnium",
- symbol = "Hf",
- mass = 178.49,
- group = 4,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [73] = {
- name = "tantalum",
- symbol = "Ta",
- mass = 180.94788,
- group = 5,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [74] = {
- name = "tungsten",
- symbol = "W",
- mass = 183.84,
- group = 6,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [75] = {
- name = "rhenium",
- symbol = "Re",
- mass = 186.207,
- group = 7,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [76] = {
- name = "osmium",
- symbol = "Os",
- mass = 190.23,
- group = 8,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [77] = {
- name = "iridium",
- symbol = "Ir",
- mass = 192.217,
- group = 9,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [78] = {
- name = "platinum",
- symbol = "Pt",
- mass = 195.084,
- group = 10,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [79] = {
- name = "gold",
- symbol = "Au",
- mass = 196.966569,
- group = 11,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [80] = {
- name = "mercury",
- symbol = "Hg",
- mass = 200.59,
- group = 12,
- period = 6,
- state = 2,
- eleconfig = "",
- },
- [81] = {
- name = "thallium",
- symbol = "Tl",
- mass = 204.38,
- group = 13,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [82] = {
- name = "lead",
- symbol = "Pb",
- mass = 207.2,
- group = 14,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [83] = {
- name = "bismuth",
- symbol = "Bi",
- mass = 208.9804,
- group = 15,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [84] = {
- name = "polonium",
- symbol = "Po",
- mass = 209,
- group = 16,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [85] = {
- name = "astatine",
- symbol = "At",
- mass = 210,
- group = 17,
- period = 6,
- state = 3,
- eleconfig = "",
- },
- [86] = {
- name = "radon",
- symbol = "Rn",
- mass = 222,
- group = 18,
- period = 6,
- state = 1,
- eleconfig = "",
- },
- [87] = {
- name = "francium",
- symbol = "Fr",
- mass = 223,
- group = 1,
- period = 7,
- state = 3,
- eleconfig = "",
- },
- [88] = {
- name = "radium",
- symbol = "Ra",
- mass = 226,
- group = 2,
- period = 7,
- state = 3,
- eleconfig = "",
- },
- [89] = {
- name = "actinium",
- symbol = "Ac",
- mass = 227,
- group = 4,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [90] = {
- name = "thorium",
- symbol = "Th",
- mass = 232.0377,
- group = 5,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [91] = {
- name = "protactinium",
- symbol = "Pa",
- mass = 231.03588,
- group = 6,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [92] = {
- name = "uranium",
- symbol = "U",
- mass = 238.02891,
- group = 7,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [93] = {
- name = "neptunium",
- symbol = "Np",
- mass = 237,
- group = 8,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [94] = {
- name = "plutonium",
- symbol = "Pu",
- mass = 244,
- group = 9,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [95] = {
- name = "americium",
- symbol = "Am",
- mass = 243,
- group = 10,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [96] = {
- name = "curium",
- symbol = "Cm",
- mass = 247,
- group = 11,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [97] = {
- name = "berkelium",
- symbol = "Bk",
- mass = 247,
- group = 12,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [98] = {
- name = "californium",
- symbol = "Cf",
- mass = 251,
- group = 13,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [99] = {
- name = "einsteinium",
- symbol = "Es",
- mass = 252,
- group = 14,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [100] = {
- name = "fermium",
- symbol = "Fm",
- mass = 257,
- group = 15,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [101] = {
- name = "mendelevium",
- symbol = "Md",
- mass = 258,
- group = 16,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [102] = {
- name = "nobelium",
- symbol = "No",
- mass = 259,
- group = 17,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [103] = {
- name = "lawrencium",
- symbol = "Lr",
- mass = 262,
- group = 18,
- period = 10,
- state = 3,
- eleconfig = "",
- },
- [104] = {
- name = "rutherfordium",
- symbol = "Rf",
- mass = 267,
- group = 4,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [105] = {
- name = "dubnium",
- symbol = "Db",
- mass = 268,
- group = 5,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [106] = {
- name = "seaborgium",
- symbol = "Sg",
- mass = 271,
- group = 6,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [107] = {
- name = "bohrium",
- symbol = "Bh",
- mass = 272,
- group = 7,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [108] = {
- name = "hassium",
- symbol = "Hs",
- mass = 270,
- group = 8,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [109] = {
- name = "meitnerium",
- symbol = "Mt",
- mass = 276,
- group = 9,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [110] = {
- name = "darmstadtium",
- symbol = "Ds",
- mass = 281,
- group = 10,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [111] = {
- name = "roentgenium",
- symbol = "Rg",
- mass = 280,
- group = 11,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [112] = {
- name = "copernicium",
- symbol = "Cn",
- mass = 285,
- group = 12,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [113] = {
- name = "nihonium",
- symbol = "Nh",
- mass = 284,
- group = 13,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [114] = {
- name = "flerovium",
- symbol = "Fl",
- mass = 289,
- group = 14,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [115] = {
- name = "moscovium",
- symbol = "Mc",
- mass = 288,
- group = 15,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [116] = {
- name = "livermorium",
- symbol = "Lv",
- mass = 293,
- group = 16,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [117] = {
- name = "tennessine",
- symbol = "Ts",
- mass = 294,
- group = 17,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- [118] = {
- name = "oganesson",
- symbol = "Og",
- mass = 294,
- group = 18,
- period = 7,
- state = 0,
- eleconfig = "",
- },
- }
- for a = 1, #elements do
- elements[a].number = a
- end
- local drawing = {} -- renders colors below elements
- -- F-block
- for y = 12, 21 do
- table.insert(drawing,{x=12,['y']=y,char=" ",col=colors.lightBlue})
- end
- for y = 17, 21 do
- table.insert(drawing,{x=12,['y']=y,char=(" "):rep(64),col=colors.lightBlue})
- end
- -- state labels
- table.insert(drawing,{x=13,y=2,char="Solid ",col=colors.brown,txt=colors.white})
- table.insert(drawing,{x=13,y=3,char="Liquid ",col=colors.blue,txt=colors.white})
- table.insert(drawing,{x=13,y=4,char="Gas ",col=colors.yellow,txt=colors.black})
- table.insert(drawing,{x=13,y=5,char="Unknown",col=colors.black,txt=colors.white})
- table.insert(drawing,{x=21,y=3,char="<-- State at 64 F",col=colors.lightGray})
- -- instructions
- table.insert(drawing,{x=21,y=5,char="Arrow keys to scroll",col=colors.lightGray})
- table.insert(drawing,{x=21,y=6,char="Press [Q] to quit",col=colors.lightGray})
- local renderElements = function(ele,xscroll,yscroll)
- term.current().setVisible(false)
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- term.setTextColor(colors.white)
- for a = 1, #drawing do
- term.setCursorPos((drawing[a].x)-xscroll,(drawing[a].y)-yscroll)
- term.setBackgroundColor(drawing[a].col)
- if drawing[a].txt then
- term.setTextColor(drawing[a].txt)
- else
- term.setTextColor(colors.black)
- end
- term.write(drawing[a].char)
- end
- for a = 1, #ele do
- if ele[a].state == 1 then
- term.setBackgroundColor(colors.yellow)
- term.setTextColor(colors.black)
- elseif ele[a].state == 2 then
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- elseif ele[a].state == 3 then
- term.setBackgroundColor(colors.brown)
- term.setTextColor(colors.white)
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- end
- term.setCursorPos((ele[a].group*4)-xscroll,(ele[a].period*2)-yscroll)
- term.write((ele[a].symbol.." "):sub(1,3))
- end
- term.current().setVisible(true)
- end
- local cleanExit = function()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print("Bye!")
- sleep(0)
- return
- end
- local xscr = 0
- local yscr = 0
- local keysDown = {}
- local viewingElement = false
- local cprint = function(txt,_y)
- local x,y = term.getSize()
- local cx,cy = term.getCursorPos()
- term.setCursorPos((x/2)-math.ceil(#txt/2),_y or cy)
- return print(txt)
- end
- local viewElement = function(ele)
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(1,2)
- term.clearLine()
- cprint(ele.name:upper())
- term.setBackgroundColor(colors.white)
- print("Symbol: "..ele.symbol)
- print("Atomic #: "..ele.number)
- print("Atomic mass: "..ele.mass)
- print("Neutron #: "..math.floor(ele.mass)-ele.number)
- write("\nState of matter: ")
- if ele.state == 1 then
- print("Gas")
- elseif ele.state == 2 then
- print("Liquid")
- elseif ele.state == 3 then
- print("Solid")
- else
- print("Unknown")
- end
- print("\nPeriod "..((ele.period <= 7 and ele.period) or (ele.period-3)))
- print("Group "..((ele.period <= 7 and ele.group) or "F-block").."\n")
- if elements[ele.number-1] then
- print("Prev: "..elements[ele.number-1].name)
- end
- if elements[ele.number+1] then
- print("Next: "..elements[ele.number+1].name)
- end
- sleep(0)
- local evt,butt
- while true do
- evt,butt = os.pullEvent()
- if evt == "key" then
- if butt == keys.left or butt == keys.right then
- return butt
- else
- return
- end
- elseif evt == "mouse_click" then
- if butt == 1 then
- return
- end
- end
- end
- end
- local getKeys = function()
- while true do
- local evt,key = os.pullEvent()
- if evt == "key" then
- keysDown[key] = true
- elseif evt == "key_up" then
- keysDown[key] = false
- end
- end
- end
- local getKeyScrolling = function()
- while true do
- sleep(0.05)
- if not viewingElement then
- if keysDown[keys.left] then
- if xscr > 0 then
- xscr = xscr - 1
- end
- elseif keysDown[keys.right] then
- if xscr < 76-scr_x then
- xscr = xscr + 1
- end
- end
- if keysDown[keys.down] then
- if yscr < 4 then
- yscr = yscr + 1
- end
- elseif keysDown[keys.up] then
- if yscr > 0 then
- yscr = yscr - 1
- end
- end
- if keysDown[keys.q] then
- return cleanExit()
- end
- renderElements(elements,xscr,yscr)
- end
- end
- end
- local getMouseInput = function()
- while true do
- local evt,butt,x,y = os.pullEvent("mouse_click")
- local _x,_y = x+xscr,y+yscr
- for a = 1, #elements do
- local e = elements[a]
- if (_x >= (e.group*4) and _x <= (e.group*4)+2) and (_y == e.period*2) then
- viewingElement = true
- local b = a
- while true do
- e = elements[b]
- local eeh = viewElement(e)
- if eeh == keys.left and elements[b-1] then
- b = b - 1
- elseif eeh == keys.right and elements[b+1] then
- b = b + 1
- else
- break
- end
- end
- viewingElement = false
- break
- end
- end
- end
- end
- local doFunks = {
- getMouseInput,
- getKeyScrolling,
- getKeys,
- }
- parallel.waitForAny(unpack(doFunks))
Add Comment
Please, Sign In to add comment