Question

When I try to call method of other class from another class it says error message that,

Attempt to call field 'LoadShift' (a nil value)

Here's my code, loginpage1.lua

local LoadShift = nil;
.
.
function LoadShift()

end

loginpage2.lua

local loginObj = require("com.classess.loginpage1")
loginObj.LoadShift();

What's the problem with my code, Please help me to solve this issue

Was it helpful?

Solution

Make your custom class like this

------------Your class LoadShift---------------
    local LoadShift = {}
    .
    .
    function LoadShift:LoadShiftFunc()
        --do somthing
    end
    .
    .
    return LoadShift
-------------------------------------

then require it and call that function like

---------------------

local LoadShift= require "LoadShift"
LoadShift:LoadShiftFunc()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top