Drewol / unnamed-sdvx-clone

A game based on K-Shoot MANIA and Sound Voltex
MIT License
795 stars 96 forks source link

[Bug] Skin `.lua` file can't load library when using `gamedir` flag #668

Open DVN196 opened 7 months ago

DVN196 commented 7 months ago

Describe the bug When using gamedir flag and adding load path in lua files, the load path is relative to the game bin folder, not the gamedir

To Reproduce Steps to reproduce the behavior:

  1. Use gamedir flag, add skin to skins folder
  2. Change skin
  3. There will be errors and warnings: the game cannot find lua file from skins/[skin-name]/... even if the file exist
  4. Copy the skin to bin/skins directory, the skin work normally.

Expected behavior The load path should be relative to gamedir

Screenshots

Desktop (please complete the following information):

Additional context I copy the files from skins/HeavenlyExpress-1.3.0/textures/_shared/scripts to the skin root folder to avoid the first error when loading skin.

Log file

[23:46:47][Warning] Lua error: .../skins/HeavenlyExpress-1.3.0/backgrounds/fallback/bg.lua:2: module 'commonShared' not found:
    no field package.preload['commonShared']
    no file '/usr/local/share/lua/5.3/commonShared.lua'
    no file '/usr/local/share/lua/5.3/commonShared/init.lua'
    no file '/usr/local/lib/lua/5.3/commonShared.lua'
    no file '/usr/local/lib/lua/5.3/commonShared/init.lua'
    no file './commonShared.lua'
    no file './commonShared/init.lua'
    no file 'skins/HeavenlyExpress-1.3.0/textures/_shared/scripts/commonShared.lua'
    no file 'skins/HeavenlyExpress-1.3.0/backgrounds/fallback/commonShared.lua'