This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
masterdisasterHD's profile picture

[cc 1.45+] [Adv. Comp.] HD's menu program

Started by masterdisasterHD, 28 February 2013 - 08:45 AM
masterdisasterHD #1
Posted 28 February 2013 - 09:45 AM
This is a menu program i made with loads of functions.

Auto update is disabled in beta version to prevent downgrading

REGULAR
Pastebin: http://pastebin.com/sPQBJNgi
Computer: pastebin get sPQBJNgi menu

BETA
Pastebin: http://pastebin.com/0EdjR85v
Computer: pastebin get 0EdjR85v menu

usage:
SpoilerUse up / down arrows to navigate
Press enter to enter / run menu item


if you want to be able to terminate the menu then do the following:
edit menu
change
local noTerminate = true
to
local noTerminate = false
save menu
run menu

If you want to disable auto update then do the following:
edit menu
change
local autoUpdate = true
to
local autoUpdate = false
save menu
run menu

NEW Screenshots:
SpoilerMain menu:


System menu:


Matrix with colours:


BETA

Updated peripheral checker:


Peripheral Log File:

Current features:
File Browser
FireWolf (by 1lann and gravityscore)
Advanced calculator (by craniumkid)
Games (by dan200 and Cloudy)
DarkChat (by darkriser)
Matrix
Smart Pastebin
+Added Auto updater

Releases:
Spoilerv10 (current):
-loads of functions
-Firewolf
-Calculator
-DarkChat
-Matrix
-Smart Pastebin
+Auto updater
*bugfixes


V5:
-fixed chat downloading not working
-first release
-loads of functions
-Firewolf
-Calculator
-DarkChat
+Matrix
+Smart Pastebin

Beta releases:
Spoilerv12 (current beta):
*Improved peripheral logging
*Bug fixes



v11:
+Added peripheral logging
+Menu doesn't work when http api is not enabled
*Bug fixes
Code:
Spoiler

if term.isColour() then
--[[ Local Variables ]]--

local termWidth, termHeight = term.getSize()
local selectedItem = 1
local ModemCount = 0
local version = "10.0"
local autoUpdate = true
local rsActive = false
local noTerminate = true
local inMainMenu = true
local inRSMenu = false
local inRednetMenu = false
local inUserMenu = false
local inSysMenu = false
local inFWMenu = false
local inMiscMenu = false
local inGameMenu = false
local inChatMenu = false

--[[ Auto Updater ]]--

if autoUpdate == true then
term.clear()
term.setCursorPos(1,1)
newVersion = http.get("https://raw.github.com/MasterdisasterHD/menu/master/Menu%20version.lua")
if newVersion then
  newVersion2 = newVersion.readAll()
  if newVersion2 ~= version then
   print("New version availble ( "..newVersion2.." )")
	write("Update yes/no: ")
	X = read()
	if string.lower(X) =="yes" then
	fs.delete(".noTerminate")
	fs.delete(".smartPB")
	fs.delete(".USERS")
	fs.delete(".rsSide")
	fs.delete(".LIGHTS")
   A = shell.getRunningProgram()
	fs.delete(A)
	menu = http.get("http://pastebin.com/raw.php?i=sPQBJNgi")
	program = fs.open(A, "w")
	program.write(menu.readAll())
	program.close()
	print("Done, press any key to return")
   os.pullEvent("key")
  else
  end
	elseif string.lower(X) ~= "yes" then

	end
elseif not newVersion then
  print("An error occured")
  print("Press any key to continue loading the menu")
os.pullEvent("key")
end
else
end

--[[ Default redstone side ]]--

if fs.exists(".rsSide") then
  A = fs.open(".rsSide", "r")
  redstoneSide = A.readLine()
  A.close()
else
  redstoneSide = "left"
end

--[[ Checking for user directory ]]--

if not fs.isDir(".USERS") then
  fs.makeDir(".USERS")
else
end

--[[ Check Terminate ]]--

if noTerminate == true then
  A = fs.open(".noTerminate", "w")
  A.writeLine(noTerminate)
  A.close()

  os.pullEvent = os.pullEventRaw
else
  A = fs.open(".noTerminate", "w")
  A.writeLine(noTerminate)
  A.close()
end

--[[ Modem Detector ]]--

for i, v in pairs(rs.getSides()) do
  if peripheral.isPresent(v) and peripheral.getType(v)=="modem" then
   rednetSide = v
  else
		ModemCount = ModemCount + 1
		  if ModemCount == 6 then
				term.clear()
				term.setCursorPos(1,1)
				print("No modem found!")
				inMainMenu = false
		end
  end
end

--[[ Functions ]]--

function clear()
  term.clear()
  term.setCursorPos(1,1)
  term.setCursorBlink(false)
end

clear()

function back()
  inMainMenu = true
  running = true
  inRSMenu = false
  inRednetMenu = false
  inUserMenu = false
  inSysMenu = false
  inFWMenu = false
  inMiscMenu = false
  inGameMenu = false
  inChatMenu = false
  clear()
end

function userMenu()
  inUserMenu = true
  selectedItem = 1

  while inUserMenu do
		clear()
		inUserMenu = true
		printMenu(userMenuOptions)

		event, key = os.pullEvent("key")
		onKeyPressed(key, userMenuOptions)
  end
end

