diff options
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/function.lua | 12 | ||||
-rw-r--r-- | server/src/vm/library.lua | 5 | ||||
-rw-r--r-- | server/src/vm/value.lua | 3 |
3 files changed, 12 insertions, 8 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 8e2478ca..834863d6 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -270,12 +270,12 @@ function mt:getSource() end local function create(source) - local id - if source then - id = source.id - if not id then - error('Not instanted source') - end + if not source then + error('Function need source') + end + local id = source.id + if not id then + error('Not instanted source') end local self = setmetatable({ source = id, diff --git a/server/src/vm/library.lua b/server/src/vm/library.lua index ed5c2e7f..6f038554 100644 --- a/server/src/vm/library.lua +++ b/server/src/vm/library.lua @@ -22,8 +22,9 @@ function buildLibValue(lib) if tp == 'table' then value = valueMgr.create('table', sourceMgr.dummy()) elseif tp == 'function' then - value = valueMgr.create('function', sourceMgr.dummy()) - local func = functionMgr.create() + local dummySource = sourceMgr.dummy() + value = valueMgr.create('function', dummySource) + local func = functionMgr.create(dummySource) value:setFunction(func) if lib.args then for _, arg in ipairs(lib.args) do diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index a51040b4..cfcdb66d 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -385,6 +385,9 @@ end function mt:getFunction() local func = self._func + if not func then + return nil + end if not func:getSource() then self._func = nil end |