Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --]] Vital testing aperatus made by LEW, Intelligence by Gluuon
- os.pullEvent = os.pullEventRaw
- local sbc = term.setBackgroundColor
- local stc = term.setTextColor
- local scp = term.setCursorPos
- local cls = term.clear
- local line = paintutils.drawLine
- local box = paintutils.drawBox
- local fbox = paintutils.drawFilledBox
- local w,h = term.getSize()
- local theme = {
- bc = colors.black,
- tc = colors.green,
- barbc = colors.orange,
- bartc = colors.white,
- qbc = colors.green,
- qtc = colors.white,
- answerbc = colors.lightGray,
- answertc = colors.gray,
- }
- qcor = 0
- local passers = {}
- local subjects = {
- {s="Theoretical Physics",q={
- {s="Fact",q="Since protons are positivly charged \n how do they all stay together?",a="strongforce"},
- {s="Theory",q="If light is a EM Field, and always remains \n a constant speed we can assume \n from this that light \n is a type of..",a="gravity"},
- {s="Theory",q="Name a force that can escape a blackhole.", a="kinetic"},
- {s="Fact",q="How about an easy one, its part of \n the lepton family and is unseeable.", a="electron"},
- {s="Fact",q="What are the 3 color wave lengths \ngluons can have. \n(list them with their 1st inital) ", a="rgb"},
- {s="Fact",q="What was the primary reason why \n einstein couldnt unite relativity \n and quantum physics \n in one word. ", a="gravity"},
- {s="Fact",q="Is it energy effective to harvest \ncarbon from the air in a \nform of plastic?",a="no"},
- {s="Fact",q="Describe why we will never see \nthe light from some galaxys \nin one word.", a="expansion"},
- {s="Theory",q="Einsteins theory that states \n that light and gravity are \n 2 differant versions of the \n same thing is called. ", a="unified field theory"},
- {s="Fact",q="If nothing can move faster than \n light then why will we never \n see the light from some \n galaxys?.", a="space expansion"},
- }},
- {s="Chemistry",q={
- {s="Fact",q="Name the 3 items of the fire pyramid. (order: left right down) ",a="oxygen heat fuel"},
- {s="Fact",q="What partical family are quarks part of?",a="boson"},
- {s="Fact",q="List the electron subshells atom (non theoretical). ",a="spdf"},
- {s="Fact",q="List all the electron shells. ",a="KLMNOP"},
- {s="Fact",q="Is Water a polar or non-polar molecule?.",a="polar"},
- {s="Fact",q="What spin is a proton?.",a="1/2"},
- {s="Fact",q="Can there be a maximum number of protons to a nucleus?.",a="yes"},
- {s="Fact",q="Which elementary particle is analogous \n to the exchange of photons in \n the electromagnetic force between \n two charged particles, \n and is used to keep protons and neutrons \n ect, together?",a="gluon"},
- {s="Fact",q="What atom am i talking about, it has 20 electrons. ",a="calcium"},
- {s="Fact",q="Which atom is used all around the world \n mainly because of its valence electrons? ",a="carbon"},
- }},
- {s="Computercraft",q={
- {s="Fact",q="What math function would i use to check \n the color table based on a \n16bit number? ",a="math.log"},
- {s="Fact",q="Should i calculate before drawing or draw before calculating?",a="draw before calculating"},
- {s="Fact",q="Write the code needed to move \n the player on the map from its x \n and y to x+1, y-1 and check \n the collision before moving. \n(player id is 1 and block id \nis anything but 0) ",a="if(map[y-1][x+1] == 0)then map[y][x] = 0 map[y-1][x+1] = 1 end"},
- {s="Fact",q="Whats more effective than calling player.draw(player)? ",a="player:draw()"},
- {s="Fact",q="Is Computercrafts fs api the same as Lua's?",a="no"},
- {s="Fact",q="Whats the best way to eliminate \n screen flickering in \n 1 word.",a="buffers"},
- {s="Fact",q="Whats the most effective way to \n store information \n for a map?",a="tables"},
- {s="Fact",q="Is there a way to condense a space? (byte(32))",a="yes"},
- {s="Fact",q="Whats the lazy way to eliminate \n screen flickering? \n (Type the function but \n dont pass an argument)",a="term.current().setVisible"},
- {s="Fact",q="Who invented ComputerCraft?",a="Dan200"},
- }},
- }
- qtable = {}
- local function reverse(tbl)
- ntbl = {}
- ntbl[1] = tbl[#tbl]
- for i = 1, #tbl do
- ntbl[i] = tbl[#tbl]
- end
- return ntbl
- end
- local function lnwrite(txt)
- local x,y = term.getCursorPos()
- local ln = 0
- for line in txt:gmatch("[^\n]+") do
- scp(x,y+ln)
- write(line)
- ln = ln + 1
- end
- end
- local function getlns(txt)
- local ln = 0
- for line in txt:gmatch("[^\n]+") do
- ln = ln + 1
- end
- return ln
- end
- local function starfield(chance)
- local scols = {colors.white,colors.lightGray,colors.gray}
- --local ptc = term.getTextColor()
- for y = 1, h do
- for x = 1, w do
- if(math.random(0,chance) == 1)then
- stc(scols[math.random(1,3)])
- scp(x,y)
- write("*")
- end
- end
- end
- stc(colors.white)
- end
- local function msgbox(msg,isc)
- local ccs = {
- colors.gray,
- colors.lime,
- colors.green,
- }
- local ics = {
- colors.pink,
- colors.orange,
- colors.red,
- }
- --local ptc = term.getTextColor()
- stc(colors.white)
- local bw = w
- local bh = 5
- local ume = ics
- if(isc)then ume = ccs end
- for i = 1, #ume do
- fbox(1, math.max(h/2) - bh/2,bw, math.floor(h/2) + bh/2,ume[i])
- sleep(0.1)
- end
- scp( ((w/2)) - (#msg/2), math.max(h/2)-(getlns(msg)-1))
- lnwrite(msg)
- stc(colors.lightGray)
- scp( ((w/2)) - 6, math.floor(h/2)+(getlns(msg)-1))
- lnwrite("Press any key.")
- os.pullEvent("key")
- stc(colors.white)
- return isc
- end
- local function clscr()
- sbc(theme.bc)
- stc(theme.tc)
- cls()
- starfield(20)
- end
- local function transition(speed)
- local c = {
- colors.gray,
- colors.lightGray,
- colors.white,
- }
- for i = 1, 2 do
- for i = 1, #c do
- sbc(c[i])
- cls()
- sleep(speed)
- end
- reverse(c)
- end
- end
- local function spaceBox(inout)
- local bh = 5
- if(inout == 'in')then
- sbc(theme.bc)
- cls()
- sleep(0.01)
- for cop = 0, bh do
- term.current().setVisible(false)
- sbc(theme.bc)
- cls()
- starfield(20)
- fbox(1, math.max(h/2) - cop/2,w, math.floor(h/2) + cop/2,colors.purple)
- term.current().setVisible(true)
- sleep(0.001)
- end
- elseif(inout == 'out')then
- for cop = 0, bh do
- term.current().setVisible(false)
- sbc(theme.bc)
- cls()
- sleep(0.01)
- starfield(20)
- fbox(1, math.max(h/2) - (bh-cop)/2,w, math.floor(h/2) + (bh-cop)/2,colors.purple)
- term.current().setVisible(true)
- sleep(0.001)
- end
- sbc(theme.bc)
- cls()
- sleep(0.01)
- end
- end
- local function win()
- clscr()
- stc(theme.qtc)
- local bh = 5
- starfield(20)
- msgloop = {
- "You have proven you're intelligence!",
- "Nova warmly invites you to join a group of",
- "Interblocktional Space And Physics thoery! (ISAP)",
- "Welcome aboard! we will now send the coords to",
- "Beam up to our academy!",
- "Do you accept this request to beam up?"
- }
- for i = 1, #msgloop do
- msg = msgloop[i]
- spaceBox('in')
- scp( ((w/2)) - (#msg/2), math.floor(h/2))
- write(msg)
- if(i == #msgloop)then
- stc(colors.pink)
- scp( ((w/2)) - 9, math.floor(h/2)+1)
- lnwrite("Press Y to accept.")
- local _, k = os.pullEvent("key")
- if(k == keys.y)then
- --]] Beam dem up suun, WOW (wink)!
- spaceBox('out')
- local cmd = peripheral.wrap("back")
- -- ]] Set cmd block cmd and teleport to it
- else
- os.reboot()
- end
- else
- os.pullEvent("key")
- spaceBox('out')
- end
- end
- end
- local function qDraw(qNum)
- clscr()
- starfield(20)
- scp(2,1)
- write(qNum .. ". " .. "Subject: " .. qtable[qNum].s)
- sbc(theme.barbc)
- local rev = false
- for i = 0, getlns(qtable[qNum].q) do
- if(rev)then line(3,3+i,w,3+i) else line(2,3+i,w-1,3+i) end
- rev = not rev
- end
- stc(theme.bartc)
- scp(4,3)
- lnwrite(qtable[qNum].q)
- sbc(theme.qbc)
- stc(theme.qtc)
- scp(1,10)
- write(string.rep(" ",4) .."Type answer below.")
- sbc(theme.answerbc)
- stc(theme.answertc)
- scp(10,14)
- write(string.rep(" ",w-18))
- scp(10,14)
- local ans = read()
- if(string.lower(ans) ==string.lower(qtable[qNum].a))then
- --]] then User got the question correct.
- qcor = qcor + 1
- end
- transition(0.1)
- if(qNum < #qtable)then
- return qDraw(qNum+1)
- else
- -- Test is over!, calculate final score!
- local perc = (qcor/#qtable)*100
- local grade = "DNF"
- if(perc == 100) then grade = "A"
- elseif(perc >= 90)then grade = "A+"
- elseif(perc >= 80)then grade = "B"
- elseif(perc >= 70)then grade = "C"
- elseif(perc >= 60)then grade = "D"
- elseif(perc < 60) then grade = "F"
- end
- clscr()
- local good = (perc >= 85)
- msgbox("Final Score: " .. perc .. "% " .. "\nGrade: " .. grade .. "\nPassing: " .. tostring(good),good)
- if(good)then return win() end
- clscr()
- sleep(0.1)
- os.reboot()
- end
- end
- local function choosesubject()
- clscr()
- fbox(5,3,w-2,h-2,colors.lightGray)
- scp(5,2)
- sbc(colors.gray)
- term.clearLine()
- write(" Subject Name | Number of Questions ")
- local selsub = 1
- local offs = 0
- local insel = true
- local function draw()
- local mdraw = #subjects
- if(mdraw - h-4 > 0)then mdraw = h-4 end
- for i = 1+offs, mdraw+offs do
- sbc(colors.lightGray)
- stc(colors.black)
- if(selsub == i)then
- sbc(colors.gray)
- stc(colors.white)
- end
- scp(5,(i-offs)+3)
- write(subjects[i].s .. " " .. "Q: " .. #subjects[i].q)
- end
- end
- local function update(e)
- if(e[1] == "key")then
- if(e[2] == keys.up and selsub > 1)then
- selsub = selsub - 1
- draw()
- elseif(e[2] == keys.down and selsub < #subjects)then
- selsub = selsub + 1
- draw()
- elseif(e[2] == keys.enter)then
- insel = false
- return subjects[selsub].q
- end
- end
- end
- local function loop()
- while insel do
- local e = {os.pullEvent()}
- local res = update(e)
- if(res ~= nil)then return res end
- end
- end
- draw()
- qtable = loop()
- qDraw(1)
- end
- choosesubject()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement