Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda