Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

LiquidBounce Forum

Alt Account 0A

Alt Account 0

@Alt Account 0
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Unsure how to fix script issue
    Alt Account 0A Alt Account 0

    Hello, my goal is to detect if an item is a fish within a certain server then deposit it automatically into whatever the current open container is. Fish detection works fine, the only issue with my code is moving it to the container (for example an open single chest). Currently what happens is the fish is attempted to be moved into the chest but it continuously gets sent back and just doesn't work.

    /// api_version=2
    
    var ENABLED = false;
    var DEBUG   = false;
    
    
    function Log(message) {
        if (DEBUG)
            Chat.print(message);
    }
    
    var script = registerScript({
        name: "AutoFishSave",
        version: "1.0.0",
        authors: [""]
    });
    
    script.registerModule({
        name: "AutoFishSave",
        category: "Misc", 
        description: "Automatically deposit fish into your open storage."
    }, function (module) {
        module.on("enable", function() {
            ENABLED = true;
        });
    
        module.on("disable", function() {
            ENABLED = false;
        });
    
        module.on("update", function() {
            if (ENABLED) {
                Log("Initial execution.")
    
                var Inventory = mc.thePlayer.inventory.mainInventory;
        
                Log("Inventory found, length is " + Inventory.length + ".")
        
                for (var Idx = 0; Idx < Inventory.length; Idx++) {
                    Log("Iterating through inventory, index is " + Idx + ".")
        
                    var Item = Inventory[Idx];
        
                    if (Item == null)
                        continue;
        
                    Log("Item found.")
        
                    var ToolTipData = Item.getTooltip(mc.thePlayer, true);
        
                    if (ToolTipData == null)
                        continue;
        
                    Log("Tooltip data found, length is " + ToolTipData.length + ".")
        
                    var IsFish = false; // for debugging set to true;
                    
                    for (var SubIdx = 0; SubIdx < ToolTipData.length; SubIdx++) {
                        var TTLine = ToolTipData[SubIdx];
        
                        if (TTLine.contains("fish") && !TTLine.contains("rod")) {
                            IsFish = true;
                            break;
                        }
                    }
        
                    Log("IsFish is " + IsFish + ".")
        
                    if (!IsFish)
                        continue;
    
                    var CurrentOpenContainer = mc.thePlayer.openContainer;
    
                    if (CurrentOpenContainer == null || CurrentOpenContainer.windowId == 0)
                        continue;
                
                    Log("Suitable container found.")
    
                    mc.playerController.windowClick(
                        CurrentOpenContainer.windowId, 
                        Idx,
                        0, 
                        2, 
                        mc.thePlayer
                    );
    
                    Log("Moved fish to storage.")
                }
            }
        });
    });
    
    ScriptAPI
  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups