Is there an issue with the script reference for include()? The docs says:

include('lib/somelib.lua') will first look in the directory of the current script. This allows using relative paths to use libraries local to the script.

My current folder structure:

script.lua
lib/
  target.lua

In script.lua, include('lib/target.lua') results in:

including /home/we/dust/code/lib/target.lua.lua
### SCRIPT ERROR: load fail
cannot open /home/we/dust/code/lib/target.lua.lua: No such file or directory

It seems like if .lua is present in the include’s filename, it adds it again.

This is true and the doc is incorrect

include attempts to follow the syntax of require (which is a builtin)

1 Like

What would be the easiest way to get a 3d perlin noise function in a lua script? Is it possible to expose the Perlin3 function of Supercollider or embed a C file?

Here’s an example where I use a few functions similar to Perlin3 (Brownian, Lorenz, and a few others) in SuperCollider that then effect Lua code via polls:

It and it’s accompanying lua code is a big mess right now, I’d love to wrap it up into a shareable modulator library at some point.

5 Likes

seems like just… coding it up in lua? would be the most straightforward.

When I tried to use a Perlin noise function I found a gist of in Lua at 15fps it ended up causing the controls and menu to get a little unresponsive. It could have been particularly inefficient or just be the cumulative effect of a lot of stuff I was doing in the draw loop, but things felt a lot snappier after I pushed it to SC and used a poll.

Yea that makes sense too. I can imagine a naive LERP in lua being pretty rough

e.g., people forget that the # operator loops over the table!

@neauoire i don’t remember where you originally asked, but

norns.script.clear()

will clear the current script.

theoretically maiden could have ;clear mapped to this.

note: it doesn’t perform the menu magic to disable toggling into PLAY mode, however.

1 Like

Being able to to stop a crashing script on the fly with a quick shortcut would be very useful, sometimes i get error debug logs 15fps and totally makes the input field too sluggish to type in.

2 Likes

This is definitely something that happens to me. Having an easy way out would be awesome.

2 Likes

What is the function that fires on quit? Let say I have noteOn messages to release when I shut down the norns, or when I change library, is there something like on_quit that I can override?

function cleanup()
  -- executed on script close/change/quit
end
1 Like

Thank you :slight_smile: I’ve updated the tutorials.

Is there a script that I can use via ssh to push my lua script(like cmd p via maiden) to the norns? So I can use another IDE instead of Maiden?

1 Like

Maiden is using websockets to do all its magic. I tried to figure this out awhile back but I could not get any websocket client working on my mac and kinda gave up. I’ll search for that thread…

FWIW - I often just code in BBEdit saving via SFTP and then reloading the script on device.

i usually use emacs and tramp-mode, do everything on device, run processes manually

(but of course maiden is extremely useful. and has some awesome new features in the pipeline,)

So, I start start.sh in the /maiden folder.
And then I do script.load('we/dust/code/folder/script.lua')?

Don’t use start.sh if you don’t want the websoxket wrappers that maiden uses

Just run directly from ~/Norns

./build/crone/crone
sclang
./build/matron/matron

@neauoire
we should maybe resurrect the old matron wrapper that has readline &c

matron is the process with the lua REPL on stdio

You can pipe to it or whatever

Personally I find it convenient to just reload script by hitting 2 buttons on device

2 Likes

How should I start the repl that will let me do .load()?