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

Any1 up for making a program

Started by sicet7, 12 June 2012 - 08:34 PM
sicet7 #1
Posted 12 June 2012 - 10:34 PM
i have a room on a multiplayer server that makes biomass and harvests all my suger canes. i have conected all the engien's both biomass engien's and redstone one's with a diffrend collored cable leading from a bundled cable. i want it so you startup the computer my lock system pop,s up (i'll put that in my self) you login and then it open's menu program it should have following options

–fermenter
–sugercane farms
–pumps
–biomass pump
–fermentor pump
–wheat farm

so when ever you chose a option it will pop up with another menu where it's tell's you to choose either "on" or "off" and when you choose one it will save that to it will out put redstone even if you reboot it (dont know if that possiple but it would be nice)
so if you are up for the challenge just post it.
the reason im asking you pro coders is that i have been trying to get it remembering the option and makeing the program myself and i have meet my limit the only thing i have a sligt idea of how to make is a lock system and the is cuz MysticT told me how. but if any1 takes on the challege then i thank you

ps. sry for bad english

this is my lock system

--[[Prevent Termination]]
local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
--[[Setup usernames and passwords]]
local tUsers = {
["user1"] = "pass1",
["user2"] = "pass2",
["user3"] = "pass3",
["user4"] = "pass4",
["user5"] = "pass5",
["user6"] = "pass6"
}
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end
--[[Infinite loop]]
while true do
clear()
--[[Ask for username]]
write("Username: ")
local usr = read()
--[[Check username]]
if tUsers[usr] ~= nil then
--[[Ask for password]]
write("Password: ")
local pass = read("*")
--[[Check password]]
if pass == tUsers[usr] then
print("Entering menu")
shell.run(your program name)
--[[Function here]]
--[[Else Function]]
else
print("Wrong password")
sleep(2)
end
else
print("The Entered Username Dosen't exist: ", usr)
sleep(2)
end
end
os.pullEvent = oldPullEvent
libraryaddict #2
Posted 15 June 2012 - 09:09 AM
Spoiler

--Some guys menu system
Side = "back"
Option = {}
Options = {}
Optiono = {}
--Defining functions!
function bundle(sSide, sColour, sValue) -- Manages the bundled cables
  local nColour = colors[sColour] or colours[sColour]
  if type(nColour) ~= "number" then
    error( "No such color" )
    return
  end
  if sValue == true then
    rs.setBundledOutput( sSide, colors.combine( rs.getBundledOutput( sSide ), nColour ) )
  elseif sValue == false then
    rs.setBundledOutput( sSide, colors.subtract( rs.getBundledOutput( sSide ), nColour ) )
  end
end

function Clear()
  term.setCursorPos(1,1)
  term.clear()
end

function fillLine(style) -- Fills the line with stuff like "======="
  local style = style
  if not style then
    style = "="
  end
  local cy,my = term.getCursorPos()
  local w,h = term.getSize()
  term.setCursorPos(1, my)
  for n=1,w-1 do
    term.write(style)
  end
  print()
end

function layout(mess, style) -- Centers text and does your style down the side. so |    hi!   |
  local style = style
  local mess = mess
  if not style then
    style = "|"
  end
  if not mess then
    mess = ""
  end
  local w,h = term.getSize()
  local middle = (w - mess:len())/2
  local cy,my = term.getCursorPos()
  middle = middle-1
  term.setCursorPos(1, my)
  write(style)
  term.setCursorPos(middle, my)
  write(mess)
  term.setCursorPos(w-1, my)
  print(style)
end

function writeFile()
  Pig = io.open("BundledState", "w")
  for n=1,#Option do
    Pig:write(Option[n]..":"..Options[n]..":"..Optiono[n].."n")
  end
  Pig:close()
end

function doBundled()
  for n=1,#Option do
    local Bam = true
    if Options[n] == "disabled" then
	  Bam = false
    end
    bundle(Side, Optiono[n], Bam)
  end
end

function readFile()
  Pig = io.open("BundledState", "r")
  for line in Pig:lines() do
    local First = string.find(line, ":")
    local Second = string.find(line, ":", First+1)
    Option[#Option+1] = string.sub(line, 1, First-1)
    Options[#Options+1] = string.sub(line, First+1, Second-1)
    Optiono[#Optiono+1] = string.sub(line, Second+1)
  end
  Pig:close()
  doBundled()
end

function nextMenu(option) -- Second menu
  Clear()
  fillLine()
  layout(option.." control panel")
  fillLine()
  layout()
  layout("Status of "..Option[option]..": "..Options[option])
  layout("Press E to toggle state")
  layout()  
  layout("Press B to go back")
  layout()
  fillLine()
  while true do
    local event,param1,param2 = os.pullEvent()
    if event == "char" and param1 == "b" then
	  MainMenu()
	  break
    elseif event == "char" and param1 == "e" then
	  if Options[option] == "disabled" then
	    Options[option] = "enabled"
	    writeFile()
	    doBundled()
	    nextMenu(option)
	    break
	  else
	    Options[option] = "disabled"
	    writeFile()
	    doBundled()
	    nextMenu(option)
	    break
	  end
    end
  end
end

function MainMenu()
  Clear()
  fillLine()
  layout("Main Control Panel")
  fillLine()
  layout()
  for n=1,#Option do
    layout(n..". "..Option[n])
  end
  layout()
  fillLine()
  while true do
    event,param1,param2 = os.pullEvent()
    if event == "key" then
	  if Option[(param1-1)] then
	    nextMenu((param1-1))
	    break
	  end
    end
  end
end

--Making the file incase its not made!
if not fs.exists("BundledState") then
  Clear()
  local function Check()
    if Name == "quit" or Color == "quit" then
	  return true
    else
	  return false
    end
  end
  print("Please keep typing in names of stuff you are controlling")
  print("Then type in the color you use. eg. blue")
  print("To quit at any time just type "quit" instead")
  while true do
    write("Name: ")
    Name = read()
    if Check() then
	  break
    end
    write("Color: ")
    Color = string.lower(read())
    if Check() then
	  break
    end
    Pig = io.open("BundledState", "a")
    Pig:write(Name..":disabled:"..Color.."n")
    Pig:close()
  end
end
doBundled()
<INSERT LOCK CODE>
readFile()
MainMenu()




http://www.computercraft.info/forums2/index.php?/topic/1505-computerlock-multiple-users-supported/
Try install that ^^
Exerro #3
Posted 25 June 2012 - 01:29 PM
I think I can help….do you only need standard mc to join the server though