kolton / d2bot-with-kolbot

d2bot game manager by D3STROY3R with kolbot libs by kolton for d2bs
346 stars 332 forks source link

Can you pass variables between files? #2961

Open croboy opened 3 years ago

croboy commented 3 years ago

I have a variable in one of my bots and I need my D2botlead to see whether it is true or false. Anyone know how to share variables between 2 files in kolbot?

croboy commented 3 years ago

Ok so someone told me to add the variable in config.js, but can i edit the value in config.js through another script??

Butterz51 commented 3 years ago

you would add that command to your character config also that's where you would change the values.

Example:

(My Custom) Tombs.js (d2bs\kolbot\libs\bots) if (Config.Tombs.PortalLeech) {{ Pather.makePortal(); say(Config.Tombs.TPMessage); delay(10000); Precast.doPrecast(true); delay(100); }

Config.js (d2bs\kolbot\libs\common) Tombs: { PortalLeech: false, TPMessage: "The tomb TP is up! You have 10 seconds till I cast BO" },

Select your character config (d2bs\kolbot\libs\config) Scripts.Tombs = false; Config.Tombs.PortalLeech = false; // Set to true to open a portal for leechers. When set to true will auto-clear the Tombs. Config.Tombs.TPMessage = "The tomb TP is up! You have 10 seconds till I cast BO";

I hope this explains what you have to do good luck.

croboy commented 3 years ago

you would add that command to your character config also that's where you would change the values.

Example:

(My Custom) Tombs.js (d2bs\kolbot\libs\bots) if (Config.Tombs.PortalLeech) {{ Pather.makePortal(); say(Config.Tombs.TPMessage); delay(10000); Precast.doPrecast(true); delay(100); }

Config.js (d2bs\kolbot\libs\common) Tombs: { PortalLeech: false, TPMessage: "The tomb TP is up! You have 10 seconds till I cast BO" },

Select your character config (d2bs\kolbot\libs\config) Scripts.Tombs = false; Config.Tombs.PortalLeech = false; // Set to true to open a portal for leechers. When set to true will auto-clear the Tombs. Config.Tombs.TPMessage = "The tomb TP is up! You have 10 seconds till I cast BO";

I hope this explains what you have to do good luck.

Thanks heaps for replying. I managed to get it working through another method.

I needed the bot to talk to D2botlead while running a script in-game, to determine whether to create the next game or join the next game. So what I did was I added this to my bot script: DataFile.updateStats("variable", "true"); So it changes the value "variable to true in your players profilename.json

Then in D2botlead in Case 5 join section, I added:

if (DataFile.getStats().variable === "true") { //Click to x,y etc to join game }

So if it's true it will join game rather than create next game