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

Fix lua class Index #314

Merged
merged 2 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions Content/Script/UnLua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@ local function Index(t, k)
local super = mt
while super do
local v = rawget(super, k)
if v~= nil then
if rawequal(v, NotExist) then
return nil
end
if v ~= nil and not rawequal(v, NotExist) then
rawset(t, k, v)
return v
end
super = rawget(super, "Super")
end
local p = mt[k]

if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end
local p = mt[k]
if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end

return p
end

Expand All @@ -65,7 +63,7 @@ local function Class(super_name)
new_class.__newindex = NewIndex
new_class.Super = super_class

return new_class
return new_class
end

local function global_index(t, k)
Expand Down
33 changes: 16 additions & 17 deletions Plugins/UnLua/Content/UnLua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@ local function Index(t, k)
local super = mt
while super do
local v = rawget(super, k)
if v~= nil then
if rawequal(v, NotExist) then
return nil
end
if v ~= nil and not rawequal(v, NotExist) then
rawset(t, k, v)
return v
end
super = rawget(super, "Super")
end
local p = mt[k]

if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end
local p = mt[k]
if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end

return p
end

Expand All @@ -65,7 +63,7 @@ local function Class(super_name)
new_class.__newindex = NewIndex
new_class.Super = super_class

return new_class
return new_class
end

local function global_index(t, k)
Expand All @@ -87,6 +85,7 @@ else
global_mt.__index = global_index
setmetatable(_G, global_mt)
UE4 = _G
UE = _G

print("WITH_UE4_NAMESPACE==false");
end
Expand Down