Override built-in type method so SoundGroup instances can be identified
This commit is contained in:
parent
e86d05ceaf
commit
910e7f58e7
2
api.lua
2
api.lua
@ -93,6 +93,8 @@ SoundGroup = {
|
||||
end
|
||||
end
|
||||
|
||||
def.__type = "SoundGroup"
|
||||
|
||||
def.__init = {
|
||||
-- execute "play" methode when called directly
|
||||
__call = self.play,
|
||||
|
1
init.lua
1
init.lua
@ -20,6 +20,7 @@ end
|
||||
|
||||
|
||||
local scripts = {
|
||||
"override",
|
||||
"api",
|
||||
"groups",
|
||||
"node_groups",
|
||||
|
16
override.lua
Normal file
16
override.lua
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
-- override built-in type function
|
||||
local otype = type
|
||||
type = function(obj)
|
||||
local base_type = otype(obj)
|
||||
if base_type == "table" then
|
||||
local meta_type = otype(obj.__type)
|
||||
if meta_type == "string" then
|
||||
return obj.__type
|
||||
elseif meta_type == "function" then
|
||||
return obj:__type()
|
||||
end
|
||||
end
|
||||
|
||||
return base_type
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user