MiniIDE: live code inside a LOVE app
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
MiniIDE: live code inside a LOVE app
Hello, LÖVE Community, we’d like to introduce “MiniIDE”!
MiniIDE was created so that developers can live-code LÖVE scripts inside of LÖVE itself. Its initial target was mobile iOS developers who lack options to live-code Love2D on their devices, but it has been tested on Windows, MacOS, Linux, iOS (iPad) and Android (tablet). We are grateful to the developers of Lua, LÖVE and the libraries love-console, Slab and native-fs. MiniIDE is built upon all their work.
MiniIDE comes with a console (bottom of the screen), a terminal (left hand side of the screen), and a resizable/movable mini-text editor.
MiniIDE has the ability to load and save lua scripts, and call its own LÖVE callback loops and return back to the editor from them.
MiniIDE is also able to render graphics commands directly from the MiniIDE screen to allow easy experimentation with the love.graphics API. One can even use the included Slab GUI library to create GUIs from one's script inside MiniIDE.
Note:
If you wish to break out of scripts that you run in MiniIDE that use LÖVE callbacks (e.g. love.update or love.draw), we’ve programmed into MiniIDE (using `xpcall`) to intercept any error in your script (e.g. if you call `error()`) and return you back to the MiniIDE editor when miniIDE encounters that code. For your convenience, we included a simple `escape()` function you can call in your script that calls `error()` and that can be inserted into the end of your script by pressing the “Stop Code” button in the Editor.
Limitations:
Cannot use the `love.run` or `love.load` callbacks in your scripts (used by MiniIDE)
No warnings yet if you forget to save editor contents.
Directory for storing scripts is currently set to the Source Base Directory (which contains the MiniIDE.love file--user could easily change in the program's code).
Acknowledgements:
MiniIDE includes the following libraries with grateful thanks:
love-console: https://github.com/rameshvarun/love-console
Slab: https://github.com/flamendless/Slab
nativefs: https://github.com/EngineerSmith/nativefs
We welcome any feedback you may have on MiniIDE and hope you enjoy using it and find it helpful :-)
------------------------------------------------------------------
YouTube MiniIDE Video:
MiniIDE was created so that developers can live-code LÖVE scripts inside of LÖVE itself. Its initial target was mobile iOS developers who lack options to live-code Love2D on their devices, but it has been tested on Windows, MacOS, Linux, iOS (iPad) and Android (tablet). We are grateful to the developers of Lua, LÖVE and the libraries love-console, Slab and native-fs. MiniIDE is built upon all their work.
MiniIDE comes with a console (bottom of the screen), a terminal (left hand side of the screen), and a resizable/movable mini-text editor.
MiniIDE has the ability to load and save lua scripts, and call its own LÖVE callback loops and return back to the editor from them.
MiniIDE is also able to render graphics commands directly from the MiniIDE screen to allow easy experimentation with the love.graphics API. One can even use the included Slab GUI library to create GUIs from one's script inside MiniIDE.
Note:
If you wish to break out of scripts that you run in MiniIDE that use LÖVE callbacks (e.g. love.update or love.draw), we’ve programmed into MiniIDE (using `xpcall`) to intercept any error in your script (e.g. if you call `error()`) and return you back to the MiniIDE editor when miniIDE encounters that code. For your convenience, we included a simple `escape()` function you can call in your script that calls `error()` and that can be inserted into the end of your script by pressing the “Stop Code” button in the Editor.
Limitations:
Cannot use the `love.run` or `love.load` callbacks in your scripts (used by MiniIDE)
No warnings yet if you forget to save editor contents.
Directory for storing scripts is currently set to the Source Base Directory (which contains the MiniIDE.love file--user could easily change in the program's code).
Acknowledgements:
MiniIDE includes the following libraries with grateful thanks:
love-console: https://github.com/rameshvarun/love-console
Slab: https://github.com/flamendless/Slab
nativefs: https://github.com/EngineerSmith/nativefs
We welcome any feedback you may have on MiniIDE and hope you enjoy using it and find it helpful :-)
------------------------------------------------------------------
YouTube MiniIDE Video:
Last edited by SugarRayLua on Mon Sep 04, 2023 1:06 am, edited 1 time in total.
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: MiniIDE: live code inside a LOVE app
Update:
MiniIDE-af release below adds the ability of MiniIDE to recognize additional white spaces and nested () inside love.graphics commands
We'd especially appreciate feedback from Android users as to how we could better optimizing MiniIDE for Android use. Thanks!
------------
MiniIDE-af release below adds the ability of MiniIDE to recognize additional white spaces and nested () inside love.graphics commands
We'd especially appreciate feedback from Android users as to how we could better optimizing MiniIDE for Android use. Thanks!
------------
- Kartik Agaram
- Prole
- Posts: 34
- Joined: Fri Apr 01, 2022 4:46 am
Re: MiniIDE: live code inside a LOVE app
One new thing inside the latest version is a list of manual tests that we're using before publishing new versions of MiniIDE. It might be useful also to others, to get a sense of the kinds of LÖVE apps you can build from within MiniIDE. Here it is:
How we the creators expect MiniIDE to behave in a few different scenarios
- Typing in an expression involving constants into either the console (bottom line on screen) or editor evaluates it and prints the result in the console (above the bottom line on screen).
In editor:Code: Select all
> 1+1 2
..and hit 'Run'Code: Select all
1+1
- Typing in graphics involving constants into either the console or editor shows them on screen.
You should see a line on the screen, potentially drawing over text in the console.Code: Select all
> love.graphics.line(100,100, 200,300)
- Typing in an expression involving variables into either the console or editor works as usual.
In editor, type:Code: Select all
> x = 1 > x+1 2
and hit 'Run'Code: Select all
x = 1
Then clear editor and type:and hit 'Run' again.Code: Select all
x+1
You can't put both statements into the editor at once. That would be like typing `x = 1; x+1` into the console or any Lua prompt. (Which also wouldn't work.)- Drawing graphics involving variables will work in either the console or editor.
The console requires blocks to all be on a single line, though:Code: Select all
x = 100 love.graphics.line(x,x, 200,300)
If you hit enter now you'll see an error. You can define functions if they're all on one line.Code: Select all
> function foo()
You're probably better off putting function definitions in the editor.Code: Select all
> function foo() return 42 end
- However, graphics only work when they fit a specific pattern. This doesn't work (known bug):
Code: Select all
lg = love.graphics lg.line(100,100, 200,300)
- For more complex graphics, override `love.draw`:
However, once you hit 'Run' you're running a whole new app, and you'll have no way to go back to MiniIDE. (intended behavior)Code: Select all
lg = love.graphics function love.draw() lg.line(100,100, 200,300) end
- To return to MiniIDE, override some event to `escape()`:
Now press the 'Stop Code' button. It will insert some code into the editor so it looks like this:Code: Select all
function love.draw() love.graphics.line(100,100, 200,300) end function love.keypressed(key) escape() end
Now press 'Run' to see a new app draw a line across the whole screen. Press any key to return to MiniIDE.Code: Select all
function love.draw() love.graphics.line(100,100, 200,300) end function love.keypressed(key) escape() end function escape() error('StopScript') end
- You can also create an app that includes MiniIDE, like this:
This will look just like scenario 2 above, but it has more room to grow. You can take over other event handlers from MiniIDE like `love.keypressed` or `love.mousepressed`, and you can add rules before or after them. Any errors will put you back in MiniIDE without your app additions. For example, if you edit it to look like this:Code: Select all
lg = love.graphics if old_love_draw == nil then old_love_draw = love.draw end function love.draw() old_love_draw() lg.line(100,100, 200,300) end
Hit 'Run', then press a key. The key will have no effect, and you'll see an error like this in the log:Code: Select all
lg = love.graphics if old_love_draw == nil then old_love_draw = love.draw end function love.draw() old_love_draw() lg.line(100,100, 200,300) end function love.keypressed() print(y+1) -- error: y is nil, and you can't add 1 to nil end
However, future keypresses (without hitting 'Run' again) will work. Your app has been 'deregistered', and things have gone back to pristine MiniIDE. Now you can fix the error and try hitting 'Run' again.Code: Select all
Error: [string "lg = love.graphics..."]:13: attempt to perform arithmetic on global 'y' (a nil value)
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: MiniIDE: live code inside a LOVE app
The following release uses a menu-driven GUI for those who might prefer a more minimalistic look and would like more screen space.
The release also contains a "Rotate device" feature for Android users. You can still use control-c and control-v to transfer text to and from the clipboard.
-----------------
------------------
The release also contains a "Rotate device" feature for Android users. You can still use control-c and control-v to transfer text to and from the clipboard.
-----------------
------------------
Re: MiniIDE: live code inside a LOVE app
Interesting project. One small problem I have immediately faced. If I implement my own love.draw callback and run it, it is clear the entire screen, get rid of all the menus including the option to stop the code. I would setup a key, maybe the Escape key traditionally to stop the code from running when pressed.
But even if I just run the code love.graphics.print()
It is print over the menu.
I think there should be a boundary to draw maybe using a separate canvas to keep the menu always visible.
But even if I just run the code love.graphics.print()
It is print over the menu.
I think there should be a boundary to draw maybe using a separate canvas to keep the menu always visible.
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: MiniIDE: live code inside a LOVE app
Thanks, @ddabrahim, for checking out the project and offering your suggestions!
A separate canvas is a great idea.
We thought about a separate "escape" key to exit out of your running code but initially decided to let folks programmatically decide what they want to use to escape (e.g. a certain key or mouse click). We've tried to make it easy on programmers by including the following brief escape function that you can add to your project with callbacks by pressing (or selecting) the "stop code" button or menu selection which will insert:
```
function escape()
error("StopScript")
end
```
(i.e. the "stop code" button doesn't actually stop the script from running but rather provides you with default code to stop the script).
Then from whatever trigger you like in your script you can just call "escape()" and the project will exit back to the main editor. If you then wanted to use the same script outside of MiniIDE you could then perhaps just substitute "love.event.quit()" for the "escape" call.
*For more concise code, alternatively you can just call "error()" from a trigger anywhere in your code to get your running code to stop and return to the editor.
A separate canvas is a great idea.
We thought about a separate "escape" key to exit out of your running code but initially decided to let folks programmatically decide what they want to use to escape (e.g. a certain key or mouse click). We've tried to make it easy on programmers by including the following brief escape function that you can add to your project with callbacks by pressing (or selecting) the "stop code" button or menu selection which will insert:
```
function escape()
error("StopScript")
end
```
(i.e. the "stop code" button doesn't actually stop the script from running but rather provides you with default code to stop the script).
Then from whatever trigger you like in your script you can just call "escape()" and the project will exit back to the main editor. If you then wanted to use the same script outside of MiniIDE you could then perhaps just substitute "love.event.quit()" for the "escape" call.
*For more concise code, alternatively you can just call "error()" from a trigger anywhere in your code to get your running code to stop and return to the editor.
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: MiniIDE: live code inside a LOVE app
Hello, LOVE2D Community.
We've updated MiniIDE to make it easier to use on mobile devices (iOS and Android tablets) with on-screen keyboards. Desktop users and those with mobile devices and an external keyboard have more screen space.
Release notes:
1. Type commands at top of window so that it isn't covered by the keyboard on touchscreens.
2. New menu entries for copy and paste, increase/decrease console font size
3. Clear graphics as well when clearing console
4. Some bugfixes to drawing graphics without overriding love.draw
Note: Editor window is resizable by selecting and dragging window borders (although a bit more difficult to do so by touch).
We welcome your further feedback and suggestions for the project.
Screenshots on iOS (iPAD) below:
---------------------- -----------------------
We've updated MiniIDE to make it easier to use on mobile devices (iOS and Android tablets) with on-screen keyboards. Desktop users and those with mobile devices and an external keyboard have more screen space.
Release notes:
1. Type commands at top of window so that it isn't covered by the keyboard on touchscreens.
2. New menu entries for copy and paste, increase/decrease console font size
3. Clear graphics as well when clearing console
4. Some bugfixes to drawing graphics without overriding love.draw
Note: Editor window is resizable by selecting and dragging window borders (although a bit more difficult to do so by touch).
We welcome your further feedback and suggestions for the project.
Screenshots on iOS (iPAD) below:
---------------------- -----------------------
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: MiniIDE: live code inside a LOVE app
New release, primarily with improvements for mobile tablet use:
Major changes:
* Windows are easier to resize, especially on a tablet.
* Scrollbars are easier to drag around, especially on a tablet.
-------------------
Major changes:
* Windows are easier to resize, especially on a tablet.
* Scrollbars are easier to drag around, especially on a tablet.
-------------------
Re: MiniIDE: live code inside a LOVE app
It's interesting if the editor has an autocomplete feature; it would be more useful. It could even have a document embedded for users to look up the API.
-
- Party member
- Posts: 356
- Joined: Wed Jul 03, 2013 4:06 am
Re: MiniIDE: live code inside a LOVE app
This is really handy...
Who is online
Users browsing this forum: Google [Bot] and 9 guests