Discord
Login
Community
DARK THEME

Print() ... clear console command?

Exploring @this_name_is_taken's Raycaster I print a lot of values to the console.

The helper function I use:

// for debugging, print value on key press
printVar = function(value,key="SPACE")
  if keyboard.press[key] then print(value) end
end

and that's how it is called in the main program:

update = function()
  move()
  printVar("camdir = "+camdir)
  printVar("camx   = "+camx)
  printVar("camy   = "+camy)
  printVar("dir    = "+dir,"1")
  printVar("rayx   = "+rayx,"1")
  printVar("rayy   = "+rayy,"1")  
end

So pressing [SPACE] I get one set of values, by pressing [1] the other. I added the key function to avoid 'console flooding' ... haven't we all been there ;) ... hehe

Works like a charm, why shouldn't it.

camdir = 0
camx = 90
camy = 90
dir = 51.34019174590991
rayx = 0.7808688094430303
rayy = 0.6246950475544243

Now my question, is there a way to clear the console from the print command?
Some special print command or system function?
Not really important, just laziness from my side to manually push the clear button every time it gets too crowded.

For sure I would settle for a configurable variable watch window with single step option as an alternative, MUAHAHA ;)

clearConsole = function()
  local i = 0
  while i < 1000
    print("")
    i += 1
  end
end

This might lag a bit, but I hope it helps. (It's a while loop because I didn't know how to do for loops at the time of writing the code in the first place). It works because the console can only have so many printed messages, and blanks count as such for some reason even though they don't show or contribute to scrolling.

Edit: I did some testing and there are exactly 1000 places in the console.

@smith_of_tinkering_and_awesome_naming_skills - That's a great idea! I've been looking for some way to bug fix my projects for a while, and this will make it a lot easier. I'm going to snatch that bug fixing code :)

@Abr00 - Nice solution! I never would have thought of that way to do it!

Ingenious.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community