random_script

random_script

This is a mod script for the Monome Norns, adding a random script combo to the script selection page.

Press k1 + k3 on the SELECT page to randomize the script selection.

Behind the scenes

For anybody interested, this approach can be used to add on top of any existing Norns functions. The limit, as far as I can tell, is that the new code must run either before or after the existing code. If there’s a better way to do this, though, please let me know.

Here, that mattered because I couldn’t quickly figure out how to prevent the normal k3 action (opening the script) from happening. As a result, I ended up wrapping the existing function, calling it after the mod checks whether it should run. So the simplified structure is like this:

-- reassign the original function 
local f = original_function
-- overwrite the function with the wrapper + original
original_function = function(n,z)
  if n == 3 and alt then
    -- my mod action
    do_stuff()
  else
    -- the original function
    f(n,z)
  end
end

If you don’t have that complication, you can also do this sort of mod a little more cleanly:

-- define mod behavior
local do_stuff = function(n,z)
  if n == 3 and alt then
    mod_stuff()
  end
end

-- reassign the original function 
local f = original_function

-- overwrite the function and call both
original_function = function(n,z) do_stuff(n,z) f(n,z) end

Requirements

Norns running 210927 or later

Download

Install

In maiden, run:

;install https://github.com/stvnrlly/random_script.git

As a mod, you’ll then need to do some extra stuff to enable it :

to enable a mod go to SYSTEM > MODS to see the list of installed mods. mods which are loaded will have a small dot to the left of their name. use E2 to selected an item in the list and then use E3 to enable or disable as appropriate. unloaded mods will show a + to the right their name to indicate that they will be enabled (and thus loaded) on restart. loaded mods will show a - to the right of their name indicating they will be disabled on restart.

16 Likes