Skip to content

Commit

Permalink
Detect reload and clear state
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Dec 9, 2017
1 parent 0b2b25f commit 9fc08b4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gooey/gooey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ end
-- @return Instance for the node
local function instance(id, instances)
local key = to_key(id)
instances[key] = instances[key] or {}
return instances[key]
local instance = instances[key]
-- detect a reload (unload and load cycle) and start with an
-- empty instance
-- if the script instance has changed then we're certain that
-- it's reloaded
local script_instance = _G.__dm_script_instance__
if instance and instance.__script ~= script_instance then
instances[key] = nil
end
instances[key] = instances[key] or { __script = script_instance, data = {} }
return instances[key].data
end

--- Convenience function to acquire input focus
Expand Down

0 comments on commit 9fc08b4

Please sign in to comment.