Jump to content




Unable to end a program


  • You cannot reply to this topic
6 replies to this topic

#1 axel.codeFail()

  • Members
  • 47 posts
  • LocationA bit lost

Posted 17 December 2013 - 10:10 PM

I made a program to lock my door with a password, just like alot of other people, and I put "os.pullEvent = os.pullEventRaw" at the top, but forgot to add a modifier to it. And in turn, the program won't end. Is there any way to end it, or is it forever running?


local pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
localside = "back"
local password = "14363"
local opentime = 5
while true do
  term.clear()
  term.setCursorPos(1,1)
  write("Password:")
  local input = read("*")
  if input == password then
	term.clear()
	term.setCursorPos(1,1)
	print("Access Granted")
	rs.setOutput(side,true)
	sleep(opentime)
  else
	print("Access Denied")
	sleep(30)
  end
end


#2 Wojbie

  • Members
  • 631 posts
  • LocationKinda lost

Posted 18 December 2013 - 06:53 AM

He can make a floppy disk with a empty startup file on it. Then after placing said floppy in disk drive next to computer restart computer. It will load up startup from floppy first (empty so nothing will happen) then go to standard shell where he can edit program.

Edited by Lyqyd, 18 December 2013 - 10:21 AM.


#3 axel.codeFail()

  • Members
  • 47 posts
  • LocationA bit lost

Posted 18 December 2013 - 09:48 PM

Oh, it's that simple? Cool, thanks.

#4 Alice

  • Members
  • 429 posts
  • LocationBehind you.

Posted 18 December 2013 - 11:43 PM

Here's a nice fix to your code
local pullEvent = os.pullEventRaw
local side = "back"
local password = "14363"
local opentime = 5
while true do
  term.clear()
  term.setCursorPos(1,1)
  print("Password:")
  if read("*") == password then
        term.clear()
        term.setCursorPos(1,1)
        print("Access Granted")
        rs.setOutput(side,true)
        sleep(opentime)
        rs.setOutput(side,false)
  else
        print("Access Denied")
        sleep(3) --Don't do it TOO long: P
  end
end


#5 jay5476

  • Members
  • 289 posts

Posted 19 December 2013 - 02:56 AM

View PostDeath, on 18 December 2013 - 11:43 PM, said:

Here's a nice fix to your code
local pullEvent = os.pullEventRaw
Nope, can still be Ctrl+T'ed :P. Just a silly mistake is all replace
pullEvent = os.pullventRaw
with
os.pullEvent = os.pullEventRaw

Heat must be getting to everyone

View Posttheoriginalbit, on 19 December 2013 - 02:18 AM, said:

View Postjay5476, on 19 December 2013 - 01:08 AM, said:

Cuz this works in lua :P, looks like you were having a bad day...
whoops. yeh, the heat is getting to me, its sending me crazy *eye twitches*, its currently 44ºC (111ºF) inside my house...

Edit: Air conditioner is at other end of the house :/

Edited by jay5476, 19 December 2013 - 02:57 AM.


#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 December 2013 - 04:41 AM

View Postjay5476, on 19 December 2013 - 02:56 AM, said:

View PostDeath, on 18 December 2013 - 11:43 PM, said:

Here's a nice fix to your code
local pullEvent = os.pullEventRaw
Nope, can still be Ctrl+T'ed :P. Just a silly mistake is all replace
pullEvent = os.pullventRaw
with
os.pullEvent = os.pullEventRaw
It'd actually error. you can't localise something that's being declared in a table

#7 Alice

  • Members
  • 429 posts
  • LocationBehind you.

Posted 19 December 2013 - 07:40 AM

I keep forgetting you can't do that. The other parts of the code were good, right?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users