function addUser()
  if not fs.isDir(".USERS") then
		fs.makeDir(".USERS")
  end
  clear()
  write("Username: ")
  name = read()
		if fs.exists(".USERS/"..name) then
		  print("Username Already Exists")
		  print("Rewriting file...")
		  sleep(3)
		else

		end
  write("\Password: ")
  pass1 = read("*")
  write("\Confirm Password: ")
  pass2 = read("*")
  if pass1 ~= nil then
  if pass1==pass2 or pass2==pass1 then
		newUser = fs.open(".USERS/"..name, "w")
		newUser.writeLine(pass1)
		newUser.close()
		fs.makeDir(name)
  else
		print("Passwords do not match!")
		sleep(3)
  end
  else
		newUser = fs.open(".USERS/"..name, "w")
		newUser.writeLine("")
		newUser.close()
  end
end

function delUser()
  clear()
  write("Username: ")
  name = read()

  if fs.exists(".USERS/"..name) then
		if fs.isDir(name) then
		  fs.delete(name)
		else
		end
		fs.delete(".USERS/"..name)
  else
		clear()
		print("This user does not exist!")
		sleep(3)
  end
end

function listUsers()
  if not fs.isDir(".USERS") then
		fs.makeDir(".USERS")
  end
  clear()
  A = fs.list(".USERS/")
  for _, userList in ipairs(A) do
		print(userList)
  end

  term.setTextColour(colors.lime)
  print("Press any key to return")
  term.setTextColour(colors.white)
  os.pullEvent("key")
end

function RedstoneMenu()
  inRSMenu = true

  while inRSMenu do
		clear()
		inRSMenu = true
		print("Current redstone output: "..redstoneSide)
		if rsActive == true then
		  V = "ACTIVE"
		elseif rsActive == false then
		  V = "INACTIVE"
		end
		print("State: "..V)
		printMenu(rsMenu)

		event, key = os.pullEvent("key")
		onKeyPressed(key, rsMenu)
  end  
end

function rsOn()
  Q = fs.open(".LIGHTS", "w")
  Q.writeLine("ON")
  Q.close()
  rs.setOutput(redstoneSide, true)
  clear()
rsActive = true
end

function rsOff()
  Q = fs.open(".LIGHTS", "w")
  Q.writeLine("OFF")
  Q.close()
  rs.setOutput(redstoneSide, false)
  clear()
rsActive = false
end

--[[ Redstone Changer ]]--

function changeRS()
RSsides = {
"front";
"back";
"left";
"right";
"top";
"bottom"
}
rsCount = 0
  clear()
  textutils.slowWrite("New side: ")
  redstoneSide = string.lower(read())
  for n=1,6 do
   if redstoneSide==RSsides[n] then
		A = fs.open(".rsSide", "w")
		A.writeLine(redstoneSide)
		A.close()
   else
		rsCount = rsCount + 1
		if rsCount==6 then
		  clear()
		  print("That side is invalid!")
		  sleep(3)
		  changeRS()
		else
   end
  end
end
end

function redOptions()
  inRednetMenu = true
  selectedItem = 1
  while inRednetMenu do
		clear()
		inRednetMenu = true
		printMenu(rednetMenu)

		event, key = os.pullEvent("key")
		onKeyPressed(key, rednetMenu)
  end
end

function redSend()
  clear()
  write("Message: ")
  msg1 = read()
  write("ID: ")
  id = tonumber(read())
  rednet.open(rednetSide)
  rednet.send(id, msg1)
  rednet.close(rednetSide)
end

function redReceive()
  clear()
  rednet.open(rednetSide)
  id, msg2 = rednet.receive()
  print(id.." sent: "..msg2)
  rednet.close(rednetSide)
  term.setTextColour(colors.lime)
  print("Press any key to return")
  term.setTextColour(colors.white)
  os.pullEvent("key")
end

function redBroadcast()
  clear()
  write("Message: ")
  msg3 = read()
  rednet.open(rednetSide)
  rednet.broadcast(msg3)
  rednet.close(rednetSide)
end

function changeUser()
  clear()
  textutils.slowWrite("Username: ")
  userName = read()
  textutils.slowWrite("Password: ")
  pass1 = read("*")
  textutils.slowWrite("Confirm password: ")
  pass2 = read("*")
  if pass2==pass1 or pass1==pass2 then
		A = fs.open(".USERS/"..userName, "w")
		A.writeLine(pass1)
		A.close()
		clear()
  else
		print("Passwords do not match!")
		sleep(3)
		clear()
  end
end

function sysMenu()
  inSysMenu = true
  selectedItem = 1
  while inSysMenu do
		clear()
		inSysMenu = true
		printMenu(sysMenuOptions)

		event, key = os.pullEvent("key")
		onKeyPressed(key, sysMenuOptions)
  end
end

function labelPC()
  clear()
  if os.getComputerLabel() ~= nil then
		print("Current label: "..os.getComputerLabel())
  else
		print("Current label: none")
  end
  write("New label: ")
  label = read()
  if label ~= nil then
  os.setComputerLabel(label)
  else
		print("Label was not entered.")
		sleep(3)
  end
end

function renMenu()
  clear()
  print("Curent name: "..shell.getRunningProgram())
  write("New name: ")
  X = read()
  shell.run("rename", shell.getRunningProgram(), X)
end

function fwMenuOptions()
  clear()
  selectedItem = 1
  inFWMenu = true
  while inFWMenu do
		clear()
		inFWMenu = true
		printMenu(fireWolf)

		event, key = os.pullEvent("key")
		onKeyPressed(key, fireWolf)
  end
end

function fwDownload()
  clear()
  name = "FireWolf"
  shell.run("pastebin", "get", "A7wGH3ty", name)
  print("Done, press any key to return")
os.pullEvent("key")
end

