Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
require command in main.lua cannot find local file. — Gideros Forum

require command in main.lua cannot find local file.

salesioparksalesiopark Member
edited July 17 in General questions
Hi.

In my project property, the 'Only load main.lua on start:' is checked.
After upgrading to Gideros 2022.6, the following error occurs
----------------------------------------------------------------

[string "luabinding/compatibility.lua"]:79: Module luasp.init not found
stack traceback:
[string "luabinding/compatibility.lua"]:79: in function require
main.lua:7: in function


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

at
    require 'luasp.init'
in the main.lua file. 'init.lua' file is located at 'asset/luasp' folder.

There were no problem in former versions.
Please help me.

Comments

  • hgy29hgy29 Maintainer
    require command disappeared from luau, so in Gideros we redefined it: https://github.com/gideros/gideros/blob/master/luabinding/compatibility.lua#L62

    But I guess our implementation doesn’t handle your case. Actually we don’t handle dots as path separators, that could be improved. But you should be able to just require ´luasp’ since by default Gideros will try to load it with /init.lua appended
  • salesioparksalesiopark Member
    edited July 18
    hgy29 said:

    require command disappeared from luau, so in Gideros we redefined it: https://github.com/gideros/gideros/blob/master/luabinding/compatibility.lua#L62

    But I guess our implementation doesn’t handle your case. Actually we don’t handle dots as path separators, that could be improved. But you should be able to just require ´luasp’ since by default Gideros will try to load it with /init.lua appended

    I overloaded the require() in main.lua as
    if gideros then
     
        function require(module)
    		if package.loaded[module] then return package.loaded[module] end
    		local m
    		if package.preload[module] then
    			assert(type(package.preload[module])=="function","Module loader isn't a function")
    			m=package.preload[module](module) or true
    		else
     
    			local fullpath = string.gsub(module, '%.','/') .. '.lua'
    			--print(fullpath)
    			local luafile,err=loadfile( fullpath )		
    			if luafile and type(luafile)=="function" then 
    				m=luafile(module) or true
    			end		
     
    		end
    		assert(m,"Module "..module.." not found")
    		package.loaded[module]=m or true
    		return m
    	end
     
    end
     
     
    require 'luasp.init'
    It seems that all my custom modules are loaded. However, the player doesn't run and occurs the following error

    ----------------------------------------
    nil
    attempt to index nil with '__styleUpdates'
    stack traceback:
    ----------------------------------------

    any help?
  • hgy29hgy29 Maintainer
    Since 2022.6, Gideros will try to get __styleUpdates value from 'application' global variable. The error you get seem to mean that application global variable was somehow set to nil somewhere in your code. Could that be ?
  • salesioparksalesiopark Member
    edited August 20
    By upgrading to ver. 2022.8, the above error occurring problem is removed.
    My overridden require() function works well too.
    Thank you.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.