I'm working on Macros that suppose to execute various code bits for each 'if' statement.
For example
if (event.text.getString().includes(N1 + G1 + S1))
JsMacros.runScript("AUDIO1.js")
This bit of code executes AUDIO1.js script. (Ignore 'if' variables)
But my problem is that instead of executing dozens separate .js scripts that each contains few lines of code,
I'd rather group all similar codes into one .js script, and load one file, executing codes by bit.
For example, here are some sample scripts I'm running with this method, but every code is separate .js file, which is bad.
Code snippet #1:
Client.waitTick(5)
Chat.title("Baritone 2", "Mining Diamonds...", 15, 22, 66)
Chat.say(".b mine diamond_ore deepslate_diamond_ore")
Code snippet #2:
Client.waitTick(5)
Chat.title("Baritone 2", "Mining Iron / Coal...", 15, 22, 66)
Chat.say(".b mine iron_ore deepslate_iron_ore coal_ore deepslate_coal_ore")
etc.
I'm stuck between giving each bit its function, to later invoke them easier, but some people also recommended to me switch blocks, custom events, and other methods as well.
My point is to reduce file quantity to minimum, preferably one for each themed code group, one for if triggers and so on.
That would require invoking codes bit by bit, and being able to do so between different .js files.
Kinda like libraries for Arduino, containing all required vars, consts, strings and functions for each sensor module and adding them into main code is as simple as include #libname.
Questions are:
Friend said he would make it into lua and read each code with loader.
Thanks for help, regards.