Back to square one: "startup"scripting with LUA?

How do I make it so that whenever Renoise is loaded, a specific script function is started?

Or whenever a sample is loaded, a specific function is started?