Why wont this work ? trying to get the require function to work after downloading a few files

main1.lua basically contains code to display a simple picture.

i managed to fix this error

ive tried everything it just wont find main1.lua, using the require function, _G.Main = require(path)

or _G.Main = require(main1)

all files are correct in folder when using show project sandbox

please help

local path = system.pathForFile( “main1.lua”, system.DocumentsDirectory )
            local fhd = io.open( path )

            – Determine if file exists
            if fhd then
               print( “main1.lua Exists” )
               
               path=path:gsub("/",".")
               --path=path:gsub(".lua","")
               --path=(path…".main1.lua")
               
               print(path)
              
               _G.Main = require(path)
            
               fhd:close()
               
            else
                print( “Main1.lua does not Exist” )
            end

Corona SDK does not permit loading of arbitrary .lua files after you’ve built your app. This is due to an Apple requirement that toolks like ours don’t allow arbitrary code to load after the user installs the app on their device. This is a security measure.

You can however load a JSON file of data, images, sounds and other files after the fact, read the JSON file in, decode it (which turns it nicely into a Lua table for you) and process the data in that file.

Rob

Corona SDK does not permit loading of arbitrary .lua files after you’ve built your app. This is due to an Apple requirement that toolks like ours don’t allow arbitrary code to load after the user installs the app on their device. This is a security measure.

You can however load a JSON file of data, images, sounds and other files after the fact, read the JSON file in, decode it (which turns it nicely into a Lua table for you) and process the data in that file.

Rob