function fwRun()
  clear()
  if fs.exists("FireWolf") then
		shell.run("FireWolf")
  else
		clear()
		print("Download FireWolf first!")
		sleep(3)
		clear()
  end
end

function openLua()
  clear()
  shell.run("lua")
end

function Exit()
running = false
clear()
end

function deleteFW()
  clear()
  write("Are you sure: ")
  A = string.lower(read())
  if A == "yes" then
		if fs.exists("FireWolf") then
		  fs.delete("FireWolf")
		else
		  print("FireWolf does not exist yet")
		  sleep(3)
		  back()
		end
  elseif A == "no" then
		back()
  end
end

function miscOptions()
  clear()
  inMiscMenu = true
  selectedItem = 1
  while inMiscMenu do
		  inMiscMenu = true
		  clear()
		  printMenu(miscMenu)

		  event, key = os.pullEvent("key")
		  onKeyPressed(key, miscMenu)
  end
end

function startMatrix()
function digiRain()



function Lime()
		clear()
		selectedItem = 1
		running = true
		x, y = term.getSize()
term.setTextColor(colours.lime)
term.clear()
function draw()
term.setCursorPos(math.random(1,x),math.random(1,y))
write(string.char(math.random(32,126)))
curx, cury = term.getCursorPos()
end
function run()
while running do
num = 0
repeat
draw()
num = num + 1
until num == 100
sleep(0)
end
end
run()
end
function moreC()
running = true
  x, y = term.getSize()
term.clear()
function draw()
term.setCursorPos(math.random(1,x),math.random(1,y))
write(string.char(math.random(32,126)))
curx, cury = term.getCursorPos()
end
function run()
while running do
num = 0
repeat
C = 2^math.random(0, 14)
term.setTextColour(C)
draw()
num = num + 1
until num == 100
sleep(0)
end
end
run()
end
clear()
  print("Press C for rainbow matrix")
  print("Press L for lime only")
  print("Press any other key to return")

  event2, key2 = os.pullEvent("char")

if string.lower(key2) == "l" then
  Lime()
elseif string.lower(key2) == "c" then
  moreC()
elseif string.lower(key2) ~= "c" or string.lower(key2) ~= "l" then

end
end

  function stopMatrix()
	  sleep(3)
		repeat
		  event, key = os.pullEvent("key")
		  clear()
		  running = false
		  term.setTextColour(colors.white)
		until event or key
  end
  parallel.waitForAny(digiRain, stopMatrix)
end

function games()
selectedItem = 1
  clear()
  inGameMenu = true
  while inGameMenu do
		inGameMenu = true
		clear()
		printMenu(gameMenu)
		event, key = os.pullEvent("key")
		onKeyPressed(key, gameMenu)
  end  
end

function worm()
  clear()
  shell.run("worm")
end

function adventure()
  clear()
  shell.run("adventure")
end

function dChatMenu()
  inChatMenu = true
  clear()
  selectedItem = 1
  while inChatMenu do
		inChatMenu = true
		clear()
		printMenu(chatMenu)
		event, key = os.pullEvent("key")
		onKeyPressed(key, chatMenu)
  end
end

function dwChat()
  clear()
  print("Downloading DarkChat...")
  C = http.get("https://raw.github.com/darkrising/darkprograms/darkprograms/chat")
  if C then
		cB = fs.open(".chat", "w")
		cB.write(C.readAll())
		cB.close()
   print("Completed")
   print("Press any key to return")
   os.pullEvent("key")
  else
   print("Failed")
   print("Press any key to return")
   os.pullEvent("key")
  end
end

function runChat()
  clear()
  if fs.exists(".chat") then
		shell.run(".chat")
  else
		print("Chat has not been downloaded yet")
  end
		print("Press any key to return")
   os.pullEvent("key")
end

function delChat()
  clear()
  if fs.exists(".chat") then
		fs.delete(".chat")
  else
		print("Chat does not exist yet")
  end
   print("Press any key to return")
  os.pullEvent("key")
end

function fbr()
  clear()
  if not fs.exists("FileBrowser") then
		fbrowse = http.get("http://pastebin.com/raw.php?i=55fk1H9y")
		fFile = fs.open("FileBrowser", "w")
		fFile.write(fbrowse.readAll())
		fFile.close()
   shell.run("FileBrowser")
  else
   shell.run("FileBrowser")
  end
end

function checkPeripherals()
  pCount = 0
clear()
  for i, v in pairs(rs.getSides()) do
   sleep(0,5)
		if peripheral.isPresent(v) then
		A = peripheral.getType(v)
		if A ~= nil then
		  print(v, ": "..A)
		end
		else
		  pCount = pCount + 1
		end
		if pCount == 6 then
		  print("No peripherals found.")
		end
  end
   print("Press any key to return")
  os.pullEvent("key")
end

function delMenu()
  clear()
  write("Are you sure: ")
  X = string.lower(read())
  if X == "yes" then
		fs.delete(shell.getRunningProgram())
		fs.delete(".rsSide")
		for i, v in ipairs(fs.list(".USERS/")) do
		  fs.delete("/"..v)
		end
		fs.delete(".USERS")
		fs.delete(".LIGHTS")
		fs.delete(".noTerminate")
		fs.delete(".smartPB")
   print("Done, press any key to reboot")
  os.pullEvent("key")
   os.reboot()
  elseif X ~= "yes" then
		clear()
  end
end

function menuReset()
  clear()
		fs.delete(".rsSide")
		print("Deleted: .rsSide")
		for i, v in ipairs(fs.list(".USERS/")) do
		  fs.delete("/"..v)
		  print("Deleted user: "..v)
		end
		fs.delete(".USERS")
		print("Deleted .USERS folder")
		fs.delete(".LIGHTS")
		print("Deleted .LIGHTS")
		fs.delete(".noTerminate")
		print("Deleted .noTerminate")
   print("Done, press any key to return")
  os.pullEvent("key")
