I created a Library myData.lua with this info I got from codebase, I changed testFunction1and inserted a string
[lua]
local M = {}
local testFunction1 = function()
star1=display.newText( “go back”, w/2, h/6, “marker felt”, 75 )
end
– assign a reference to the above local function
M.testFunction1 = testFunction1
local testFunction2 = function()
print( “Test 2” )
end
M.testFunction2 = testFunction2
– Finally, return the table to be used locally elsewhere
return M
[/lua]
then in a separate file level1.lua I try to call the string testFunction1like so:
[lua]
local myData = require( “myData” )
local options1 =
{
text = myData.testFunction1(),
x = w/2,
y= h/6,
width = 800, --required for multi-line and alignment
font = “marker felt”,
fontSize = 75,
align = “center”,
}
local myText1 = display.newText( options1 )
myText1:setFillColor( 0, 0, 0 )
group:insert( myText1 )
[/lua]
I keep getting errors, i can’t put the function in the text because it wants a string, if i put
text = “myData.testFunction1()”,it prints exactly that - myData.testFunction1()