Jump to content




[1.3] Security Terminal

computer utility

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

#1 Kolpa

  • New Members
  • 260 posts
  • LocationGermany

Posted 23 March 2012 - 10:59 PM

So this is my Secure code Lock which instead of writing the password just writes "*"
Code:
Spoiler

Images:
Spoiler

u want pastebin?
Spoiler


#2 hamish1001

  • New Members
  • 75 posts
  • LocationAustralia

Posted 24 March 2012 - 01:41 AM

cool im putting this in my world

#3 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 24 March 2012 - 01:52 AM

@hamish1001:
At the current state of the program, it won't actually work, since the loop doesn't contain a break-condition, i.e. it will run indefinitely.
*derp* Kinda hard to match the end's with their counterparts sometimes with non-indented code. My bad. :(/>
But it will reboot in both cases (access denied/granted), so you'd at least have to replace the reboot on "access granted" with a break.

@Kolpa:
I hope you don't mind, just tried to compress the code a little to make it more efficient.
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

clear()
write("Kolpa s Privacy Terminal")
term.setCursorPos(2, 5)
write("Password: ")

while true do
  local pass = read("*")

  if pass == "test" then
	clear()
	write("acces granted")
	os.sleep(2)
	break;  -- Break out of loop.
  else
	clear()
	write("acces denied")
	os.sleep(2)
	os.reboot()
  end
end

Note: Didn't test it ingame, but should work. If it doesn't, give me a holler.
Cheers :)/>

Edited by Espen, 24 March 2012 - 01:59 AM.


#4 Zer0t3ch

  • Members
  • 33 posts
  • LocationIllinois, USA

Posted 24 March 2012 - 02:10 AM

View PostEspen, on 24 March 2012 - 01:52 AM, said:

@hamish1001:
At the current state of the program, it won't actually work, since the loop doesn't contain a break-condition, i.e. it will run indefinitely.
*derp* Kinda hard to match the end's with their counterparts sometimes with non-indented code. My bad. :(/>
But it will reboot in both cases (access denied/granted), so you'd at least have to replace the reboot on "access granted" with a break.

@Kolpa:
I hope you don't mind, just tried to compress the code a little to make it more efficient.
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

clear()
write("Kolpa s Privacy Terminal")
term.setCursorPos(2, 5)
write("Password: ")

while true do
  local pass = read("*")

  if pass == "test" then
	clear()
	write("acces granted")
	os.sleep(2)
	break;  -- Break out of loop.
  else
	clear()
	write("acces denied")
	os.sleep(2)
	os.reboot()
  end
end

Note: Didn't test it ingame, but should work. If it doesn't, give me a holler.
Cheers :)/>

You're edit looks nice. Has anyone figured out a way to make programs non-terminate-able? (not a word, I know) Without editing the actual OS?

#5 coolblockj

  • Members
  • 84 posts

Posted 24 March 2012 - 02:25 AM

View PostZer0t3ch, on 24 March 2012 - 02:10 AM, said:

View PostEspen, on 24 March 2012 - 01:52 AM, said:

@hamish1001:
At the current state of the program, it won't actually work, since the loop doesn't contain a break-condition, i.e. it will run indefinitely.
*derp* Kinda hard to match the end's with their counterparts sometimes with non-indented code. My bad. :(/>
But it will reboot in both cases (access denied/granted), so you'd at least have to replace the reboot on "access granted" with a break.

@Kolpa:
I hope you don't mind, just tried to compress the code a little to make it more efficient.
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

clear()
write("Kolpa s Privacy Terminal")
term.setCursorPos(2, 5)
write("Password: ")

while true do
  local pass = read("*")

  if pass == "test" then
	clear()
	write("acces granted")
	os.sleep(2)
	break;  -- Break out of loop.
  else
	clear()
	write("acces denied")
	os.sleep(2)
	os.reboot()
  end
end

Note: Didn't test it ingame, but should work. If it doesn't, give me a holler.
Cheers :)/>

You're edit looks nice. Has anyone figured out a way to make programs non-terminate-able? (not a word, I know) Without editing the actual OS?
You can set os.pullEvent to os.pullEventRaw, like this :
nos.pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
Yourcodehere
os.pullEvent = nos.pullEvent --Resets it back to normal after you're done.


#6 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 24 March 2012 - 02:26 AM

Whoops, got ninja'd. Just Ignore this now pointless post.^^

Edited by Espen, 24 March 2012 - 02:27 AM.


#7 Zer0t3ch

  • Members
  • 33 posts
  • LocationIllinois, USA

Posted 24 March 2012 - 02:31 AM

Cool! (BTW, your post is f'ed up)

#8 Zer0t3ch

  • Members
  • 33 posts
  • LocationIllinois, USA

Posted 24 March 2012 - 02:42 AM

View Postcoolblockj, on 24 March 2012 - 02:25 AM, said:

View PostZer0t3ch, on 24 March 2012 - 02:10 AM, said:

View PostEspen, on 24 March 2012 - 01:52 AM, said:

@hamish1001:
At the current state of the program, it won't actually work, since the loop doesn't contain a break-condition, i.e. it will run indefinitely.
*derp* Kinda hard to match the end's with their counterparts sometimes with non-indented code. My bad. :(/>
But it will reboot in both cases (access denied/granted), so you'd at least have to replace the reboot on "access granted" with a break.

@Kolpa:
I hope you don't mind, just tried to compress the code a little to make it more efficient.
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

clear()
write("Kolpa s Privacy Terminal")
term.setCursorPos(2, 5)
write("Password: ")

while true do
  local pass = read("*")

  if pass == "test" then
	clear()
	write("acces granted")
	os.sleep(2)
	break;  -- Break out of loop.
  else
	clear()
	write("acces denied")
	os.sleep(2)
	os.reboot()
  end
end

Note: Didn't test it ingame, but should work. If it doesn't, give me a holler.
Cheers :)/>

You're edit looks nice. Has anyone figured out a way to make programs non-terminate-able? (not a word, I know) Without editing the actual OS?
You can set os.pullEvent to os.pullEventRaw, like this :
nos.pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
Yourcodehere
os.pullEvent = nos.pullEvent --Resets it back to normal after you're done.
I tried out that code as you said it, exactly, it crashes and shuts down but I managed to print screen it.

http://www.zer0t3ch....03/Untitled.png


#9 coolblockj

  • Members
  • 84 posts

Posted 24 March 2012 - 04:18 AM

View PostZer0t3ch, on 24 March 2012 - 02:42 AM, said:

View Postcoolblockj, on 24 March 2012 - 02:25 AM, said:

View PostZer0t3ch, on 24 March 2012 - 02:10 AM, said:

View PostEspen, on 24 March 2012 - 01:52 AM, said:

@hamish1001:
At the current state of the program, it won't actually work, since the loop doesn't contain a break-condition, i.e. it will run indefinitely.
*derp* Kinda hard to match the end's with their counterparts sometimes with non-indented code. My bad. :(/>
But it will reboot in both cases (access denied/granted), so you'd at least have to replace the reboot on "access granted" with a break.

@Kolpa:
I hope you don't mind, just tried to compress the code a little to make it more efficient.
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

clear()
write("Kolpa s Privacy Terminal")
term.setCursorPos(2, 5)
write("Password: ")

while true do
  local pass = read("*")

  if pass == "test" then
	clear()
	write("acces granted")
	os.sleep(2)
	break;  -- Break out of loop.
  else
	clear()
	write("acces denied")
	os.sleep(2)
	os.reboot()
  end
end

Note: Didn't test it ingame, but should work. If it doesn't, give me a holler.
Cheers :)/>

You're edit looks nice. Has anyone figured out a way to make programs non-terminate-able? (not a word, I know) Without editing the actual OS?
You can set os.pullEvent to os.pullEventRaw, like this :
nos.pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
Yourcodehere
os.pullEvent = nos.pullEvent --Resets it back to normal after you're done.
I tried out that code as you said it, exactly, it crashes and shuts down but I managed to print screen it.