end

function redwMenu()
  clear()
		--[[ File deleter ]]--
  fs.delete(".rsSide")
		print("Deleted: .rsSide")
		for i, v in ipairs(fs.list(".USERS/")) do
		  fs.delete("/"..v)
		  print("Deleted user: "..v)
		end
		fs.delete(".USERS")
		print("Deleted .USERS folder")
		fs.delete(".LIGHTS")
		print("Deleted .LIGHTS")
		fs.delete(".noTerminate")
		print("Deleted .noTerminate")
		fs.delete(".smartPB")
		print("Deleted: .smatPB")

		--[[ Other stuff ]]--
  ABC = http.get("http://pastebin.com/raw.php?i=sPQBJNgi")
  if ABC then
   fs.delete(shell.getRunningProgram())
		A = fs.open("menu", "w")
		A.write(ABC.readAll())
		A.close()
		print("Done, press any key to restart menu")
		os.pullEvent("key")
   shell.run("menu")
   inSysMenu = false
   selectedItem = 1
  else
		print("Failed, press any key to return")
		os.pullEvent("key")
  end
end

function wipe()
  clear()
  for i,v in ipairs(fs.list("")) do
		sleep(0,5)
		if not fs.isReadOnly(v) and v ~= shell.getRunningProgram() then
		fs.delete(v)
		print("Deleted: "..v)
		end
  end
term.setTextColour(colors.lime)
print("Press any key to return")
term.setTextColour(colors.white)
os.pullEvent("key")
end

function calc()
  local tX, tY = term.getSize()
local calc = {}

--equation states
calc.mode = false
calc.inverse = false
calc.hyp = false
calc.sqrt = false
calc.exp = false
calc.asin = false
calc.sin = false
calc.sinh = false
calc.atan = false
calc.tan = false
calc.tanh = false
calc.acos = false
calc.cos = false
calc.cosh = false
calc.log = false
calc.pos = false

-- characters
local charList = {
		["0"] = {
				".-.",
				"| |",
				"'-'"
		},
		["1"] = {
				" . ",
				"'| ",
				"---"
		},
		["2"] = {
				".-.",
				".-'",
				"'- "
		},
		["3"] = {
				" -.",
				" -|",
				" -'"
		},
		["4"] = {
				". .",
				"'-|",
				"  '"
		},
		["5"] = {
				".- ",
				"'-.",
				" -'"
		},
		["6"] = {
				".-.",
				"|-.",
				"'-'"
		},
		["7"] = {
				".-.",
				"  |",
				"  '"
		},
		["8"] = {
				".-.",
				"|-|",
				"'-'"
		},
		["9"] = {
				".-.",
				"'-|",
				" -'"
		},
		["."] = {
				"   ",
				"   ",
				" . "
		},
		["-"] = {
				"   ",
				" --",
				"   "
		},
}
-- lay out the button labels
local labels = {
		' + ', ' 1 ', ' 2 ', ' 3 ', '<--', 'sin', 'x^y', 'DEG', 'OFF',
		' - ', ' 4 ', ' 5 ', ' 6 ', 'CLR', 'cos', 'srt', 'RAD', '   ',
		' x ', ' 7 ', ' 8 ', ' 9 ', '   ', 'tan', 'Pi ', 'inv', '   ',
		' / ', ' 0 ', '-/+', ' . ', ' = ', 'log', 'exp', 'hyp', '   '
}


-- generate the objects
local function objGen()
		local _objects = {}
		local width = 9
		for i=1, #labels do
				table.insert(_objects, {
						x = (((i - 1)%width + 1)*5) - 1;
						y = (math.ceil(i/width) * 3) + 4;
						label = labels[i];
						-- make operators different colors
						color =
						i == 1 and colors.blue or
						i == 5 and colors.red or
						i == 6 and colors.yellow or
						i == 7 and colors.orange or
						i == 8 and colors.white or
						i == 9 and colors.red or
						i == 10 and colors.blue or
						i == 14 and colors.red or
						i == 15 and colors.yellow or
						i == 16 and colors.orange or
						i == 17 and colors.white or
						i == 18 and colors.white or
						i == 19 and colors.blue or
						i == 24 and colors.yellow or
						i == 25 and colors.orange or
						i == 26 and colors.white or
						i == 27 and colors.white or
						i == 28 and colors.blue or
						i == 30 and colors.red or
						i == 32 and colors.white or
						i == 33 and colors.yellow or
						i == 34 and colors.orange or
						i == 35 and colors.white or
						i == 36 and colors.white or
						colors.lightGray;
						-- controls the highlight colors for operators
						back =
						i == 6 and
								calc.sin == true and colors.red or
								calc.asin == true and colors.red or
								calc.sinh == true and colors.red or
						i == 8 and calc.mode == "deg" and colors.blue or
						i == 15 and
								calc.cos == true and colors.red or
								calc.acos == true and colors.red or
								calc.cosh == true and colors.red or
						i == 16 and calc.sqrt == true and colors.lightBlue or
						i == 17 and calc.mode == "rad" and colors.blue or
						i == 24 and
								calc.tan == true and colors.red or
								calc.atan == true and colors.red or
								calc.tanh == true and colors.red or
						i == 26 and calc.inverse == true and colors.blue or
						i == 30 and calc.pos == true and colors.white or
						i == 33 and calc.log == true and colors.red or
						i == 34 and calc.exp == true and colors.lightBlue or
						i == 35 and calc.hyp == true and colors.blue or
						colors.black;
				})
		end
