My tool has a certain state (set of variables), and I like to save this set of variables as presets, as for example the Epic Arpeggiator did
Aha, OK yes - now I get it.
For simple tools that have a fixed set of preferences you can simply instantiate the renoise.tool().preferences.
Lookie here:
https://github.com/renoise/xrnx/blob/master/Documentation/Renoise.ScriptingTool.API.lua#L336
What it’s doing, technically, is to create an instance ofrenoise.Document.DocumentNode, which is associated with the tool and automatically loaded on startup. Also, any values that change are automatically saved to the document (not immediately, but as the tool or Renoise is unloaded).
When/if you need more complex stuff I would suggest looking into extending therenoise.Document.DocumentNode as a class, or possibly, invent your own solution.
Here is an example tool I did for Raul which (among other things) implements the renoise prefs as a class. Could be used as a starting point?
https://forum.renoise.com/t/solved-help-create-an-area-with-vertical-scrollbar-with-buttons-in/47059