agraef / pd-lua

Lua bindings for Pd, updated for Lua 5.3+
https://agraef.github.io/pd-lua/
GNU General Public License v2.0
47 stars 10 forks source link

pdluax can't be created without arguments or wrong file #15

Closed porres closed 1 year ago

porres commented 1 year ago

I think it should be able to create and give us just a simple/easy to read error

agraef commented 1 year ago

Can you elaborate? Or just follow up with a PR so that I can see what you mean.

porres commented 1 year ago

I tried but I couldn't see how to fix this.

The idea is that the object should be created even though it has no argument or if the argument points to a file than can't be found. Right now it will not create the object and print lots of errors, but I think that just printing an error should be enough, so people don't lose object connections in the patch and can still right click the object for help. This way it feels people don't have the object installed. Do you follow?

agraef commented 1 year ago

Ah yes, now I see what you mean:

pdlua_new: error in constructor for `pdluax':
[string "pd.lua"]:346: attempt to concatenate a nil value (field 'integer index')
pdluax
... couldn't create

It should be possible to create a dummy object in that case which just does nothing, except maybe respond to a load message, as pdlua does. I'll look into it.

agraef commented 1 year ago

Having looked at this again, this behavior is by design. pdluax is unlike pdlua in that it creates a proper Pd-Lua object as defined by the source that you give it as creation arg. To make this work, there actually needs to be a Lua function which implements the object, which is what the Lua source returns.

That said, we could maybe supply a dummy function if no source file is given. I'll look into that.

agraef commented 1 year ago

This was simply buggy initialization code on the Lua side which wouldn't handle certain corner cases, resulting in Lua exceptions which would then be printed in the console. Should be fixed now.

agraef commented 1 year ago

Ok, it looks like all open issues have been dealt with now (except #9 which is a complex issue and will have to wait for another day). So expect a 0.11.0 release soon.