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

help with frame motor door code

Started by trevor1097, 15 December 2012 - 09:56 AM
trevor1097 #1
Posted 15 December 2012 - 10:56 AM
i have a code for my door but the redpulse doesnt work and how would i add a debug key to my code



local function getUserInput()
  term.clear()
  term.setCursorPos(1,1)
  term.write("Password: ")
  local input = read("*")
  if input == "welcome" then
	    shell.run("redpulse","left","2",".75")
	    print("Enter the gates")
	    sleep(3)
	    shell.run("redpulse","right","2",".75")
  elseif input == "edit" then
	    print ("editing")
	    sleep(2)
  else
	    print("Wrong password")
	    sleep(5)
  end
  return true
end
local function getRedstoneInput()
  os.pullEvent("redstone")
  if rs.getInput("top") == true then
	    print("Opening door from redstone")
	    shell.run("redpulse","left","2",".75")
	    print ("Enter the gates")
	    sleep(3)
	    shell.run("redpulse","right","2",".75")
  end
  return true
end
while true do
  parallel.waitForAny(getUserInput, getRedstoneInput)
end
theoriginalbit #2
Posted 15 December 2012 - 01:54 PM
i have a code for my door but the redpulse doesnt work and how would i add a debug key to my code
 local function getUserInput() term.clear() term.setCursorPos(1,1) term.write("Password: ") local input = read("*") if input == "welcome" then shell.run("redpulse","left","2",".75") print("Enter the gates") sleep(3) shell.run("redpulse","right","2",".75") elseif input == "edit" then print ("editing") sleep(2) else print("Wrong password") sleep(5) end return true end local function getRedstoneInput() os.pullEvent("redstone") if rs.getInput("top") == true then print("Opening door from redstone") shell.run("redpulse","left","2",".75") print ("Enter the gates") sleep(3) shell.run("redpulse","right","2",".75") end return true end while true do parallel.waitForAny(getUserInput, getRedstoneInput) end 

try putting a function in your code like this


function pulseRedstone(side)
  rs.setOutput(side, true)
  sleep(2)
  rs.setOutput(side, false)
end

that replaces the shell.run to repulse. also if that doesn't work, is the frame motor powered?


secondly to wait for a key make this modification


debugKey = keys.p --[[ this is for CC1.4
if using CC1.3 use the number from here in its place
http://www.minecraftwiki.net/wiki/Key_codes
]]

local function getRedstoneInput()
  event, param = os.pullEventRaw()
  if event == "redstone" then
    if rs.getInput("top") then
	  -- do your redstone stuff
    end
  elseif event == "key" and param == debugKey then
    error() -- quits the program :)/>
  end
end
trevor1097 #3
Posted 21 December 2012 - 09:10 AM
It it mot a key on the keyboard it is a seprate password
Doyle3694 #4
Posted 21 December 2012 - 12:02 PM
put a button on the computer suing shift + rightclick and then rightclick the button itself. is the frames moving?