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

"Activity Log" --Help needed

Started by AwesomeKinnect, 03 March 2014 - 11:35 PM
AwesomeKinnect #1
Posted 04 March 2014 - 12:35 AM
I have worked continuously on a program that I'm making, but I've run into an issue.

I know that it's probably a stupid question;however, I want to make the program save and then display text a certain amount of times (based on how many times I've clicked a button) and then display it in an "Activity Log" type thing. I've already gotten a working screen that displays text x amount of times based on variable going ,but whenever I return to the home of the program (To clear up any confusion, it is in the same program. This is not the entire program due to how messy and large the full one is), it clears the log. Is there a way to keep it so it can display the exact thing, or more, later? (I'll show how I've gotten it to print text based on how many times it's been clicked below)


function displayLog()
term.setCursorPos(1,3)
term.setBackgroundColor(colors.gray)
term.setTextColor(colors.black)
if logUpArrow > 0 then

  while  logUpArrow > 0 do
  print("turtle.forward()")
  logUpArrow = logUpArrow - 1
  end
end
end



Variables,(I have defined them!):

logUpArrow = 0
--Nothing else necessary for this that I have

And here is my code for counting how many times I've clicked to do the above(NOTE: There are Ends but I didn't put them because they are found much, MUCH later):


function osScreen()
drawDesktop()
while logOpen == false do
local event, button, X, Y = os.pullEventRaw()
	if event == "mouse_click" then
	  if X >=2 and X <=8 and Y==1 and button ==1 then
	  drawMenu1()
	  slc = 1
		else
		drawDesktop()
  if X >= 21 and X <= 29 and Y >= 2 and Y <= 6 and button ==1 then
   logUpArrow = logUpArrow + 1

   bground = paintutils.loadImage("upArrowClick.nfp")
   paintutils.drawImage(bground,1,1)
   term.setCursorPos(32,2)
   term.setBackgroundColor(colors.green)
   print("turtle.forward()")
   sleep(1)
   bground = paintutils.loadImage("arrows.nfp")
   paintutils.drawImage(bground,1,1)

So does anyone have any suggestions as to what I could do to write text to a log x amount of times, but not get deleted from log every time I return to the home screen of my program?
Edited on 04 March 2014 - 05:37 PM
CometWolf #2
Posted 04 March 2014 - 01:47 AM
This home screen you keep talking about, is it a seperate program altogether? Otherwise the issue is probably just how you initially define logUpArrow, meaning we'd have to see the whole program to really help you much further.
AwesomeKinnect #3
Posted 04 March 2014 - 11:21 AM
This home screen you keep talking about, is it a seperate program altogether? Otherwise the issue is probably just how you initially define logUpArrow, meaning we'd have to see the whole program to really help you much further.

I'm sorry to not have included the whole program, it's a bit messy, but I'm completely sure it's defined correctly (I use it in many other instances) and the home screen is the same program.
CometWolf #4
Posted 04 March 2014 - 04:35 PM
facepalm! I shoulda seen this earlier…

  while  logUpArrow > 0 do
  print("turtle.forward()")
  logUpArrow = logUpArrow - 1
  end
This piece of code essentially sets it back to 0.
Use a for loop instead

  for i=1,logUpArrow do
  print("turtle.forward()")
  end
AwesomeKinnect #5
Posted 05 March 2014 - 12:14 AM
facepalm! I shoulda seen this earlier…

  while  logUpArrow > 0 do
  print("turtle.forward()")
  logUpArrow = logUpArrow - 1
  end
This piece of code essentially sets it back to 0.
Use a for loop instead

  for i=1,logUpArrow do
  print("turtle.forward()")
  end

Thanks! I can't believe how easy a fix it was…I was so stupid…