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

Allow LuaCallableExtra to be called in GDScript #207

Open
jbromberg opened this issue Apr 17, 2024 · 0 comments
Open

Allow LuaCallableExtra to be called in GDScript #207

jbromberg opened this issue Apr 17, 2024 · 0 comments

Comments

@jbromberg
Copy link

There are many instances where you may end up with a LuaCallableExtra in GDScript and there is no way to call it. The problem is illustrated here:

func lua_call(function):
	print("calling %s" % function)
	function.call()

var lua := LuaAPI.new()
lua.push_variant("call", lua_call)
lua.push_variant("foo", func(): print("foo"))

# Doesn't work
lua.do_string("call(foo)")

# Works
lua.do_string("call(function()
foo()
end)")

More broadly, it seems there could be some consolidation between LuaCallable and LuaCallableExtra to provide a simpler API. They both exist as functions in Lua but not in GDScript. Godot's Callable also has the bind() method that could allow the ref and tuple to still be passed into the Callable as arguments. This is obviously a deeper change but at the very least it would be great to be able to call a LuaCallableExtra from GDScript or at least expose the underlying Callable it wraps.

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

No branches or pull requests

1 participant