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

Broken Terminal Help

Started by Kron, 08 June 2013 - 01:42 PM
Kron #1
Posted 08 June 2013 - 03:42 PM
Hey guys, I'm making a tekkit map (1.2.5) for Minecraft. Its based off of the game Fallout 3.

I need broken terminals for ambient effect. I know how to get the foremost part down, but I need help with the text. I need to make it to where whenever you type something, it appears on the terminal as one of the following "!@#$%^/". However, I do not know how to do that. Can some one please lend me a hand? Thanks.

-Kron
LBPHacker #2
Posted 08 June 2013 - 03:54 PM
Typed "fallout terminal" into Search in the Programs forum.

EDIT: By the way, the community wouldn't be able to help you anyways due to the lack of information you gave us. Which part do you have problems with? How do you want store possible passwords? etc.
Kron #3
Posted 08 June 2013 - 04:09 PM
Typed "fallout terminal" into Search in the Programs forum.

EDIT: By the way, the community wouldn't be able to help you anyways due to the lack of information you gave us. Which part do you have problems with? How do you want store possible passwords? etc.

I need to make it to where whenever you type something, it appears on the terminal as one of the following "!@#$%^/". However, I do not know how to do that.

They're really for ambient effect. I just need it to randomly render your letters to one of the symbols displayed. I have the password cracking and all of that other good stuff down though. :D/>
Engineer #4
Posted 08 June 2013 - 04:32 PM
a simple converter would be:

local convert = function( str )
   local chars = "!@#$%^&amp;*()~{}[]:;'\"<>?/,./\\-+"
   local newString = ""
   for i = 1, str:len() do
      local randomChar = math.random( chars:len() )
      newString = newString .. chars:sub( randomChar, randomChar )
   end
   return newString
end

I like these kind of random functions :P/>

Edit: Look at this! Awesomeness! :D/>


I literally used this:

print(convert(read()))
Kron #5
Posted 08 June 2013 - 05:41 PM
a simple converter would be:

local convert = function( str )
   local chars = "!@#$%^&amp;*()~{}[]:;'\"<>?/,./\\-+"
   local newString = ""
   for i = 1, str:len() do
	  local randomChar = math.random( chars:len() )
	  newString = newString .. chars:sub( randomChar, randomChar )
   end
   return newString
end

I like these kind of random functions :P/>

Edit: Look at this! Awesomeness! :D/>


I literally used this:

print(convert(read()))

Wow, thanks!
H4X0RZ #6
Posted 08 June 2013 - 06:51 PM
a simple converter would be:

local convert = function( str )
   local chars = "!@#$%^&amp;*()~{}[]:;'\"<>?/,./\\-+"
   local newString = ""
   for i = 1, str:len() do
      local randomChar = math.random( chars:len() )
      newString = newString .. chars:sub( randomChar, randomChar )
   end
   return newString
end

I like these kind of random functions :P/>/>/>

Edit: Look at this! Awesomeness! :D/>/>/>


I literally used this:

print(convert(read()))
Under the "f" of fun is a smiley :o/>
Bomb Bloke #7
Posted 08 June 2013 - 09:52 PM
Couldn't help myself. I like random functions too.

Spoiler
local errors = {
"Operation complete",
"Function asdfdfwea has performed an illegal operation and will be shot",
"Error: Does not compute",
"Don't you talk about my mother like that! She was a saint!",
"Please dear, not in front of the children!",
"English, do you speak it?",
"This message will self destruct in ten seconds",
"Accessing databank for file 'meaning of life'... ... ... Error: <EOF>"}

local event,key,timer,blink,textX,textY = "",0,os.startTimer(0),false,0,0

local garbage = "!@#$%^/"

term.clear()
term.setCursorPos(1,1)
print("BrokenOS")
write("> ")

while true do
  while true do
    event,key = os.pullEventRaw()
    if event == "timer" and key == timer then   -- Flash the text cursor.
      write(blink and "_" or " ")
      blink = not blink
      textX,textY = term.getCursorPos()
      term.setCursorPos(textX-1,textY)
      timer = os.startTimer(0.5)
    elseif event == "key" then break end  -- User typed something, so exit the current while loop.
  end

  textX,textY = term.getCursorPos()

  if key == keys.enter then  -- Handle a line break.
    print(" ")
    if textX ~= 3 then
      if (math.random(10) < 10) then
        print("No such program")
      else
        print(errors[math.random(#errors)])
      end    
    end
    write("> ")
  elseif key == keys.backspace then
    if textX > 3 then
      write(" ")
      term.setCursorPos(textX-1,textY)
    end
  else  -- User typed anything else.
    key = math.random(garbage:len())
    write(garbage:sub(key,key))
  end
end