Code Monkey home page Code Monkey logo

love-console's Introduction

love-console

Features

  • Activate and deactivate the console with the ~ key.
  • Use the left and right arrows to navigate the cursor.
    • alt-left and alt-right navigate by word.
    • ctrl-left and ctrl-right navigate to the end of the line.
  • Evaluate both expressions and statements.
  • Use the up and down arrow keys to access history.
  • Use _ to access the last returned value, and last to access all of the last returned values as a table.
  • Use ctrl+ and ctrl- to change font size.
  • Type clear to clear the console.
    • Add custom commands to console.COMMANDS.
  • Use console.ENV to expose objects to the REPL.

Integrating the Console

local console = require "console"
love.keyboard.setKeyRepeat(true) -- Not required.

function love.keypressed(key, scancode, isrepeat)
  console.keypressed(key, scancode, isrepeat)
end

function love.textinput(text)
  console.textinput(text)
end

function love.draw()
  console.draw()
end

-- This function is run when the user types "save" into the console.
console.COMMANDS.save = function()
  -- Example: save game state
end

-- This table is available as "player" in the console scope.
console.ENV.player = {x = 100, y = 5}

love-console's People

Contributors

akkartik avatar rameshvarun avatar

Stargazers

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

Watchers

 avatar

love-console's Issues

~ key

At console.lua, at line 275 change this (~):

function console.textinput(input)
  -- Use the "~" key to enable / disable the console.
  if input == "~" then
    enabled = not enabled
    return
  end

to this (`):

function console.textinput(input)
  -- Use the "~" key to enable / disable the console.
  if input == "`" then
    enabled = not enabled
    return
  end

built in print() command returns nil

Whenever you can print() in the command line; it adds an additional 'nil' line at the end.
I assume this is a bug because it doesn't happen to any user implemented commands.

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.