This project generates Luanalysis Type Definitions for the HaasScript Language so code editors can autocomplete and type check your scripts. If you do not want to run the project, you can simply download the zip files of the output here: https://github.com/FiretronP75/HaasScriptLuaTypes/releases
- Most people should use production definitions.
- You do not want staging definitions unless you test on the Haas Cloud staging server.
- Only use 1 of the 4 zip files of lua definitions, or Luanalysis will error about duplicates.
- Install IntelliJ IDEA Community Edition or PyCharm Community from JetBrains. They are free. Or use any paid JetBrains product.
- In the settings, install the Luanalysis plugin.
- Open a folder containing your haas scripts.
- Copy the (unzipped) lua definitions into the same folder or a sub folder. Use only one of the zip files.
- The Luanalysis plugin should pick them up automatically. You will now see code hints and type errors in your scripts.
- If the JetBrains code editor freezes, force kill and increase its memory limit in its settings in JetBrains Toolbox.
Normally, JetBrains products will alert you that you need to give it more memory. But it seems to not be able to track memory used by Luanalysis.
- Clone the git repository.
- Install Node 16 or greater.
- Install Yarn.
- Open a terminal in the project root.
- Run
yarn
. - Run
yarn start
. - Read and follow the help output in the console (pasted here for convenience):
- This script requires 5 parameters: environment, file extension, flexible numbers, interface key, user id.
- Environment may be "production" or "staging". Anything other than "staging" (case-insensitive) assumes "production".
- File extension may be anything, but "lua" or "hs" is recommended.
- Flexible numbers may be "flex-num" or "not-flex-num". Anything other than "flex-num" (case-insensitive) assumes "not-flex-num".
- Interface key and user id can be copied from a web browser session that has not expired yet.
- Example:
yarn start prod lua flex-num 30w3jrv4pa-fj209-qj0934-295cn-qv9r0cev fm02q9rf0q2fqr2cv98r4v8q9tv8rq48
Many of the number parameters of functions can also take a list of numbers.
But it is not clear which do and which do not.
Using "not-flex-num" keeps them all as number
.
This will give errors when you assign a list of numbers, even though it might be valid.
Using "flex-num" changes them all to number | number[]
.
This will not error when you assign a list of numbers, even though it might be invalid.
I'm not sure which is better or worse. So you have to decide for yourself which you prefer.
- Open Haas cloud server in your browser.
- Hard refresh with ctrl+F5 to ensure you have the latest version.
- Open your browser's developer tools.
- Select the Network tab of the developer tools.
- Clear any filters on the network transactions list.
- In Haas cloud server, open the Web Editor. (or reload the page if the Web Editor is already open)
- In Haas cloud server, open any one of your saved scripts.
- In the Network tab of your browser's developer tools, filter on "command".
- Click on the only remaining network transaction.
- Select the Payload tab of the network details.
- Your
interfacekey
anduserid
should be in the Payload panel. - Right click on each and choose "Copy value".
- Note that they will expire when logged out.
- Note that they are different in production and staging.
- If you need staging definitions, do these steps again on the staging server.