I have this in menu.lua
local db = require "databaseconnection"
...
local function onEndBtnRelease()
local thisandthat = db.getLoggedIn()
native.showAlert( "Corona SDK", thisandthat.." teststring", { "OK" } )
end
...
and this in databaseconnection.lua
local function getLoggedIn()
print("Test")
--[[...
]]--
return "some data"
end
The only thing I want is that String ("some data"
) from getLoggedIn()
, but all I get is an error:
...\corona\menu.lua:51:attempt to call field 'getLoggedIn' (a nil value)
The outprint is never reached.
I'm working on Corona SDK and Sublime, the needed data from isLoggedIn()
comes from a sqlite-request. How can I reach that function?
One direct way to write a module is to return a table that includes the functions you need:
local M = {}
function M.getLoggedIn()
print("Test")
--...
return "some data"
end
return M
Note that the function needs to be non-local
, or it would be private.
See PiL for other advanced methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With