Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Invoking variables or functions from external .js script file

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:

  • Which way would be most optimal and expandable for this purpose in JavaScript?
  • What are the limitations?
  • Can I make it all into libraries?
  • If yes, then how?

Friend said he would make it into lua and read each code with loader.

Thanks for help, regards.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!