http://www.zer0t3ch....03/Untitled.png

Could you take a pic of the code, or put it down exactly on here?
This way i'll be able to help more accurately.
Also, are you using tekkit? I've heard there might be a few bugs in tekkit with it.

#10 Zer0t3ch

  • Members
  • 33 posts
  • LocationIllinois, USA

Posted 24 March 2012 - 04:44 AM

Yes I am using tekkit

while true do
pullEvent = os.pullEvent()
os.pullEvent = os.pullEventRaw()
os.pullEvent = pullEvent
end
After key press it instantly crashes, I have tried multiple variations, with and without parens, and this is what it is now. Any ideas?

#11 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 24 March 2012 - 11:58 AM

@Zer0t3ch
os.pullEvent returns the function itself, os.pullEvent() executes the function and returns the results of that.
Also the code to backup os.pullEvent is supposed to be executed at the very beginning and end of your program, outside of any other parts.
Like this:
local oldPullEvent = os.pullEvent  -- Creates a copy of the function pullEvent under the local variable oldPullEvent
os.pullEvent = pullEventRaw  -- Overwrite the global function os.pullEvent with os.pullEventRaw

-- From now on every call to os.pullEvent() is essentially the same as a call to os.pullEventRaw().
-- This effectively prevents program termination, because os.pullEventRaw does not stop the program when the 'terminate' event occurs.

-- After you are done with your program we restore the global function os.pullEvent again with the backup we made at the beginning.
os.pullEvent = oldPullEvent


#12 Kolpa

  • New Members
  • 260 posts
  • LocationGermany

Posted 24 March 2012 - 01:21 PM

View PostEspen, on 24 March 2012 - 01:52 AM, said:

@hamish1001:
At the current state of the program, it won't actually work, since the loop doesn't contain a break-condition, i.e. it will run indefinitely.
*derp* Kinda hard to match the end's with their counterparts sometimes with non-indented code. My bad. :(/>
But it will reboot in both cases (access denied/granted), so you'd at least have to replace the reboot on "access granted" with a break.

@Kolpa:
I hope you don't mind, just tried to compress the code a little to make it more efficient.
local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

clear()
write("Kolpa s Privacy Terminal")
term.setCursorPos(2, 5)
write("Password: ")

while true do
  local pass = read("*")

  if pass == "test" then
	clear()
	write("acces granted")
	os.sleep(2)
	break;  -- Break out of loop.
  else
	clear()
	write("acces denied")
	os.sleep(2)
	os.reboot()
  end
end

Note: Didn't test it ingame, but should work. If it doesn't, give me a holler.
Cheers :)/>

i actualy did the code with the reboot just to show off what u can do,
anyway thanks for the edit had to go and coudnt describe the post anymore will edit that

#13 coolblockj

  • Members
  • 84 posts

Posted 24 March 2012 - 08:33 PM

View PostEspen, on 24 March 2012 - 11:58 AM, said:

@Zer0t3ch
os.pullEvent returns the function itself, os.pullEvent() executes the function and returns the results of that.
Also the code to backup os.pullEvent is supposed to be executed at the very beginning and end of your program, outside of any other parts.
Like this:
local oldPullEvent = os.pullEvent  -- Creates a copy of the function pullEvent under the local variable oldPullEvent
os.pullEvent = pullEventRaw  -- Overwrite the global function os.pullEvent with os.pullEventRaw

-- From now on every call to os.pullEvent() is essentially the same as a call to os.pullEventRaw().
-- This effectively prevents program termination, because os.pullEventRaw does not stop the program when the 'terminate' event occurs.

-- After you are done with your program we restore the global function os.pullEvent again with the backup we made at the beginning.
os.pullEvent = oldPullEvent
You got to it first :(/>

#14 Robd

  • New Members
  • 32 posts

Posted 04 April 2012 - 01:23 AM

Hmm... I've done something very similar with some of my own consoles (only I don't use the stars). Might I suggest that you make an event for the backspace key so that you don't have to reboot if you mis-type a key?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users