My point is that it is. Or rather, that it has too much power to allow covering all possible use cases. Also, see my edit.
Edit: If Corona can use loadfile and print, I could write a program for Corona that doesn't hot-reload properly.
Hot reload plugin that actually works?
Re: Hot reload plugin that actually works?
Well try it and get back to us. Otherwise it's just a hypothesis which may not be true. In any case hot reloading in 99% of cases (100%?) which seems to be how Corona works unless there's some complaints about that (which there may be) is way better than no hot reloading at all.
Re: Hot reload plugin that actually works?
This works in lua, luajit and Löve. I guess it probably works in Corona too.
The program prints "hi" and waits for you to press enter, then prints "> hi" and keeps doing it every time you press enter. You can exit by typing an EOF (Ctrl+D in Linux and Mac, Ctrl+Z then enter in Windows) and then closing the window if you're in Löve.
The challenge is to press enter a few times, then modify module.lua changing the > to * and then keep pressing enter and see if the change of > to * was effective, without seeing a single line with just "hi" and no prefix (which would indicate a restart).
main.lua:
module.lua:
My prediction is that it will not change at all, meaning the file was not reloaded.
Redefining print() is a relatively common operation; often the aim is to add a timestamp at the beginning, or to redirect the output to a different place. Using loadfile() is not so common, but I predict that if it uses require() and it is hot reloaded, another problem will happen, namely that it will print "* > hi" instead of "* hi".
The program prints "hi" and waits for you to press enter, then prints "> hi" and keeps doing it every time you press enter. You can exit by typing an EOF (Ctrl+D in Linux and Mac, Ctrl+Z then enter in Windows) and then closing the window if you're in Löve.
The challenge is to press enter a few times, then modify module.lua changing the > to * and then keep pressing enter and see if the change of > to * was effective, without seeing a single line with just "hi" and no prefix (which would indicate a restart).
main.lua:
Code: Select all
local redefine_print = loadfile("module.lua")
local first = true
repeat
print("hi")
if first then
redefine_print()
first = false
end
until io.read() == nil
Code: Select all
local orig_print = print
print = function(...)
orig_print("> " .. tostring((...)), select(2, ...))
end
Redefining print() is a relatively common operation; often the aim is to add a timestamp at the beginning, or to redirect the output to a different place. Using loadfile() is not so common, but I predict that if it uses require() and it is hot reloaded, another problem will happen, namely that it will print "* > hi" instead of "* hi".
Re: Hot reload plugin that actually works?
Ok sounds interesting - and so did it work?
Re: Hot reload plugin that actually works?
I don't have Corona, but I know it won't.
-
- Citizen
- Posts: 66
- Joined: Tue Jan 14, 2014 11:03 pm
Re: Hot reload plugin that actually works?
Corona doesn't do real "hot-reload". When you save a file, it just re-builds automatically the project from scratch.
Hot-reload of assets and code while the game is playing is much more difficult to handle. A good working example is Defold (which also has a lua debugger in its editor).
www.defold.com
Hot-reload of assets and code while the game is playing is much more difficult to handle. A good working example is Defold (which also has a lua debugger in its editor).
www.defold.com
Re: Hot reload plugin that actually works?
What's the difference in a practical sense? The project is instantly reloaded...seems pretty 'hot' to me.gianmichele wrote: ↑Sun Jan 28, 2018 9:36 am Corona doesn't do real "hot-reload". When you save a file, it just re-builds automatically the project from scratch.
Hot-reload of assets and code while the game is playing is much more difficult to handle. A good working example is Defold (which also has a lua debugger in its editor).
www.defold.com
Re: Hot reload plugin that actually works?
What Corona does is defined at 'Live Reloading'. Which can be pretty easy to setup with either Love or your Editor.hasen wrote: ↑Sun Jan 28, 2018 9:41 amWhat's the difference in a practical sense? The project is instantly reloaded...seems pretty 'hot' to me.gianmichele wrote: ↑Sun Jan 28, 2018 9:36 am Corona doesn't do real "hot-reload". When you save a file, it just re-builds automatically the project from scratch.
Hot-reload of assets and code while the game is playing is much more difficult to handle. A good working example is Defold (which also has a lua debugger in its editor).
www.defold.com
'Hot Reloading' on the other hand only reloads files that where changed, and maintains the state of the program, something that is difficult to achieve which has been explained earlier.
Re: Hot reload plugin that actually works?
I think that hasen is talking about this plugin: https://marketplace.coronalabs.com/plug ... ive-coding
I don't run software I can't compile myself. It may be free as in beer, but not free as in freedom.
It can't find the other file. Make sure it is placed somewhere where Corona can find it.
Who is online
Users browsing this forum: Bing [Bot], slime and 4 guests