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

Options in computer?

Started by ShadowZenoX, 08 June 2012 - 10:38 PM
ShadowZenoX #1
Posted 09 June 2012 - 12:38 AM
I want to be able to like press 1 to like activate redstone the i wanna activate on different sides and press 2 or 3 or 4 for more options to activate redstone so like
1 would activate the booster track on the right to launch it to my station on multiplayer then 2 would activate the one on the left then 3 would activate both does anyone know how to create this kind of stuff it would help alot
BigSHinyToys #2
Posted 09 June 2012 - 01:31 AM
this should do that and a hole lot more. the keys 1 to 6 control the sides of the computer. it will show you if a side is on or off.


[EDIT] removed some redundancy and unnecessary code this is ver 0.2
Spoiler

local sList = rs.getSides() -- this is a list of names "left" "right" ect...
local function draw()
term.clear()
term.setCursorPos(1,1)
for i = 1,6 do
  print(i.."| "..sList[i].." "..tostring(rs.getOutput(sList[i])).." input? "..tostring(rs.getInput(sList[i])))
end
end
for i = 1,6 do -- remove if you dont want all outputs set to off on program startup
rs.setOutput(sList[i],false) -- remove if you dont want all outputs set to off on program startup
end -- remove if you dont want all outputs set to off on program startup
draw()
while true do -- start a loop
e,e1,e2,e3,e4,e5 = os.pullEvent() -- wait here for an event then make e = to the event name eg "key" or "cahr" or "rednet_message"
if e == "char" then
  if e1 == "q" then error() end
  e1 = tonumber(e1) -- converts string to number (integra)
  if e1 <= 6 and e1 >= 1 then -- checks if the numver is between 1 and 6
   if rs.getOutput(sList[e1]) then -- checkes if it is already on
	rs.setOutput(sList[e1],false) -- turns it off if it was on
   else
	rs.setOutput(sList[e1],true) -- turns it on if it was off
   end
  end
  draw()
end
if e == "redstone" then
  draw()
end
end

[EDIT2]
spaced information better on screen and showing events on the bottom row

this is ver 0.3
Spoiler

local sList = rs.getSides() -- this is a list of names "left" "right" ect...
local function draw()
term.clear()
term.setCursorPos(1,1)
for i = 1,6 do
  term.setCursorPos(1,i)
  write(i.."| "..sList[i])
  term.setCursorPos(11,i)
  write(tostring(rs.getOutput(sList[i])))
  term.setCursorPos(16,i)
  print(" input: "..tostring(rs.getInput(sList[i])))
end
end
for i = 1,6 do -- remove if you dont want all outputs set to off on program startup
rs.setOutput(sList[i],false) -- remove if you dont want all outputs set to off on program startup
end -- remove if you dont want all outputs set to off on program startup
draw()
while true do -- start a loop
e,e1,e2,e3,e4,e5 = os.pullEvent() -- wait here for an event then make e = to the event name eg "key" or "cahr" or "rednet_message"
if e == "char" then
  if e1 == "q" then error() end
  e1 = tonumber(e1) -- converts string to number (integra)
  if e1 <= 6 and e1 >= 1 then -- checks if the numver is between 1 and 6
   if rs.getOutput(sList[e1]) then -- checkes if it is already on
	rs.setOutput(sList[e1],false) -- turns it off if it was on
   else
	rs.setOutput(sList[e1],true) -- turns it on if it was off
   end
  end
  draw()
end
if e == "redstone" then
  draw()
end
term.setCursorPos(1,7)
term.clearLine()
print(tostring(e).." "..tostring(e1).." "..tostring(e2).." "..tostring(e3).." "..tostring(e4).." "..tostring(e5))
end
[/EDIT2]
ShadowZenoX #3
Posted 09 June 2012 - 04:33 AM
How do you make it where u can set it for a certain time that the redstone is on then it turns off because im making a train stations and i dont want to turn it off manualy i want it to do that automaticly
BigSHinyToys #4
Posted 09 June 2012 - 04:43 AM
well this will do it it is possible for me to make this more complex but work better if you would like custom lables for eatch line i can do that as well.
tell you what think about how you would like the program to be (what features how you wantit to work ect) and i will make it as best i can

for now this should work.
Spoiler

--[[
  By Big Shiny Toys
  9 june 2012 ver 0.3
  NO right's reserved
  use as you see fit no credit required
]]--
local sList = rs.getSides() -- this is a list of names "left" "right" ect...
local function draw()
term.clear()
term.setCursorPos(1,1)
for i = 1,6 do
  term.setCursorPos(1,i)
  write(i.."| "..sList[i])
  term.setCursorPos(11,i)
  write(tostring(rs.getOutput(sList[i])))
  term.setCursorPos(16,i)
  print(" input: "..tostring(rs.getInput(sList[i])))
end
end
for i = 1,6 do -- remove if you dont want all outputs set to off on program startup
rs.setOutput(sList[i],false) -- remove if you dont want all outputs set to off on program startup
end -- remove if you dont want all outputs set to off on program startup
draw()
while true do -- start a loop
e,e1,e2,e3,e4,e5 = os.pullEvent() -- wait here for an event then make e = to the event name eg "key" or "cahr" or "rednet_message"
if e == "char" then
  if e1 == "q" then error() end
  e1 = tonumber(e1) -- converts string to number (integra)
  if e1 <= 6 and e1 >= 1 then -- checks if the numver is between 1 and 6
   rs.setOutput(sList[e1],true) -- turns it on if it was off
   sleep(0.5)
   rs.setOutput(sList[e1],false)
  end
end
draw()
term.setCursorPos(1,7)
term.clearLine()
print(tostring(e).." "..tostring(e1).." "..tostring(e2).." "..tostring(e3).." "..tostring(e4).." "..tostring(e5))
end

when you have a list of how you want the program just PM me and i will do what i can. I will be out most of the day so dont expect it quickly maybe a couple of days at most.