Giter Site home page Giter Site logo

love-repl's Introduction

Magic-free in-game REPL for the Love game engine. Released under the Boost 1.0 license. (Credit is not required but would be appreciated)

I say magic free because it does not override any Love functions, but it does require you to add hooks into your code in order to work.

See main.lua for an example. The background used in the demo is from David Brown on flickr, used under the Creative Commons license.

console closed console open

Use

  • Enter: Evaluate line
  • Left/Right: Move cursor in line
  • Backspace: Delete letter behind cursor
  • Delete: Delete letter at cursor
  • Ctrl-A: Beginning of line
  • Ctrl-E: End of line
  • Escape: Clear current line
  • Up/Down: Navigate through history for a line to edit
  • Mouse wheel: Scroll through history
  • Home: Scroll to top
  • End: Scroll to bottom
  • Page up: Scroll up a page
  • Page down: Scroll down a page
  • F8: Default toggle key

Functions

repl.initialize()

Should be called during love.load() to initialize the module, but after specifying any settings (such as max lines), and after setting Love's graphical mode.

repl.toggle()

Toggle the REPL.

repl.toggled() : boolean

Returns true if the REPL has been toggled.

repl.eval(text : string, add_to_history : boolean) : boolean

Enter and evaluate TEXT at the REPL. Normally triggered by a user entering text, but can be called directly from code if desired. If ADD_TO_HISTORY is true, the line will be added to the user-navigable history if it is successfully evaluated. Returns true if evaluation was successful, false if not.

repl.print(value)

Print value to the REPL. Great for debug messages. REPL does not need to be open for this to work.

repl.keypressed(k, isrepeat)
repl.mousepressed(x, y, button)
repl.textinput(t)

Use these functions to pass input through to the REPL.

repl.draw()

Render the REPL.

Variables

repl.font : Font

The font to use when rendering. Vera Sans 12pt by default. Requires a monospace font, or multi-line rendering might get messed up.

repl.screenshot = true

If true, take a screenshot when toggled and set repl.background to a darkened version of it.

repl.dark_factor = 0.6

The amount by which the background will be darkened, lower is darker. Should be between 0 and 1.

repl.background : Drawable

Image to use as REPL background. If neither this or screenshot is set, love-repl will clear to black.

repl.max_lines = 1000

The maximum number of lines to keep. Must be set before initialize() is called. Includes both user-entered and program generated lines.

repl.max_history = 1000

The maximum number of history lines to keep. Must be set before initialize() is called.

repl.toggle_key = "f8"

The Love KeyConstant that will cause the REPL to close itself.

repl.clear_key = "escape"

The Love KeyConstant that will clear the current line.

repl.on_close : function

A hook that will be called when the REPL is closed.

repl.wrapping = false

Enable word wrapping via love.graphics.printf. Note that it is necessary to use a monospaced font with word wrapping.

Issues

  • No word wrapping

love-repl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.