Jump to content




Displaying user input on a monitor.


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

#41 JokerRH

  • Members
  • 147 posts

Posted 07 March 2013 - 10:31 AM

View Postboudragon, on 07 March 2013 - 10:18 AM, said:

How would that be solved if possible?

function set(ind)
  if type(term[ind]) ~= "function" then return end

  term[ind] = setmetatable({term = term[ind], monitor = m[ind]}, {
		__call = function(self, ...)
		  self.term(...)
		  self.monitor(...)
		end
  })
end
This additional line will detect if term[ind] is a function. If it is already modified it is a table and will not be set twice

#42 boudragon

  • Members
  • 107 posts

Posted 07 March 2013 - 11:04 AM

Absolutely amazing thank you! JokerRH super kudos for sticking with me through all this! Once I get in contact with my server admin to enable the ability to use pastebin I will upload some stuff for you to check out! I have learned quite a bit! Thanx again!

#43 boudragon

  • Members
  • 107 posts

Posted 07 March 2013 - 02:31 PM

Ok... so... pastebin isn't working and the server admin wont be on for a while so... looks like I get to type all this out! well... here it goes!

This is the startup file. Make sure you have a monitor attached to the top. It's made for a 4 long by 2 tall monitor. You can change this in the code. NOTE: In order for this to work you MUST have a memcheck file on a disk and placed in a drive attached to the system before running (memcheck needs to have the number 640 in the first line). Also, there must be a lock file (you can use any password protection lock you want as long as the file is named "lock") and a btsm file with the first line of text saying "--BTSM Header". Let me know what you think! And if you'd like the other files to get the full effect just tell me and I will get to work on re-writing the code.

mon = peripheral.wrap("top")
momc = "disk/memcheck"
memcf = fs.exists(memc) and io.open(memc, "r") or nil
btsmc = "btsm"
btsmcf = fs.exists(btsmc) and io.open(btsmc, "r") or nil
--THANK YOU to JokerRH for this next part!
function set(ind)
   if type(term[ind]) ~= "function" then return end
   term[ind] = setmetatable({term = term[ind], monitor = mon[ind]}, {
		 __call = function(self, ...)
				 self.term(...)
				 self.monitor(...)
		 end
   })
end
set("write")
set("setCursorPos")
set("print")
set("setCursorBlink")
set("clear")
set("clearLine")
set("scroll")
term.setCursorPos(term.getCursorPos())
term.clear()
term.setCursorPos(1,1)
os.pullEvent = os.pullEventRaw
print"|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|"
print"|		 BouTech Corporation		 |"
print"|-------------------------------------|"
print""
print"BTC OS version 1.2"
sleep(2)
term.setCursorPos(1,6)
print "Memory Check"
sleep(1)
term.setCursorPos(13,6)
print"."
sleep(1)
term.setCursorPos(14,6)
sleep(1)
print"."
term.setCursorPos(15,6)
print"."
sleep(1)
if (memcf and memcf:read()=="640") then
   term.setCursorPos(17,6)
   print"640Kb OK!"
   sleep(2)
   if (btsmcf and btsmcf:read()=="--BTSM Header") then
		  term.setCursorPos(1,8)
		  print"::WARNING::"
		  sleep(1)
		  print"Authorized access only!"
		  sleep(1)
		  print"CyberPunk Security now loading..."
		  sleep(3)
		  cpsc = fs.exists("lock")
		  if cpsc == true then
				 shell.run("lock")
		  else
				 term.setCursorPos(1,11)
				 print"System corrupt!  Running system restore..."
				 sleep(3)
				 file = fs.exists("disk/restore/sysrest")
				 if file == true then
						shell.run("disk/restore/sysrest")
				 else
						print"System restore file not found on disk."
						print"System rebooting..."
						sleep(3)
						os.reboot()
				 end
		  end
   else
		  term.setCursorPos(1,8)
		  print"System corrupt!  Running system restore..."
		  sleep(3)
		  file = fs.exists("disk/restore/sysrest")
		  if file == true then
				 shell.run("disk/restore/sysrest")
		  else
				 print"System restore file not found on disk."
				 print"System rebooting..."
				 sleep(3)
				 os.reboot()
		  end
   end
else
   term.setCursorPos(17,6)
   print"Memory Test Failed!"
   sleep(2)
   os.reboot()
end

WARNING - Just in case it was missed... you CAN NOT terminate this once it has begun! If you want to re-add the terminate function just remove line 26 of the code.

::EDIT::
I know the spacing for the BouTech Corp. sign looks off but it should be correct... for some reason adding code on the forums altered the spacing...

#44 JokerRH

  • Members
  • 147 posts

Posted 07 March 2013 - 10:07 PM

Looks cool! just 3 things I noticed while I was reading your code:
#1 You don't need a set("print"), print is a function that uses write
#2 insetead of
cpsc = fs.exists("lock")
if cpsc == true then
you can simply write
if fs.exists("lock") then
and #3: If your system is corrupted and you don't have a disk with your restore files it will run forever and always notice that are files missing.

But none of these 3 points will make your programm instable. Nice!

#45 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 07 March 2013 - 10:15 PM

I would probably use a variable just because it helps me remember what I was checking for in terms of files, But that is just my preference

EDIT: Better yet, I would use a comment :P

#46 boudragon

  • Members
  • 107 posts

Posted 08 March 2013 - 02:06 AM

Thanx Joker :) I will clean it up a bit! I have it run forever on purpose... cause either way if the system is corrupt its going to need a system restore. If you dont have the sysrest file you can always just break the terminal then copy the backup files back onto it. And Suicidal... yeah I could use comments to help me remember but generally when it comes to ANYTHING computer related I usually do good on the remembering department! LOL





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users