return _objects
end

local function draw()
		term.setBackgroundColor(colors.black)
		term.clear()
		local objects = objGen()
		for i=1, #objects do
				local obj = objects[i]
				term.setTextColor(colors.gray)
				term.setBackgroundColor(colors.black)
				--draw the grid
				for num, line in pairs{'+---+','|   |','+---+'} do
						term.setCursorPos(obj.x, obj.y + num - 1)
						write(line)
				end
				--draw the button text and colors
				term.setCursorPos(obj.x+1, obj.y+1)
				term.setTextColor(obj.color)
				term.setBackgroundColor(obj.back)
				write(obj.label)
		end
end
--draw border and screen
local function display()
		term.setBackgroundColor(colors.black)
		term.setTextColor(colors.gray)
		term.setCursorPos(2,1)
		write("+"..string.rep("-", tX - 4).."+")
		for i = 2, tY - 1 do
				term.setCursorPos(2,i)
				write("|")
				term.setCursorPos(tX - 1,i)
				write("|")
		end
		term.setCursorPos(2,tY)
		write("+"..string.rep("-", tX - 4).."+")
		term.setBackgroundColor(colors.lightGray)
		for i = 2, 6 do
				term.setCursorPos(4,i)
				write(string.rep(" ", tX - 6))
		end
end
--run the equation passed by the user.
local function calculate(eq)
		if table.concat(eq) == "()" then
				eq = {"0"}
		elseif table.concat(eq) == "(.)" then
				eq = {"0"}
		end
		local sExpr = table.concat(eq)
		local fnMath, sErr = loadstring("return "..sExpr)
		if not fnMath then
				return "ERROR! Check syntax!"
		end
		--setfenv(fnMath, math)
		local bSucc, vRes = pcall(fnMath)
		if not bSucc then
				return "ERROR! Check syntax!"
		else
				return vRes
		end
end

