Norns: scripting

norns
#492

Looks like @lazzarello says this weekend prior to your post.

1 Like
#493

does anyone know where the lua code for the “levels” screen is located? wanna try and steal some code from that for a script I am working on.

#494

All of the menu stuff currently lives in a single file. This should bring you to the mix/levels section https://github.com/monome/norns/blob/954f26da8a0362b5d657df31de26820526fc3bfc/lua/core/menu.lua#L1291

1 Like
#495

i might suggest instead looking at the UI code inside the we folder.

3 Likes
#496

yup, looking at both. just good to know how the levels menu are getting the live feeds from the ins/outs.

1 Like
#497

Updated

4 Likes
#498

Hi! I’m a new norns owner and started writing some scripts (have a bit of lua experience) :slight_smile: I have a couple of beginner questions:

  1. Can I use luarocks for third party libs?
  2. Is there something like fnutils (util functions for function programming style coding) on the norns? source
  3. Is somebody working on repl integration for vim? :smiley:
1 Like
Norns: help
#499

sure. IIRC luarocks is installed by deafult (nope, i did not RC). currently if you want to stay distributable i guess you would want to point luarocks at the local script directory. (with --tree)

we’ve discussed including more libraries by default.
[ https://github.com/monome/norns/issues/479 ]

Penlight is the one that has come up. but fnutils looks like a strong candidate and i like that Hammerspoon’s libs are so focused and modular (albeit many are osx-specific.) (i’m wary of kitchen-sink libraries hiding performance pitfalls.)

not that i know of. REPL integration is via websocket by way of nanomsg. it’s not hard to make a new client, but where i’ve stopped short of doing a “demo” of this is in actually replacing the maiden connections. (it’s a simple pair socket; maybe some more complex topology is needed.)

1 Like
#500

I’m not sure it is (?) - or At least I had to install manually on RasPi (as it might be new in the 2.0 build)

Also - I believe penlight is required for luarocks install - or maybe that was for ldoc? Apologies if I got that wrong

#501

Yeah, you’re right. It’s not installed by default. Whilst it does offer a lot of possibilities it also comes with some challenges like how to get those deps installed for scripts and possible performance issues.

1 Like
#502

you’re probably right.

penlight is needed for ldoc but not for luarocks afaik
(penlight is one of the modules in their test suite, so if you run tests you will get it)

1 Like
#503

random find - here’s a list of font’s available in 2.0:

fonts: 
  0: 04B_03__.TTF
  1: liquid.ttf
  2: Roboto-Thin.ttf
  3: Roboto-Light.ttf
  4: Roboto-Regular.ttf
  5: Roboto-Medium.ttf
  6: Roboto-Bold.ttf
  7: Roboto-Black.ttf
  8: Roboto-ThinItalic.ttf
  9: Roboto-LightItalic.ttf
  10: Roboto-Italic.ttf
  11: Roboto-MediumItalic.ttf
  12: Roboto-BoldItalic.ttf
  13: Roboto-BlackItalic.ttf
  14: VeraBd.ttf
  15: VeraBI.ttf
  16: VeraIt.ttf
  17: VeraMoBd.ttf
  18: VeraMoBI.ttf
  19: VeraMoIt.ttf
  20: VeraMono.ttf
  21: VeraSeBd.ttf
  22: VeraSe.ttf
  23: Vera.ttf
  24: bmp/tom-thumb.bdf
  25: bmp/creep.bdf
  26: bmp/ctrld-fixed-10b.bdf
  27: bmp/ctrld-fixed-10r.bdf
  28: bmp/ctrld-fixed-13b.bdf
  29: bmp/ctrld-fixed-13b-i.bdf
  30: bmp/ctrld-fixed-13r.bdf
  31: bmp/ctrld-fixed-13r-i.bdf
  32: bmp/ctrld-fixed-16b.bdf
  33: bmp/ctrld-fixed-16b-i.bdf
  34: bmp/ctrld-fixed-16r.bdf
  35: bmp/ctrld-fixed-16r-i.bdf
  36: bmp/scientifica-11.bdf
  37: bmp/scientificaBold-11.bdf
  38: bmp/scientificaItalic-11.bdf
  39: bmp/ter-u12b.bdf
  40: bmp/ter-u12n.bdf
  41: bmp/ter-u14b.bdf
  42: bmp/ter-u14n.bdf
  43: bmp/ter-u14v.bdf
  44: bmp/ter-u16b.bdf
  45: bmp/ter-u16n.bdf
  46: bmp/ter-u16v.bdf
  47: bmp/ter-u18b.bdf
  48: bmp/ter-u18n.bdf
  49: bmp/ter-u20b.bdf
  50: bmp/ter-u20n.bdf
  51: bmp/ter-u22b.bdf
  52: bmp/ter-u22n.bdf
  53: bmp/ter-u24b.bdf
  54: bmp/ter-u24n.bdf
  55: bmp/ter-u28b.bdf
  56: bmp/ter-u28n.bdf
  57: bmp/ter-u32b.bdf
  58: bmp/ter-u32n.bdf
  59: bmp/unscii-16-full.pcf
  60: bmp/unscii-16.pcf
  61: bmp/unscii-8-alt.pcf
  62: bmp/unscii-8-fantasy.pcf
  63: bmp/unscii-8-mcr.pcf
  64: bmp/unscii-8.pcf
  65: bmp/unscii-8-tall.pcf
  66: bmp/unscii-8-thin.pcf
3 Likes
#504

Hello everyone,

I’m a professional software dev but new to Lua, so please forgive me if I get any of the Lua specific terminology wrong. :slight_smile:

I’m trying to write a Lua library + sample host script to test it out. I’ve created the start of my lib and have my host script pulling it in, but when I make changes to the lib, the runtime doesn’t seem to see my changes. It feels like it’s not clearing out the Lua VM or something. Like when I used to do web dev and had to aggressively clear IE’s cache back in the day. Anyway, would love some help from other lib developers on a good workflow for doing this sort of thing.

Thanks!

PS. Super excited I finally broke down and bought Norns. Loving it so far!

#505

Use this format to include instead of require:

local libfile = dofile('/home/we/dust/code/FOLDER/lib/LIBFILE.lua')

1 Like
#506

i assume you’re using require. if so, you can either 1) unload your module manually (see below/above), or 2), my preference actually, use dofile() instead of require for your ‘user’ libraries (as opposed to system stuff that you won’t be changing.)

(use of require is a basically pointless optimization for this occasion.)

if you’re not using require then i’m not sure what’s hapenning and we gotta get to teh code


btw. this has come up on the threads before :slight_smile: i searched for “norns lua require cache”

1 Like
#507

Awesome! Thank you both!

#508

I don’t know that this is documented anywhere yet, but Norns 2.0 added a helper method called include, which can be used like mylib = include(“myscript/lib/mylib”) and takes care of cache clearing for you. It means writing simpler paths than dofile and doesn’t require the cache clearing of require.

I use require for built in Norns libraries that are on the path, like beatclock and musicutils.

#509

I have some projects where I’ve just added underscore to my own lib folder too, although in the long run adding to every Norns script would get a bit redundant.

https://mirven.github.io/underscore.lua/

#510

Assuming you want to use your own norns specific library (i.e. the library lives somewhere in ~/dust/code) use include().

See the docs for more info
https://monome.org/docs/norns/script-reference/#using-libraries

#511

include() first searches myscript/lib/* first, so it’s very helpful.


re: luarocks. there might be some modules that would be worth making available by default. it’s just that we need to consider each carefully. here’s the git issue (again): https://github.com/monome/norns/issues/479