t-oster / LibLaserCut

a platform independant library to control Lasercutters. This is the base library for VisiCut
http://visicut.org
Other
60 stars 55 forks source link

Global utility functions (or alternatively ability to import other scripts) #210

Open TheAssassin opened 9 months ago

TheAssassin commented 9 months ago

Many laser scripts used by the various labs or in VisiCut's examples contain similar if not the same code all over again. For instance, drawing figures or characters inspired by a seven segment display (which I find relatively limited and will soon extend to a 14 or 16 segment one), a simple but useful focus gauge to include in other scripts, etc.

I would like to be able to define those functions once and then import the functionality into other scripts, either from a global utility script exposing functions into the global namespace or by explicitly importing script files (the latter allowing users to maintain their own scripts while also allowing them to import a global one).

There are so many advantages of such a scenario: not only will the copy-pasta between scripts end which often causes inconsistencies. When going for the import feature, one could recycle functionality from a script in another one or add different "frontends", e.g., one asking prompts, the other one using some quick defaults.

What do you think?