-- function loop
local equation = {"(", ")"}
local result = "0"
while true do
		local rLen = 0
		draw()
		display()
		term.setBackgroundColor(colors.lightGray)
		term.setTextColor(colors.white)
		term.setCursorPos(4,2)
		--write the equation
		write(table.concat(equation))
		--write the result
		if tonumber(result) ~= inf then
				if string.len(result) >= 15 then
						term.setCursorPos(5, 4)
						term.setTextColor(colors.black)
						write("= ")
						for num in string.gmatch(result, ".") do
								rLen = rLen + 1
								local pX,pY = term.getCursorPos()
								if pX >= 4 and pX <= 48 then
										term.setCursorPos(rLen + 5, 4)
										write(num)
								else
										term.setCursorPos(rLen + 5 - 48, 5)
										write(num)
								end
						end
				else
						for num in string.gmatch(result, ".") do
								rLen = rLen + 1
								for i = 1, #charList[num] do
										term.setTextColor(colors.black)
										term.setCursorPos((rLen * 3) + 1, i + 3)
										write(charList[num][i])
								end
						end
				end
		elseif result == nil then
				term.setCursorPos(5, 4)
				term.setTextColor(colors.black)
				write("= ERROR")
		else
				term.setCursorPos(5, 4)
				term.setTextColor(colors.black)
				write("= INFINITY")
		end
		local events = {os.pullEvent()}
		--mouse click filter
		if events[1] == "mouse_click" and events[2] == 1 then
				if events[3] >= 44 and events[3] <= 48 then
						if events[4] >= 7 and events[4] <= 9 then
								term.setBackgroundColor(colors.black)
								term.clear()
								term.setCursorPos(1,1)
								break
						end
				elseif events[3] >= 39 and events[3] <= 43 then
						if events[4] >= 7 and events[4] <= 9 then
								if calc.mode == false then
										table.remove(equation, 1)
										calc.mode = "deg"
										table.insert(equation, 1, "math.deg(")
								elseif calc.mode == "deg" then
										table.remove(equation, 1)
										calc.mode = false
								elseif calc.mode == "rad" then
										table.remove(equation, 1)
										calc.mode = "deg"
										table.insert(equation, 1, "math.deg(")
								end
						elseif events[4] >= 10 and events[4] <= 12 then
								if calc.mode == false then
										table.remove(equation, 1)
										calc.mode = "rad"
										table.insert(equation, 1, "math.rad(")
								elseif calc.mode == "rad" then
										table.remove(equation, 1)
										calc.mode = false
								elseif calc.mode == "deg" then
										table.remove(equation, 1)
										calc.mode = "rad"
										table.insert(equation, 1, "math.rad(")
								end
						elseif events[4] >= 13 and events[4] <= 15 then
								if calc.inverse == true and calc.hyp == false then
										calc.inverse = false
								elseif calc.inverse == false and calc.hyp == true then
										calc.inverse = true
										calc.hyp = false
								elseif calc.inverse == false and calc.hyp == false then
										calc.inverse = true
								end
						elseif events[4] >= 16 and events[4] <= 18 then
								if calc.hyp == true and calc.inverse == false then
										calc.hyp = false
								elseif calc.hyp == false and calc.inverse == true then
										calc.hyp = true
										calc.inverse = false
								elseif calc.hyp == false and calc.inverse == false then
										calc.hyp = true
								end
						end
				elseif events[3] >= 34 and events[3] <= 38 then
						if events[4] >= 7 and events[4] <= 9 then
								table.insert(equation, #equation, "^")
						elseif events[4] >= 10 and events[4] <= 12 then
								if calc.sqrt == false then
										table.insert(equation, #equation, "math.sqrt(")
										calc.sqrt = true
								elseif calc.sqrt == true then
										table.insert(equation, #equation, ")")
										calc.sqrt = false
								end
						elseif events[4] >= 13 and events[4] <= 15 then
								table.insert(equation, #equation, "math.pi")
						elseif events[4] >= 16 and events[4] <= 18 then
								if calc.exp == false then
										table.insert(equation, #equation, "math.exp(")
										calc.exp = true
								elseif calc.exp == true then
										table.insert(equation, #equation, ")")
										calc.exp = false
								end
						end
				elseif events[3] >= 29 and events[3] <= 33 then
						if events[4] >= 7 and events[4] <= 9 then
								if calc.inverse == true and calc.asin == false then
										table.insert(equation, #equation, "math.asin(")
										calc.asin = true
								elseif calc.inverse == false and calc.hyp == false and calc.sin == false then
										table.insert(equation, #equation, "math.sin(")
										calc.sin = true
								elseif calc.hyp == true and calc.sinh == false then
										table.insert(equation, #equation, "math.sinh(")
										calc.sinh = true
								elseif calc.asin == true then
										table.insert(equation, #equation, ")")
										calc.asin = false
								elseif calc.sin == true then
										table.insert(equation, #equation, ")")
										calc.sin = false
								elseif calc.sinh == true then
										table.insert(equation, #equation, ")")
										calc.sinh = false
								end
						elseif events[4] >= 10 and events[4] <= 12 then
								if calc.inverse == true and calc.acos == false then
										table.insert(equation, #equation, "math.acos(")
										calc.acos = true
								elseif calc.inverse == false and calc.hyp == false and calc.cos == false then
										table.insert(equation, #equation, "math.cos(")
										calc.cos = true
								elseif calc.hyp == true and calc.cosh == false then
										table.insert(equation, #equation, "math.cosh(")
										calc.cosh = true
								elseif calc.acos == true then
										table.insert(equation, #equation, ")")
										calc.acos = false
								elseif calc.cos == true then
										table.insert(equation, #equation, ")")
										calc.cos = false
								elseif calc.cosh == true then
										table.insert(equation, #equation, ")")
										calc.cosh = false
								end
						elseif events[4] >= 13 and events[4] <= 15 then
								if calc.inverse == true and calc.atan == false then
										table.insert(equation, #equation, "math.atan(")
										calc.atan = true
								elseif calc.inverse == false and calc.hyp == false and calc.tan == false then
										table.insert(equation, #equation, "math.tan(")
										calc.tan = true
								elseif calc.hyp == true and calc.tanh == false then
										table.insert(equation, #equation, "math.tanh(")
										calc.tanh = true
								elseif calc.atan == true then
										table.insert(equation, #equation, ")")
										calc.atan = false
								elseif calc.tan == true then
										table.insert(equation, #equation, ")")
										calc.tan = false
								elseif calc.tanh == true then
										table.insert(equation, #equation, ")")
										calc.tanh = false
								end
						elseif events[4] >= 16 and events[4] <= 18 then
								if calc.log == false then
										table.insert(equation, #equation, "math.log10(")
										calc.log = true
								elseif calc.log == true then
										table.insert(equation, ")")
										calc.log = false
								end
						end
				-- backspace, clear, equals
				elseif events[3] >= 24 and events[3] <= 28 then
						if events[4] >= 7 and events[4] <= 9 then
								if table.concat(equation) ~= "()" then
										table.remove(equation, #equation - 1)
								end
						elseif events[4] >= 10 and events[4] <= 12 then
								calc.mode = false
								calc.inverse = false
								calc.hyp = false
								calc.sqrt = false
								calc.exp = false
								calc.asin = false
								calc.sin = false
								calc.sinh = false
								calc.atan = false
								calc.tan = false
								calc.tanh = false
								calc.acos = false
								calc.cos = false
								calc.cosh = false
								calc.log = false
								calc.pos = false
								equation = {"(", ")"}
								result = "0"
						elseif events[4] >= 16 and events[4] <= 18 then
								if equation[#equation-1] == "+" or
										equation[#equation-1] == "-" or
										equation[#equation-1] == "*" or
										equation[#equation-1] == "/" then
										table.insert(equation, #equation, "0")
								elseif equation[#equation-1] == "^" then
										table.insert(equation, #equation, "1")
								end
								for i, v in pairs(calc) do
										if calc[i] == true then
												table.insert(equation, #equation, ")")
												calc[i] = false
										end
								end
								result = tostring(calculate(equation))
						end
				-- 3, 6, 9, decimal
				elseif events[3] >= 19 and events[3] <= 23 then
						if events[4] >= 7 and events[4] <= 9 then
								table.insert(equation, #equation, "3")
						elseif events[4] >= 10 and events[4] <= 12 then
								table.insert(equation, #equation, "6")
						elseif events[4] >= 13 and events[4] <= 15 then
								table.insert(equation, #equation, "9")
						elseif events[4] >= 16 and events[4] <= 18 then
								table.insert(equation, #equation, ".")
						end
				-- 2, 5, 8, positive/negative
				elseif events[3] >= 14 and events[3] <= 18 then
						if events[4] >= 7 and events[4] <= 9 then
								table.insert(equation, #equation, "2")
						elseif events[4] >= 10 and events[4] <= 12 then
								table.insert(equation, #equation, "5")
						elseif events[4] >= 13 and events[4] <= 15 then
								table.insert(equation, #equation, "8")
						elseif events[4] >= 16 and events[4] <= 18 then
								if calc.pos == false then
										table.insert(equation, #equation, "(-")
										calc.pos = true
								elseif calc.pos == true then
										table.insert(equation, #equation, ")")
										calc.pos = false
								end
						end
				-- 1, 4, 7, 0
				elseif events[3] >= 9 and events[3] <= 13 then
						if events[4] >= 7 and events[4] <= 9 then
								table.insert(equation, #equation, "1")
						elseif events[4] >= 10 and events[4] <= 12 then
								table.insert(equation, #equation, "4")
						elseif events[4] >= 13 and events[4] <= 15 then
								table.insert(equation, #equation, "7")
						elseif events[4] >= 16 and events[4] <= 18 then
								table.insert(equation, #equation, "0")
						end
				-- add, subtract, multiply, divide
				elseif events[3] >= 4 and events[3] <= 8 then
						if events[4] >= 7 and events[4] <= 9 then
								table.insert(equation, #equation, "+")
						elseif events[4] >= 10 and events[4] <= 12 then
								table.insert(equation, #equation, "-")
						elseif events[4] >= 13 and events[4] <= 15 then
								table.insert(equation, #equation, "*")
						elseif events[4] >= 16 and events[4] <= 18 then
								table.insert(equation, #equation, "/")
						end
				end
		-- filter for keyboard presses
		elseif events[1] == "key" then
				if events[2] == 79 then
						table.insert(equation, #equation, "1")
				elseif events[2] == 80 then
						table.insert(equation, #equation, "2")
				elseif events[2] == 81 then
						table.insert(equation, #equation, "3")
				elseif events[2] == 75 then
						table.insert(equation, #equation, "4")
				elseif events[2] == 76 then
						table.insert(equation, #equation, "5")
				elseif events[2] == 77 then
						table.insert(equation, #equation, "6")
				elseif events[2] == 71 then
						table.insert(equation, #equation, "7")
				elseif events[2] == 72 then
						table.insert(equation, #equation, "8")
				elseif events[2] == 73 then
						table.insert(equation, #equation, "9")
				elseif events[2] == 82 then
						table.insert(equation, #equation, "0")
				elseif events[2] == 83 then
						table.insert(equation, #equation, ".")
				elseif events[2] == 78 then
						table.insert(equation, #equation, "+")
				elseif events[2] == 74 then
						table.insert(equation, #equation, "-")
				elseif events[2] == 55 then
						table.insert(equation, #equation, "*")
				elseif events[2] == 181 then
						table.insert(equation, #equation, "/")
				elseif events[2] == 14 then
						if table.concat(equation) ~= "()" then
								table.remove(equation, #equation - 1)
						end
				elseif events[2] == 28 or events[2] == 156 then
						if equation[#equation-1] == "+" or
								equation[#equation-1] == "-" or
								equation[#equation-1] == "*" or
								equation[#equation-1] == "/" then
								table.insert(equation, #equation, "0")
						elseif equation[#equation-1] == "^" then
								table.insert(equation, #equation, "1")
						end
						for i, v in pairs(calc) do
								if calc[i] == true then
										table.insert(equation, #equation, ")")
										calc[i] = false
								end
						end
						result = tostring(calculate(equation))
				end
		end
end
term.setTextColour(colors.white)
end

function smartPB()
  A = http.get("http://pastebin.com/raw.php?i=d8RBf7FN")
  B = fs.open(".smartPB", "w")
  B.write(A.readAll())
  B.close()
  shell.run(".smartPB")
end

function mVersion()
clear()
  print("Current version: "..version)
  print("Press any key to return")
os.pullEvent("key")
end

--[[ Menu Definitions ]]--

mainMenu = {
[1] = { text = "Redstone Menu", handler = RedstoneMenu },
[2] = { text = "Rednet Menu", handler = redOptions},
[3] = { text = "User Menu", handler = userMenu },
[4] = { text = "System Menu", handler = sysMenu },
[5] = { text = "FireWolf Menu", handler = fwMenuOptions },
[6] = { text = "Misc menu", handler = miscOptions },
[7] = { text = "Chat menu", handler = dChatMenu },
[8] = { text = "Exit", handler = Exit}
}
chatMenu = {
[1] = { text = "Download chat", handler = dwChat },
[2] = { text = "Run chat", handler = runChat },
[3] = { text = "Delete chat", handler = delChat },
[4] = { text = "Back", handler = back }
}

rsMenu = {
[1] = { text = "Redstone On", handler = rsOn },
[2] = { text = "Redstone Off", handler = rsOff },
[3] = { text = "Change output side", handler = changeRS },
[4] = { text = "Back", handler = back }
}

rednetMenu = {
[1] = { text = "Send message", handler = redSend},
[2] = { text = "Receive message", handler = redReceive},
[3] = { text = "Broadcast message", handler = redBroadcast},
[4] = { text = "Back", handler = back }
}

userMenuOptions = {
[1] = { text = "Add User", handler = addUser },
[2] = { text = "Delete User", handler = delUser },
[3] = { text = "List Users", handler = listUsers },
[4] = { text = "Edit User", handler = changeUser },
[5] = { text = "Back", handler = back }
}

sysMenuOptions = {
[1] = { text = "Rename Menu", handler = renMenu },
[2] = { text = "Open Lua", handler = openLua },
[4] = { text = "Reboot Computer", handler = os.reboot },
[5] = { text = "Stop Computer", handler = os.shutdown },
[3] = { text = "Label Computer", handler = labelPC },
[6] = { text = "Delete menu", handler = delMenu },
[7] = { text = "Reset menu", handler = menuReset },
[8] = { text = "Redownload menu", handler = redwMenu },
[9] = { text = "Version", handler = mVersion },
[10] = { text = "Back", handler = back }
}

fireWolf = {
[1] = { text = "Download/Update Firewolf", handler = fwDownload },
[2] = { text = "Delete Firewolf", handler = deleteFW },
[3] = { text = "Run firewolf", handler = fwRun },
[4] = { text = "Back", handler = back }
}

miscMenu = {
[1] = { text = "Matrix", handler = startMatrix },
[2] = { text = "Games", handler = games },
[3] = { text = "Calculator", handler = calc },
[4] = { text = "File browser", handler = fbr },
[5] = { text = "Peripheral checker", handler = checkPeripherals },
[6] = { text = "Wipe computer", handler = wipe },
[7] = { text = "Smart Pastebin", handler = smartPB },
[8] = { text = "Back", handler = back}
}

gameMenu = {
[1] = { text = "Adventure", handler = adventure },
[2] = { text = "Worm", handler = worm },
[3] = { text = "Back", handler = miscOptions }
}

--[[ Printing Methods ]]--

function printMenu( menu )
  for i=1,#menu do
		if i == selectedItem then
		 term.setTextColour(colors.lime) write(">> ") term.setTextColour(colors.white) write(menu[i].text) term.setTextColour(colors.lime) write(" <<") term.setTextColour(colors.white) print("")
		else
		  print("   "..menu[i].text.."   ")
		end
		  if selectedItem > #menu then
				selectedItem = 1
		  end
		end



--[[ Handler Methods ]]--

function onKeyPressed( key, menu )
  if key == keys.enter then
		onItemSelected(menu)
  elseif key == keys.up then
		if selectedItem > 1 then
		  selectedItem = selectedItem - 1
		end
  elseif key == keys.down then
		if selectedItem < #menu then
		  selectedItem = selectedItem + 1
		  end
		end	
  end
end

function onItemSelected( menu )
  menu[selectedItem].handler()
end

--[[ Main Methods ]]--

function main()
running = true
  while inMainMenu and running do
		term.clear()
		term.setCursorPos(1,1)
		printMenu(mainMenu)

		event, key = os.pullEvent("key")
		onKeyPressed(key, mainMenu)
  end
end

main()
else
  print("You need an advanced computer.")
end
oeed #2
Posted 28 February 2013 - 01:34 PM
Quick issue, I tried to open DarkChat, it crashed on line 503.

The line is the one with 'cB.write(CHAT.readAll()'
I think this may be due to the fact that 'CHAT' is not defined.


function dwChat()
  clear()
  print("Downloading DarkChat...")
  C = http.get("https://raw.github.com/darkrising/darkprograms/darkprograms/chat")
  if C then
    cB = fs.open("chat", "w")
    cB.write(CHAT.readAll())
    cB.close()
   print("Completed")
   print("Press any key to return")
   os.pullEvent("key")
  else
   print("Failed")
   print("Press any key to return")
   os.pullEvent("key")
  end
end
masterdisasterHD #3
Posted 28 February 2013 - 07:16 PM
Quick issue, I tried to open DarkChat, it crashed on line 503.

The line is the one with 'cB.write(CHAT.readAll()'
I think this may be due to the fact that 'CHAT' is not defined.


function dwChat()
  clear()
  print("Downloading DarkChat...")
  C = http.get("https://raw.github.com/darkrising/darkprograms/darkprograms/chat")
  if C then
    cB = fs.open("chat", "w")
    cB.write(CHAT.readAll())
    cB.close()
   print("Completed")
   print("Press any key to return")
   os.pullEvent("key")
  else
   print("Failed")
   print("Press any key to return")
   os.pullEvent("key")
  end
end

CHAT was not defined becuase i forgot to change CHAT to C.
Fixed.
masterdisasterHD #4
Posted 04 March 2013 - 11:28 AM
Update released!
v10 is now for public uses!
+Added auto updater!
*Bugfixes
superaxander #5
Posted 04 March 2013 - 07:44 PM
How is This hd?
theoriginalbit #6
Posted 05 March 2013 - 01:12 AM
How is This hd?
It says "HD's" as in its his. It's like me saying "BIT's Programs……"
superaxander #7
Posted 05 March 2013 - 01:16 AM
Oh I understand
masterdisasterHD #8
Posted 05 March 2013 - 03:43 AM
Yup
LeCanardNoir #9
Posted 05 March 2013 - 03:15 PM
Really cool stuff :lol:/> i will try this B)/>
LeCanardNoir #10
Posted 05 March 2013 - 03:22 PM
I confirm is very a nice stuff,…. thank DUDE :D/>
masterdisasterHD #11
Posted 06 March 2013 - 03:00 AM
I confirm is very a nice stuff,…. thank DUDE :D/>

You're welcome :D/>
masterdisasterHD #12
Posted 06 March 2013 - 08:11 AM
Beta version is now released.

+Added peripheral logging
+Menu cannot run without http api
*Bug fixes
masterdisasterHD #13
Posted 10 March 2013 - 10:44 PM
MenuAPI released!
Check my other topic for more info
masterdisasterHD #14
Posted 05 June 2013 - 05:09 PM
Mayor derpynes fixed
masterdisasterHD #15
Posted 08 June 2013 - 03:26 AM
The next version will be released with my new api so hang in there :P/>
MudkipTheEpic #16
Posted 08 June 2013 - 10:25 AM
The next version will be released with my new api so hang in there :P/>/>

Quintiple post, might wanna use edit. ;)/>