{"id":19001687,"url":"https://github.com/itzkiwisky/loveconsole","last_synced_at":"2025-04-22T17:49:49.926Z","repository":{"id":164994798,"uuid":"640395714","full_name":"itzKiwiSky/LoveConsole","owner":"itzKiwiSky","description":" A simple to use and powerful command Console to your love games.","archived":false,"fork":false,"pushed_at":"2023-08-05T19:15:36.000Z","size":163,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-17T08:59:27.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itzKiwiSky.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-14T00:11:09.000Z","updated_at":"2024-07-12T00:10:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"92aeae83-3a71-4104-a681-bd893dab3764","html_url":"https://github.com/itzKiwiSky/LoveConsole","commit_stats":null,"previous_names":["itzkiwisky/loveconsole"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzKiwiSky%2FLoveConsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzKiwiSky%2FLoveConsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzKiwiSky%2FLoveConsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzKiwiSky%2FLoveConsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzKiwiSky","download_url":"https://codeload.github.com/itzKiwiSky/LoveConsole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250291082,"owners_count":21406294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T18:12:21.343Z","updated_at":"2025-04-22T17:49:49.905Z","avatar_url":"https://github.com/itzKiwiSky.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LoveConsole\n\nA simple to use and powerful command Console to your love games.\n\n---\n\n## Features\n\n- Draggable window\n- Custom command support (supporting commands with parameters, without changing the source)\n- Simple color support\n- Easy to install and setup.\n- No need external files to work.\n- Window resizing and auto breaking text\n\n### Planned:\n\n- [ ] More default commands\n\n---\n\n## How to install\n\n\u003e ### **[1] -** Copy the console library to your project folder\n\n\u003e ### **[2] -** require it with `console = require 'console'`\n\n\u003e ### **[3] -** Put every function on specific callback. Example : console:update(dt) to to love.update(dt) callback.\n\n---\n\n## Examples of use\n\n### **[Example 1] |** using with [hump gamestate](https://github.com/vrld/hump/tree/master)\n\nInstead of calling every function of the console library in every state you create, this example shows you how to create a global console.\n\n```lua\nfunction love.load()\n    -- require the console library --\n    console = require 'console'\n    gamestate = require 'gamestate'\n\n    -- create a new console at x: 90, y: 90\n    console:init()\n\n    -- states list (cool for organization :D) --\n    states = {\n        myState = require 'states.mystate'\n    }\n    \n    -- register the necessary events --\n    gamestate.registerEvents({'update', 'textinput', 'keypressed', 'mousepressed', 'mousereleased'})\n    -- change the state --\n    gamestate.switch(states.myState)\nend\n\nfunction love.draw()\n    -- draw all the state stuff first --\n    gamestate.current():draw()\n    -- after drawing the state stuff, draw the console itself --\n    console:render()\nend\n\nfunction love.update(elapsed)\n    console:update()\nend\n\nfunction love.textinput(text)\n    console:textinput(text)\nend\n\nfunction love.keypressed(k)\n    console:keypressed(k)\nend\n\nfunction love.mousepressed(x, y, button)\n    console:mousepressed(x, y, button)\nend\n\nfunction love.mousereleased(x, y, button)\n    console:mousereleased(x, y, button)\nend\n```\n\n\u003e **OBS:** This method don't work for `love.graphics.present()` function. Everything draw on the present() method will appear on the top\n\n\u003e **OBS 2:** This example shows you how to setup the console globally, removing the need to install it on every state you create and want use.\n\n---\n\n### **[Example 2] |** creating custom commands (Part 1 - The basic command)\n\nThis example will show you how to create a basic command *without any arguments*. It uses a function called `console:registerCommand:(\u003ccommandName\u003e:string, \u003chelpDescription\u003e:string, \u003ccommandFunction\u003e:function)`\n\n\u003e **OBS :** This example also uses another command, the `console:trace()` command, it will be explained on the functions section.\n\n```lua\nfunction love.load()\n    -- require the console library --\n    console = require 'console'\n    -- create a new console at x: 90, y: 90\n    console:init()\n\n    console:registerCommand(\"myCoolCommandName\", \"This is the help message, it will appear with help command\" function()\n        console:trace(\"This is my cool command\")\n    end)\nend\n```\n\nand this is the result : \n\n![Alt text](assets/Screenshot_1.png)\n\nand when we run the command on the console:\n\n![Alt text](assets/Screenshot_2.png)\n\n### **[Example 3] |** creating custom commands (Part 2 - Commands with arguments)\n\nIs the same process to create commands but this time, we include the arguments we want as parameters on the function\n\n```lua\nfunction love.load()\n    -- require the console library --\n    console = require 'console'\n    -- create a new console at x: 90, y: 90\n    console:init()\n\n    console:registerCommand(\"myCoolCommandWithArgument\", \"This is the help message, it will appear with help command\", 0, function(argument)\n        console:trace(\"This is my cool command\")\n        console:trace(\"And this is my argument\" .. argument)\n    end)\nend\n```\n\nand this is the result when we execute it on the console :\n\n![Alt text](assets/Screenshot_3.png)\n\n## Function list\n\n---\n\n### **console:registerCommand()**\n\n---\n\nUsed to register a custom command to commands database.\n\nUsage : `console:registerCommands(\u003ccommandName\u003e, \u003chelpDescription\u003e, \u003cpriorityLevel\u003e, \u003cfunctionExec\u003e)`\n\n| Parameters  | Type | optional | Description |\n| ------------- | ------------- | ------------- | ------------- |\n| commandName | `string` | no | The name of your command |\n| helpDescription | `string` | yes  | The description of your command |\n| priorityLevel | `number` | yes | Define the priority color on the `help` command|\n| functionExec | `function` | no | The lua function you want run when the command is executed|\n\n---\n\n### **console:rebind()**\n\n---\n\nUsed to rebind some keyboard keys functions\n\nUsage : `console:rebind(\u003ckeys\u003e)`\n\n| Parameters  | Type | optional | Description |\n| ------------- | ------------- | ------------- | ------------- |\n| keys | `table` | no | The keys table you want rebind |\n\nhere the list of the possible values to use in this table:\n\n| Keys | value |\n| ---- | ----- |\n| submit | return |\n| open | f1 |\n| removeChar | backspace |\n| previousCommand | up |\n| nextcommand | down |\n\nexample :\n\n```lua\nconsole:rebind({\n    submit = \"return\",\n    open = \"f1\",\n    removeChar = \"backspace\",\n    previousCommand = \"up\"\n    nextcommand = \"down\"\n})\n```\n\n\u003e **OBS :** Please insert a valid key constant, if you want check the official [LOVE keys Constant reference](https://love2d.org/wiki/KeyConstant)\n\n---\n\n### **console:trace()**\n\n---\n\nUsed to write a message on the console display.\n\nUsage: `console:trace(\u003cmessage\u003e, \u003clevel\u003e)`\n\n| Parameters  | Type | optional | Description |\n| ------------- | ------------- | ------------- | ------------- |\n| message | `string` | no | The message you want write |\n\n---\n\n### **console:setTheme()**\n\n---\n\nUsed to change the colors of the console including  the text colors\n\nUsage : `console:setTheme(_theme)`\n\n| Parameters  | Type | optional | Description |\n| ------------- | ------------- | ------------- | ------------- |\n| theme | `table` | no | The theme data table |\n\nhere the list of the possible values to use in this table:\n\n| Key | value |\n| ---- | ----- |\n| bg | table of colors (0 - 255) |\n| fg | table of colors (0 - 255) |\n| textColor | table of colors (0 - 255) |\n\n\n**Example** :\n```lua\nfunction love.load()\n    loveconsole:setTheme({\n        bg = {255, 255, 255},\n        fg = {128, 128, 128},\n        textColor = {\n            {255, 255, 255},\n            {128, 128, 128},\n            {0, 0, 0}\n        }\n    })\nend\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzkiwisky%2Floveconsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzkiwisky%2Floveconsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzkiwisky%2Floveconsole/lists"}