Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 'am.restart()' from lua in the SDL backend. #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinw
Copy link
Contributor

@kevinw kevinw commented Feb 27, 2020

Does this kind of change need multiplatform support and documentation in the pull request, or are you happy to add undocumented functions incrementally? Happy to help with the former if so.

@ianmaclarty
Copy link
Owner

What's the use-case for this?

@kevinw
Copy link
Contributor Author

kevinw commented Mar 2, 2020

I was implementing some live reload-like-features for shaders on the Lua side. i.e., if a shader's text has changed, then we just reload the world. But perhaps that's the kind of functionality that is better served in the engine.

@kevinw
Copy link
Contributor Author

kevinw commented Mar 10, 2020

specifically something like this:

local live_files = {}
local last_check_time = 0
local CHECK_INTERVAL_SECS = 0.3

local function check_live_files()
    for filename, contents in pairs(live_files) do
        local f = io.open(filename, "r")
        if f == nil then
            log("could not open live file " .. filename)
        elseif f:read("*all") ~= contents then
            log("reloading because file changed: " .. filename)
            am.restart()
        end
    end
end

@ianmaclarty
Copy link
Owner

Why not just hit F5 after making a change though? Loading all files each frame is probably not going to be great for performance.

@kevinw
Copy link
Contributor Author

kevinw commented Mar 24, 2020

I have it doing the actual file check every 2 seconds or something.

Basically my point is, being able to hack together a live-reload harness type thing from Lua is made possible by providing an am.restart() func.

@ianmaclarty
Copy link
Owner

I still don't understand what's the issue with just pressing F5. To me this is preferable to since you can then control when the game restarts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants