Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --FunnyCalc, a "fake" calculator
- --By CodedPixelCube, aka Minimite, for ComputerCraft, a Minecraft mod that adds computers
- term.clear()
- term.setCursorPos(1,1)
- function execute(executeCode)
- --name of the file, if you use error command it will show this file
- local defFile = "calcemulator"
- --open and write the code they want inside the file
- local open = fs.open(defFile, "w")
- open.write(executeCode)
- open.close()
- --run the file
- shell.run(defFile)
- --sleep for a little just in case something breaks
- sleep(0)
- --delete the file, we don't need it anymore
- fs.delete(defFile)
- end
- while true do
- local input = read()
- local input = input:gsub(" ","")
- --stupid things you can also put in
- if input == "meaningoflife,theuniverse,andeverything" then
- print("42")
- elseif input == "9+10" then
- print("21")
- elseif input == "9 + 10" then
- print("21")
- elseif input == "exit" then
- return
- elseif input == "Bornholm" then --bornholm is a danish island
- print("588 square kilometers")
- elseif input == "cake" then
- print("Yummy!")
- elseif input == "fire" then
- print("BEEEE DOOOOO BEEEEE DOOOOOO BEEEEE DOOOO BEEEEEE DOOOOOOO")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- --part to go back toe xecuting code
- elseif string.find(input, "execute") then
- local codetoexecute = input:gsub("execute","")
- execute(codetoexecute)
- else
- --get the input with only the digits
- local inputclean = input:gsub("%D","")
- --if no numbers
- if inputclean == "" then
- elseif inputclean == " " then
- elseif inputclean == nil then
- else
- --if yes numbers, set the random seed to the
- --input with only digits
- math.randomseed(inputclean)
- --pick a random number 1,50 depending on randomseed
- print(math.random(1,50))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement