that was the full code! I think previously I had copied some error report from a different run of the script… sorry that made it confusing.
I am using an apc mini, and I have gotten it pretty successfully to be grid like before… but I am not really trying right now to have it “emulate” a grid as hardware on the norns. such ventures are well documented around here
, and the apcmini is only 64 anyway. just want to the best I can with what i got!
But either way, just simply:
make a new script, and enter
somenewclass = midi.new()
function somenewclass:newmethod()
print("hello")
end
m = somenewclass.connect()
m:newmethod()
what I expect is that somenewclass = midi.new() copies over the midi class to my new class, then I add a new method to my new class by calling the next part, then I instantiate my new class in m and call its new method. ultimately I expect no error (even if I dont see the print because this script never initializes or anything).
but if I run this, I get an error that newmethod has not been declared:
norns.script.load("code/beepboop/apcgrid-test2/apcgrid-test.lua")
# script load: /home/we/dust/code/beepboop/apcgrid-test2/apcgrid-test.lua
# cleanup
# script clear
### SCRIPT ERROR: load fail
/home/we/dust/code/beepboop/apcgrid-test2/apcgrid-test.lua:9: attempt to call a nil value (method 'newmethod')
stack traceback:
/home/we/norns/lua/core/norns.lua:215: in method 'newmethod'
/home/we/dust/code/beepboop/apcgrid-test2/apcgrid-test.lua:9: in main chunk
[C]: in function 'dofile'
/home/we/norns/lua/core/script.lua:149: in function </home/we/norns/lua/core/script.lua:149>
[C]: in function 'xpcall'
/home/we/norns/lua/core/norns.lua:216: in field 'try'
/home/we/norns/lua/core/script.lua:149: in function 'core/script.load'
(...tail calls...)
# script clear
<ok>
so yeah more a lua question than anything, looking at both the lua documentation on this, as well as the midi.lua core file, I cant quite see whats wrong with this.
I assume it has something to do with methods available to midi instances vs those available to the midi class itself, because, for example, calling somenewclass:newmethod() works here, but thats obviously not as useful
edit I think I got it, I just had to follow through with my last thought there…
the call to somenewclass.connect does not actually instantiate m as anything, it simply points it to the pre-method-wrapped vport thing, which wont have my new method. this totally makes sense because of the way we select midi devices and the way scripts are agnostic to midi being plugged in or not.
So I just have to figure out how to add methods to vports conditionally, or just make an alternate core file.