CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    (Request) Chest script help

    Requests
    2
    7
    277
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Hookie last edited by

      if (mc.currentScreen instanceof GuiContainer && mc.thePlayer.openContainer.getLowerChestInventory().getDisplayName().getUnformattedText().contains("Chest")) {

      		for (i = 27; i < 65; i++) 
      		{
      			
      		mc.playerController.windowClick(mc.thePlayer.inventoryContainer.windowId, i, 0, 1, mc.thePlayer) 
      

      Above is my code

      Essentially, what it does is move items from inventory to chest. I'm new to scripting this stuff is very complex to understand.
      Problems:

      1. When item is moved from inventory to chest it just appears back in inventory (im thinking problem is mode in windowclick but not sure, what other mode to use)

      2. Adding a delay for statement, make it so each item move at a delay

      if anyone can help me it'll be wonderful i've been struggling for hours.

      H 1 Reply Last reply Reply Quote 0
      • H
        Hookie @Hookie last edited by

        I use core lib

        CzechHek 1 Reply Last reply Reply Quote 0
        • CzechHek
          CzechHek @Hookie last edited by CzechHek

          @hookie Since noone replied, I'll help you.

          Lets start with the simple one, the delay.

          You can create a MSTimer instance and check if .hasTimePassed(delay)

          ///api_version=2
          (script = registerScript({
              name: "Script",
              authors: ["Author"],
              version: "1.0"
          })).import("Core.lib");
          
          module = {
              onUpdate: function () {
                  if (timer.hasTimePassed(1000)) {
                      dosomething();
                      timer.reset();
                  }
              }
          }
          
          timer = new MSTimer();
          

          For inventory interactions, you should debug what original packet sends and then try to replicate it.

              onPacket: function (e) {
                  if (e.getPacket() instanceof C0EPacketClickWindow) {
                      p = e.getPacket();
                      print(p.getMode(), p.getSlotId(), p.getUsedButton());
                  }
              }
          
          H 2 Replies Last reply Reply Quote 1
          • H
            Hookie @CzechHek last edited by

            @czechhek
            i'm very grateful bro, the packet debug has been very convenient to me and timer you've made it very explicable you've been a big help but one problem remains.

            In this video i've set the script to move the last slot in inventory into the chest and remain there but for some reason it doesn't stay there

            I use (mc.thePlayer.inventoryContainer.windowId for window id, slot 64 for last slot in inventory, left mouse click 0, and mode 1, mc.thePlayer)

            https://www.youtube.com/watch?v=wc4cekS--AI

            1 Reply Last reply Reply Quote 0
            • H
              Hookie @CzechHek last edited by

              @czechhek
              i can only move stuff out of chest but not into chest

              CzechHek 1 Reply Last reply Reply Quote 0
              • CzechHek
                CzechHek @Hookie last edited by

                @hookie If you send completely same packets, there is no way that it won't work.

                H 1 Reply Last reply Reply Quote 0
                • H
                  Hookie @CzechHek last edited by Hookie

                  @czechhek

                  I just found out it's because it was using the wrong window id, thank you for being there when i needed you, appreciate it brother.

                  mc.thePlayer.openContainer.windowId is correct one

                  not
                  mc.thePlayer.inventoryContainer.windowId

                  1 Reply Last reply Reply Quote 2
                  • First post
                    Last post
                  About
                  • Terms of Service
                  • Privacy Policy
                  • Status
                  • Contact Us
                  Downloads
                  • Releases
                  • Source code
                  • License
                  Docs
                  • Tutorials
                  • CustomHUD
                  • AutoSettings
                  • ScriptAPI
                  Community
                  • Forum
                  • Guilded
                  • YouTube
                  • Twitter
                  • D.Tube