Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot load this plugin due to "attempt to call a nil value" #31

Closed
codewdy opened this issue Jan 2, 2023 · 8 comments · Fixed by #34
Closed

cannot load this plugin due to "attempt to call a nil value" #31

codewdy opened this issue Jan 2, 2023 · 8 comments · Fixed by #34

Comments

@codewdy
Copy link

codewdy commented Jan 2, 2023

I create an empty godot project, and unzip addons to the project.
reopen the project and press F5(Run).
I think there is some lua error.

src/language_gdnative.c:301 - Error in validate: attempt to call a nil value
stack traceback:
	[C]: at 0x7ff98d127030
--- Debugging process started ---
Godot Engine v3.5.1.stable.official.6fed1ffa3 - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
Async. shader compilation: OFF
 
Unicode error: invalid skip

v0.5.0 lua_pluginscript.zip md5sum:47c9324b9f15aa2f4009914d7c247e1d

I revert lua plugin to v0.4.0 and all things work well.

@gilzoide
Copy link
Owner

gilzoide commented Jan 2, 2023

Hmm, I've tried it here, both using the version in Asset Library and downloading the newest build, but none failed.

src/language_gdnative.c:301 - Error in validate: attempt to call a nil value
stack traceback:
[C]: at 0x7ff98d127030

By the looks of it, the problem seems to be loading plugin/in_editor_callbacks/init.lua, which is the file that contains the editor specific callbacks, including validate.

Using require in src/register_in_editor_callbacks.lua might be the issue, since it depends on package.path.
I'll change it to load the file directly instead of relying on require.

Say, how is the Package Path configuration in your project?
Screenshot 2023-01-02 at 20 31 30

@codewdy
Copy link
Author

codewdy commented Jan 3, 2023

maybe the plugin is not loaded at all, so the settings is not enable.
image

I found the plugin is not enable in the settings, so I click here and get some error.
image

some errors when I click "Enable".

--- Debugging process started ---
Godot Engine v3.5.1.stable.official.6fed1ffa3 - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
Async. shader compilation: OFF
 
Unicode error: invalid skip
--- Debugging process stopped ---
 src/language_gdnative.c:184 - Error in script_init: attempt to call a nil value
stack traceback:
	[C]: at 0x7ff994147030
 src/language_gdnative.c:184 - Error in script_init: attempt to call a nil value
stack traceback:
	[C]: at 0x7ff994147030
 res://addons/godot-lua-pluginscript/plugin/plugin.gd:33 - Invalid call. Nonexistent function 'new' in base 'PluginScript'.
 src/language_gdnative.c:184 - Error in script_init: attempt to call a nil value
stack traceback:
	[C]: at 0x7ff994147030
 src/language_gdnative.c:184 - Error in script_init: attempt to call a nil value
stack traceback:
	[C]: at 0x7ff994147030
 res://addons/godot-lua-pluginscript/plugin/plugin.gd:33 - Invalid call. Nonexistent function 'new' in base 'PluginScript'.

@codewdy
Copy link
Author

codewdy commented Jan 3, 2023

I tried add code in the head of the file, but no file created.

"PROJECT_ROOT\addons\godot-lua-pluginscript\plugin\in_editor_callbacks\init.lua"

file = io.open ("C:\Users\xxx\Downloads\a" , "w")
file:write("--test")
file:close()

@gilzoide
Copy link
Owner

gilzoide commented Jan 3, 2023

Ok, it seems the GDNative library is being loaded, or else you wouldn't be seeing these [C]: * stacktraces.
Lua initialization must have some error, since all PluginScript callbacks are nil, hence the message attempt to call a nil value.

I have a machine with Windows 10 here and will test to see what is going on, probably something is off with the new build.
Thanks for the new information! I'll let you know if I find anything.

@gilzoide
Copy link
Owner

gilzoide commented Jan 4, 2023

Hey, so I'm testing here and I found the problem.
It seems MinGW is not exporting symbols marked with extern, I don't know why it stopped working.
LuaJIT accesses some global variables via FFI, so they need to be exported in the DLL. Adding -Wl,--export-all-symbols seems to fix this, but I might change the initialization script to receive these variables directly instead of relying on exported symbols to avoid more trouble.

@gilzoide
Copy link
Owner

gilzoide commented Jan 4, 2023

@codewdy #34 should fix the problem.
Can you please test the "lua_pluginscript" artifact from https://github.com/gilzoide/godot-lua-pluginscript/actions/runs/3834391408 and confirm if the new version works for you?

@codewdy
Copy link
Author

codewdy commented Jan 4, 2023

a new bug, but not very confusing.

  1. create a project
  2. close godot
  3. copy the addons
  4. open the project
  5. now the plugin is not enable in the setting,
  6. click the Enable and some error log is emitted.
  7. close the godot and reopen
  8. now you can click Enable correctly, and lua plugin works well.

I use windows 11.

first click "Enable" error log:

Godot Engine v3.5.1.stable.official (c) 2007-2022 Juan Linietsky, Ariel Manzur & Godot Contributors.
--- GDScript language server started ---
 No loader found for resource: res://addons/godot-lua-pluginscript/plugin/lua_repl.lua.
 No loader found for resource: res://addons/godot-lua-pluginscript/plugin/lua_repl.lua.
 scene/resources/resource_format_text.cpp:157 - Couldn't load external resource: res://addons/godot-lua-pluginscript/plugin/lua_repl.lua
 No loader found for resource: res://addons/godot-lua-pluginscript/plugin/export_plugin.lua.
 res://addons/godot-lua-pluginscript/plugin/plugin.gd:33 - Parse Error: Can't preload resource at path: res://addons/godot-lua-pluginscript/plugin/export_plugin.lua
 core/project_settings.cpp:239 - Property not found: editor_plugins/enabled

@gilzoide
Copy link
Owner

gilzoide commented Jan 4, 2023

Ok, thanks for the info. Since it is a different problem, can you please open a new issue for it?
I'm closing this one, since the fix is working and the PluginScript is loaded correctly in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants