Import in HomeyScript

Is there way to import external functions in HomeyScript. I have some homey script functions that I want to be able to access in every other homey script so not sure how or if I can do that.

No, each Homeyscript runs in a “virtual machine context” that’s quite confined. So you need to copy&paste your code into each script.

Ok thanks!

I am somewhat surprised by the reply to this question. The answer answer itself, amounting to “you cannot write and import modules in HomeyScript” is correct, but the reasoning behind “why not” rings very wrong to me. There is nothing in the concept of an isolated “virtual machine context” that is violated by importing functions from a module. The reason it is not allowed in HomeyScript is simply that the people behind HomeyScript hasn’t opened for it. A request should be made because it would be very useful, as pointed out by @igorstefus

I’m not reasoning anything, I’m explaining how HomeyScript scripts are being run and how that doesn’t allow for external code to be imported. I’m not at all saying that such functionality wouldn’t be possible to implement.