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

Need a reporting log

Started by XxSovietxX, 07 August 2012 - 04:19 PM
XxSovietxX #1
Posted 07 August 2012 - 06:19 PM
I need a program that will allow a user to input data (It will ask for the player's account name, the problem causer's account name, and the problem caused) , then, when the sequence "admin" "admin" "admin" is entered for all 3 questions, print out a list (With a 3 second delay between the next print) that displays:

(Player account name) is reporting (Problem Causer's name) for (Problem Caused).

It would also need to delete the logs if the sequence "admindelete" "admindelete" "admindelete" is entered.
OmegaVest #2
Posted 07 August 2012 - 06:26 PM
That's not really what this part of the forum is for. We are here to help you fix code, not to give whole programs away. And, have you searched the program section for a code that would work?

Otherwise, try it out for yourself. Learning Lua is not really all that hard, and if you stumble, we'll be here to help.



(If you just want the program, go ask about it in the general tab. Most of us enjoy a challenge, even a little one)





EDIT: How to make an Ask the Pros thread.
ardera #3
Posted 07 August 2012 - 06:29 PM
code:

log={}
function printOutLog()
  for n=1, #log do
	print(log[n][1].." is reporting "..log[n][2].." for "..log[n][3])
	sleep(3)
  end
end  
function loop()
  term.clear()
  term.setCursorPos(1, 1)
  print("Your Account Name: ")
  local an=read()
  print("The Problem Causers Name:")
  local cn=read()
  print("The Problem Caused:")
  local pc=read()
  if an=="admin" and cn=="admin" and pc=="admin" then
	printOutLog()
  elseif an=="admindelete" and cn=="admindelete" and pc=="admindelete" then
	log={}
  else
	log[#log+1]={an, cn, pc}
  end
end
while true do
	loop()
end

EDIT:
@OmegaVest: I enjoyed it ;)/>/>

PS.: @OmegaVest: The program was already finished, so i posted it anyway. Sorry if that was not ok.
cant_delete_account #4
Posted 07 August 2012 - 08:29 PM
code:

log={}
function printOutLog()
  for n=1, #log do
	print(log[n][1].." is reporting "..log[n][2].." for "..log[n][3])
	sleep(3)
  end
end  
function loop()
  term.clear()
  term.setCursorPos(1, 1)
  print("Your Account Name: ")
  local an=read()
  print("The Problem Causers Name:")
  local cn=read()
  print("The Problem Caused:")
  local pc=read()
  if an=="admin" and cn=="admin" and pc=="admin" then
	printOutLog()
  elseif an=="admindelete" and cn=="admindelete" and pc=="admindelete" then
	log={}
  else
	log[#log+1]={an, cn, pc}
  end
end
while true do
	loop()
end

EDIT:
@OmegaVest: I enjoyed it ;)/>/>

PS.: @OmegaVest: The program was already finished, so i posted it anyway. Sorry if that was not ok.
But wouldn't that reset the log when the computer restarts?
OmegaVest #5
Posted 07 August 2012 - 10:05 PM
@ardera Eh, I just don't want the Ask the Pros section becoming a madhouse of "PROGRAM PLEASE!"

And, yes that would reset the log. It will need an fs interface.


placard = fs.open("logs/log", "w")

for i = 1, #log do
   placard.writeLine(log[i])
end
placard.close()



Should work. I would suggest placing it in an if statement so you could dump it when the admin types adminsave three times. Or, admin save () just to mess with 'em.
XxSovietxX #6
Posted 08 August 2012 - 02:26 PM
It doesnt say that the program doesnt exist, but it just never shows up.