So far, all of our lua code has been in luarc. That’s a good way to develop your script but not very practical for distribution. We need to make this into a proper lua module. To do that, we save the code in a separate file (scp-storage.lua
in this case):
Ansel will look for scripts (following the normal lua rules) in the standard directories plus $CONFIGDIR/lua/*.lua
. So our script can be called by simply adding require "scp-storage"
in the luarc file. A couple of extra notes…
The function
Ansel.configuration.check_version
will check compatibility for you. The “...
” will turn into your script’s name and{2,0,0}
is the API version you have tested your script with. You can add multiple API versions if you update your script for multiple versions of Ansel.Make sure to declare all your functions as
local
so as not to pollute the general namespace.Make sure you do not leave debug prints in your code –
Ansel.print_error
in particular allows you to leave debug prints in your final code without disturbing the console.You are free to choose any license for your script but scripts that are uploaded on Ansel’s website need to be GPLv2.
Once you have filled all the fields, checked your code, you can upload it to our script page here .