Skip to content

[TESTING] New feature: print() outputs text on screen - FEEDBACK WANTED #7

@lee2sman

Description

@lee2sman

This is a test of adding a new feature to L5. Feedback wanted.

PROBLEM.
This is an idea that grows out of a discussion with @JessicaGarson. Basically, currently the easiest method to get started working with L5 for users that don't use the command line is to drag their project folder on top of the Love2d icon. But unfortunately, that doesn't display print() output.

SOLUTION
I modified L5, adding basically an override of print so that it displays the output of print on screen. Inspired by the way that the Pico-8 print works, though that is different in that there is no text() function separate from print.

This is somewhat more complicated in that one could have print() inside draw(), and so I set it to display only the last N print statements and scroll down. For example, see my test code at the bottom.

By default, you won't see the print output on screen, so as to have feature parity with Processing-p5. But to turn it on, just add showPrint() to your setup or draw.

To try this out, you must download and run L5.lua from the print-in-window test branch!

Describe alternatives you've considered
I considered whether this should be on by default, which would be more beginner-friendly, but then requiring everyone to add something like showPrint(false) might be a step too much for those coming from other Processing-p5's, right?

Additional context

Example code:

require("L5")

function setup()
  size(400, 400)

  -- Set the program title
  windowTitle("Basic sketch")

  describe('Draws a yellow background')
  showPrint()
end

function draw()
  -- Fills the background with the color yellow
  background(255, 215, 0)
  print(frameCount)
end

Here's what that looks like at the moment i screenshot (which was at frameCount number 672.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions