Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    rom1504bot
    @rom1504bot
    <Link> I forgot it for that
    rom1504bot
    @rom1504bot
    <Link> I still get that
    <SMED> can i see all the code
    <WhoTho> yes
    <Link> Thanks for confirming
    <WhoTho> np
    <WhoTho> anytime
    <WhoTho> r u sure thats where the error is
    <Link> literally can't be anywhere else
    <Link> the error is at the if statement inside the second case
    <Link> the follow case
    <WhoTho> hmm
    rom1504bot
    @rom1504bot
    <Link> makes no sense because I already initialized the variable
    <Link> this is why I don't use switch case ffs
    <WhoTho> yeah try w if
    <Link> I wanted to use switch case cuz it looked nice but oh well
    <WhoTho> nah switch looks bad imo
    <WhoTho> if u didnt have to break i would consider using it
    <Link> the break statements are breaking me
    <Link> -10/10 joke ty ty
    rom1504bot
    @rom1504bot
    <natman99> 10/10 no takebacks it was amazing
    rom1504bot
    @rom1504bot

    <Pix3lPirat3> ```JS
    let createBot;
    let pathfinder, Movements;
    let mineflayer = {
    startClient: async function(options) {
    if(!createBot) createBot = require('mineflayer').createBot;
    if(!pathfinder) pathfinder = require('mineflayer-pathfinder').pathfinder;
    if(!Movements) Movements = require('mineflayer-pathfinder').Movements;

    
    Anyone know a way to compress this? I'm using this style of loading so the initial loadtime is faster (since startClient isn't called until a player launches a client)
    
    Just something to compress it, such as, but can't seem to figure out how to do it like:

    let { pathfinder, Movements } = require('mineflayer-pathfinder')
    ```

    <Pix3lPirat3> ```JS
    let createBot;
    let pathfinder, Movements;
    let mineflayer = {
    startClient: async function(options) {
    if(!createBot) createBot = require('mineflayer').createBot;
    if(!pathfinder) pathfinder = require('mineflayer-pathfinder').pathfinder;
    if(!Movements) Movements = require('mineflayer-pathfinder').Movements;
    
    Anyone know a way to compress this? I'm using this style of loading so the initial loadtime is faster (since startClient isn't called until a player launches a client)
    
    Just something to compress it, such as, but can't seem to figure out how to do it like:
    ```JS
    let { pathfinder, Movements } = require('mineflayer-pathfinder')

    <Pix3lPirat3> ```JS

    let createBot;
    let pathfinder, Movements;
    let mineflayer = {
    startClient: async function(options) {
    if(!createBot) createBot = require('mineflayer').createBot;
    let pathfinder_module = require('mineflayer-pathfinder');
    if(!pathfinder) pathfinder = pathfinder_module.pathfinder;
    if(!Movements) Movements = pathfinder_module.Movements;
    ````
    depending on the module this make may more sense..

    rom1504bot
    @rom1504bot
    <WhoTho> y r u doing all the if checks
    <WhoTho> y not just have one, to check if startClient has been called already
    <WhoTho> also (my preference), use const instead of let
    <WhoTho> just cuz those values (should) never change
    <WhoTho> =wait this setup is weird
    <WhoTho> nvm most of those should be let
    <Pix3lPirat3> startClient is called on the connect command, if --edition: bedrock is called it'll load bedrock-protocol stuff, otherwise by default mineflayer libs are loaded
    <Pix3lPirat3> If the user disconnects and runs the connect command again I shouldn't need to load most libs
    rom1504bot
    @rom1504bot
    <WhoTho> well
    <WhoTho> it doesnt load them again tho
    <Pix3lPirat3> but yea makes sense to only do 1 if check
    <Pix3lPirat3> I mean some things should be re-loaded, not all
    <Pix3lPirat3> pathfinder, Movements those won't need to be updated
    <Pix3lPirat3> other things like my commander system are called again
    <WhoTho> wait but im saying like doing require on the same file doesnt load it again
    <WhoTho> so its actually going to load faster the second time
    <WhoTho> yeah for that u should reload
    rom1504bot
    @rom1504bot
    <Pix3lPirat3> decreased page load time from 700ms to 500ms 🤷
    <Pix3lPirat3> another ~50ms by only loading "global" commands (Only load mineflayer commands when a bot is launched)
    rom1504bot
    @rom1504bot
    <WhoTho> yay and now with those extra 250ms u can cure cancer!! woooo!!!
    rom1504bot
    @rom1504bot
    <bonana> woo!
    <bonana> u can predict future now!
    rom1504bot
    @rom1504bot
    <natman99> I predict that the page will load