• 1

    posted a message on Macro / Keybind Mod

    Wondering if anyone knows how to make attack stay pressed. e.g. key own(forward), however, this does not work with keydown(attack). my problem is coming from doing key(attack) occurs too little in a period of time and it is not fast enough. Help would be greatly appreciated, Thanks :)





    This post explains the reasons behind the different types of bindings and how to use them

    Stateful vs trigger vs momentary bindings

    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod
    Quote from nbird»

    Wait, UNSET also works for other variables then boolean flags?

    Thanks, thats good to know, but I am still a bit confused why local variables are globaly saved in a file and even survive a computer restart.


    Because if you need a fresh var you can always clear them, but not vice versa - if they didn't persist there'd be no way to make them persist

    Posted in: Minecraft Mods
  • 2

    posted a message on Macro / Keybind Mod
    Quote from nbird»

    Is it possible to delete local variables after a script is run?


    I had run some scripts set local variables e.g. #m, &m, &m[] and after stopping all scripts or even restarting minecraft,

    if I check the variables its still filled with the same values - and no its not global variables.


    This is a problem especially with arrays.

    At one point a array is filled with 10 different values (index 0-9). If I want to use this variable name again, I first have to empty the array by hand with POP(), otherwise if I only put 4 values (index 0-3) into the array it would still iteraote over 10 values, because the old ones are still there, too.


    Is there some setting I am missing or some command doing something like &m[]=NULL (this specific doesn't work) or &m[] = new Array() or only &m[]; to get a completly new/empty array?


    You can clear an array easily with `Unset(&myarray[])`
    If that didn't exist you could still do something like `#n = ArraySize(&myarray[]);DO(%#n%);POP(&myarray[]);LOOP;`

    Posted in: Minecraft Mods
  • 2

    posted a message on Macro / Keybind Mod

    The other thing i suspect is that you have spaces after the commas - i remember at least some commands choking on them (they treat the space as part of the input)

    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod
    Quote from nbird»

    Is it possible that GETSLOT() and GETSLOTITEM() are bugged in the newest version (0.15.4)?


    I got very basic code, but both functions won't assign anything to the variables.


    ${
    
    GUI("inventory");
    
    FOR(#invslot, 9, 35);
    		GETSLOTITEM(%#invslot%, &invidvar, #invstacksize);
    		WAIT(10ms);
    		LOG(%#invslot% %&invidvar% %#invstacksize%);
    NEXT;
    
    }$


    Output: 9 0

    Expected Output: 9 reeds 64


    Tested lots of variation, but I can only get item name and not the stacksize if I write:

    &invidvar = GETSLOTITEM(%#invslot%);


    Can anyone help what I am doing wrong or if it is really bugged.

    Thanks.


    You may need to wait for the GUI to open using `DO;UNTIL(GUI=="GUIINVENTORY")` (Double check what the correct inventory name is)

    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod

    Hey guys, sorry if this has been answered but I got a question.

    Is there any way to make my scripts run as soon as I join a server/world? Like right when I join the scripts start themselves?


    sounds like the onJoinGame event - or is there some problem with that?


    Events found by either clicking the yellow arrows on the top to switch tabs, or selecting one from the 'file' menu in the corner

    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod
    Quote from user-100090318»

    I dont want to get the name to an id. I want to get the name of an item. For Example: if I rename a stack of Cobblestone in an Anvil with "TEST" I get using log(%ITEMNAME%); "TEST" as a response even if its Cobblestone but if I use getslotitem(%&idofitem%,&name); I get the minecraft-name to an id.


    So what I am searching for is a way to get the display-name (%ITEMNAME% for the display-name of the item in my hands) of an item if I am in my inventory and want to check a specific slot.



    hm - i don't think there's any commands for that - with vanilla you'll have to move the item to your hotbar and select it i suppose

    Probably very complicated, but if this is critical you could install spthiel's "Not enough information" module which adds a fifth parameter to GetSlotItem that returns the nbt data
    Then you'll need to somehow extract the name from that (i believe it gives you a json string)


    Edit: See post below

    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod
    Quote from MatthewTheWeeb»

    How do you get constant negative pitch values for the look command? Using minus just makes the pitch relative.


    add 360 to it

    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod
    Quote from user-100090318»

    Hey,


    Does anybody know how to compare 2 Itemnames with each other? I mean the actual name not the ids. I know that you can get the Intemname of the item in your hand with log(%ITEMNAME%); but how do I do this with items I dont have in my hands?


    I hope you guys know what I mean ^^



    Given an ID, you can get a bunch of details using:

    GETITEMINFO(<item[:damage]>,[&namevar],[#maxstacksize],[&type],[&dropid])


    //For example

    &id = GetSlotItem(9)
    GetItemInfo(%&id%,&name);
    Log("Slot 9 of your inventory contains %&name%")

    Posted in: Minecraft Mods
  • 1

    posted a message on Macro / Keybind Mod

    nah

    Posted in: Minecraft Mods
  • 2

    posted a message on Macro / Keybind Mod
    Quote from MatthewTheWeeb»

    Height shouldn't matter except for the single block jumps, so just x and z is probably fine.





    Alright, i've removed the extra bits and added comments for everything, i hope this version is a bit clearer


    Lines starting with // are comments - meaning nothing would change if they were removed (the mod ignores those lines), they're simply there for explanation


    Edit: Wanted to at least highlight the comments but can't get the forums to cooperate

    //
    // Configuration
    //
    
    // How close we need to get to the target
    #threshold = 0
    
    //
    // Waypoints
    //
    // Reset the array so that the list doesn't get bigger every time the script is run
    UnSet(#walkx[])
    UnSet(#walkz[])
    
    // Add one coordinate
    #walkx[] = 10
    #walkz[] = 10
    
    // Add another coordinate
    #walkx[] = 10
    #walkz[] = 0
    
    //
    // Code
    //
    
    // A common snippet used to make a script toggleable (let me know if you want an explanation of this)
    TOGGLE;IF;Log("Stopped");Keyup(jump);Keyup(forward);STOP;ENDIF;
    
    // How many total coordinates do we have?
    #size = ArraySize(#walkx[])
    #size = #size - 1
    // For each waypoint
    FOR(#i = 0 to %#size%)
        // Copy the coordinates to shorter variables for convenience
        #x = #walkx[%#i%]
        #y = #walky[%#i%]
        #z = #walkz[%#i%]
    
    
        // Start walking
        keydown(forward)
    
        // Repeat this part until we reach the waypoint
        // This part handles looking towards the coordinate and jumping if necessary
        DO()
            // Look towards the waypoint on the x-z plane
            calcyawto(%#x%,%#z%,#yaw,#dist);
            inc(#yaw,180); // Fix because minecraft yaw is 180 degrees off
            look(%#yaw%,+0); // +0 means do not affect pitch (you can still control pitch with the mouse then)
    
    
    
            // ↓ Jump if blocks in the way
            // Depending on which 90 degree angle you're looking towards, this will only check the three blocks that are in that sector
            // sig_x - Whether we're looking more towards positive x or negative x
            // sig_z - Same but for z
            #sig_x = 1;
            #sig_z = 1;
            IF(YAW < 180); #sig_x = -1; ENDIF
            IF((90 < YAW) && (YAW < 270)); #sig_z = -1; ENDIF
    
            // Block along x axis, along y axis, and on the diagonal
            &block_1 = GETIDREL(%#sig_x%,0,0)
            &block_2 = GETIDREL(%#sig_x%,0,%#sig_z%)
            &block_3 = GETIDREL(0,0,%#sig_z%)
    
            // If all are air, do not jump, else jump
            IFMATCHES("%&block_1%,%&block_2%,%&block_3%","air,air,air");
                Keyup(jump)
            ELSE;
                Keydown(jump);
            ENDIF;
            // ↑ end
    
    
    
            // ↓ Expose global variables
            // Not important for the script, but might be handy if you want to make a GUI to show progress or something
            @#walker_yaw = %#yaw%
            @#walker_pitch = %#pitch%
            @#walker_target_x = %#x%
            @#walker_target_y = %#y%
            @#walker_target_z = %#z%
            @#walker_distance = %#dist%
            // ↑ end
    
        While(#threshold < #dist);
        // Done walking to waypoint
        Keyup(forward)
    NEXT;
    // Done walking to all waypoints
    Posted in: Minecraft Mods
  • 1

    posted a message on Macro / Keybind Mod
    Quote from MatthewTheWeeb»

    Alright, I've tried it out and I have a question. How do you input several coordinates to travel to after one another? For example, first coordinate 1, then 2, then 3 etc. Also, let me specify what I want the script to do more specifically so you have a better idea of what I'm trying to do; I want to set up a loop for the character, where it walks from coordinate to coordinate, eventually returning to the start position and then repeating the loop. At every coordinate inputted, the character will left click once, wait 5 seconds and continue toward the next coordinate and repeating the action. The code might look something like this (very simplified and unprofessional):
    1. Go to coordinate 1
    2. Left click

    3. Wait 5 sec

    4. Go to coordinate 2

    5. Left click

    6. Wait 5 sec

    7. Go to coordinate 3

    8. Left click

    9. Wait 5 sec
    10. Repeat

    In practice, more coordinates would be needed, forming a kind of circle, but I believe this demonstrates my idea adequately. This is probably what your script does with a couple more steps added, but I think I might need an explanation of how to work it and input the variables as I'm not exactly experienced in coding... Sorry if this is too much to ask. I do think I could make something workable after hours of trial and error, but I figured it's probably easier and less time consuming if you just explain how it works. :P

    Again, thanks so much for responding and giving me a script almost immediately. I am as stated previously, eternally grateful.


    This example already has two coordinates right at the start there, 10,10 and 10,0
    Let me remove the extra stuff and leave only the script and commends, hopefully it'll make more sense then

    edit: A lot of the complexity comes from the fact that i tried to combine 2d and 3d logic
    Do you want height to matter? or only the x and z?

    Posted in: Minecraft Mods
  • 1

    posted a message on Macro / Keybind Mod
    Quote from MatthewTheWeeb»

    I want it to walk to a specific inputted coordinate, then walk to a chain of different specific coordinates. Ideally also able to jump over singular blocks. That's it.


    Turns out i already had something like that - had to tweak it a bit but this should get you started

    (The entire thing goes in a file, it looks like markdown with code snippets (well, it is), but it works just fine for the mod too because it ignores all the lines it doesn't understand)

    # Waypoint walker script
    
    ## Configuration
    
    ```mkb
    &logtarget = "Debug"
    #threshold = 0
    use_y = false
    ```
    
    ## Waypoints
    
    ```mkb
    UnSet(#walkx[])
    UnSet(#walky[])
    UnSet(#walkz[])
    
    #walkx[] = 10
    #walky[] = 4
    #walkz[] = 10
    
    #walkx[] = 10
    #walky[] = 6
    #walkz[] = 0
    ```
    
    Note: The following global variables are exposed (you can use these in a GUI for example)  
    The current waypoint we're walking towards: `@#walker_target_x` `@#walker_target_y` `@#walker_target_z`  
    The distance to that waypoint: `@#walker_distance`
    
    ## Code
    
    ```mkb
    TOGGLE;
    IF;LogTo("%&logtarget%","Stopped");Keyup(jump);Keyup(forward);STOP;ENDIF;
    
    #size = ArraySize(#walkx[])
    #size = #size - 1
    FOR(#i = 0 to %#size%)
        logTo("%&logtarget%","%#i%")
        #x = #walkx[%#i%]
        #y = #walky[%#i%]
        #z = #walkz[%#i%]
    
    
        keydown(forward)
        DO()
            // ---------------- CALCULATE DIRECTION TO LOOK IN ----------------
            // Get direction and distance on the horizontal plane
            calcyawto(%#x%,%#z%,#yaw,#dist);
            inc(#yaw,180); // coordinate transformation
    
            // Get direction and distance on a vertical plane
            // Get position relative to head
            #deltay = #y - YPOS + 2; //+2 for player correction
            #deltaz = #dist
    
            //// NOV16: I suspect this doesn't actually add precision
            // *100 for increased precision
            #deltay = #deltay * 100
            #deltaz = #deltaz * 100
            IF(!use_y) #deltay = 0
    
            // Offset from current position
            #vx = XPOS+#deltay
            #vz = ZPOS+#deltaz
    
            // Get pitch
            CalcYawTo(%#vx%,%#vz%,#pitch,#dist_3d)
    
            // Look in direction
            IF(use_y)
                look(%#yaw%,%#pitch%)
            ELSE 
                look(%#yaw%,+0)
            ENDIF
    
            // Jump if suspect blocks in the way
            #sig_x = 1;
            #sig_z = 1;
            IF(YAW < 180); #sig_x = -1; ENDIF
            IF((90 < YAW) && (YAW < 270)); #sig_z = -1; ENDIF
            &block_1 = GETIDREL(%#sig_x%,0,0)
            &block_2 = GETIDREL(%#sig_x%,0,%#sig_z%)
            &block_3 = GETIDREL(0,0,%#sig_z%)
            IFMATCHES("%&block_1%,%&block_2%,%&block_3%","air,air,air");
                Keyup(jump)
            ELSE;
                Keydown(jump);
            ENDIF;
    
    
            // expose global variables
            @#walker_yaw = %#yaw%
            @#walker_pitch = %#pitch%
            @#walker_target_x = %#x%
            @#walker_target_y = %#y%
            @#walker_target_z = %#z%
            IF(use_y)
                @#walker_distance = %#dist_3d%
            ELSE
                @#walker_distance = %#dist%
            ENDIF
            // ---------------- CHECK IF TARGET REACHED ----------------
        While((#threshold < #dist_3d) && (use_y || (#threshold < #dist)));
        Keyup(forward)
    NEXT;
    ```
    Posted in: Minecraft Mods
  • 0

    posted a message on Macro / Keybind Mod
    Quote from MatthewTheWeeb»

    Is there any way to make a script to look in the direction of a coordinate and walk to that position then do the same for a chain of different coordinates using GETID and CALCYAWTO? If anyone could make me a script that does this and tell me how to input custom x and z values I'd be eternally grateful.


    Well the core of it is just Look(pitch,yaw) and Keydown(forward)
    But depending on how smart you want it to be it can be anything from easy to practically impossible
    Consider for example the following potential obstacles

    Difficult
    Hostile players
    Mobs
    Fatal drops (holes in the ground - ravines)
    Unavoidable drops (steep mountain side)
    Unavoidable pillaring (steep mountain side again)
    Doors
    Unavoidable mining (coordinates accidentally happen to be inside a mountain or w\e)

    Potentially doable:
    Turns (A house is in the way, have to go around it)

    Doable:
    Jumps: (The terrain gradually changes height, have to jump up 1 block ledges)


    So it all depends on the context of what you want this for

    Posted in: Minecraft Mods
  • 1

    posted a message on Macro / Keybind Mod
    Quote from LiftedRici»

    Hey, i hope someone can help me with my macro. I tried for days now, but it doesn't work.
    First i will tell you what i want to achieve.
    So i want a macro that will start sprinting forward and start mining cobble until the inventory is full. After that, the account should drop the cobblestone out of the inventory and repeat running/mining and dropping without pressing the macro key again it should work afk.
    Here is what i got so far. I got 3 scripts that contain:


    run.txt
    $${keydown(sprint);keydown(forward);}$$

    attack.txt

    $${TOGGLE(autoclick);DO;KEY(attack);WHILE(autoclick)}$$


    drop.txt

    $${GUI(inventory);FOR(#s,9,35);GETSLOTITEM(%#s%,#i);IF(#i=Cobblestone);SLOTCLICK(%#s%);SLOTCLICK(-999);ENDIF;NEXT;GUI}$$


    Now i bind it to a key with:
    $${$$<run.txt>}$$ $${$$<attack.txt>}$$ $${wait(50ms)}$$ $${$$<attack.txt>}$$


    Like this it will run and start attacking. I have attack doubled because after i open the inventory with the drop.txt the account need to press the attack button again. I got no solution for the drop.txt that it triggers when the inventory is full. And overall this is a really bad solution i think.

    I hope you can help me to get a working script because im to bad to get it right :)





    It might be easier to start with the entire script in one file, because that's how the mod eventually runs the code - just like it was copy pasted together

    Figure out a basic high level overview, because you can only do one thing at a time
    I'm guessing it should go something like



    Once you have the high level idea of what you want to make, start making and testing it in individual pieces

    For example, try to just get it to run first

    Then to run and mine


    Then in a separate script try to figure out how to detect if the inventory is full

    Then combine them


    Then in a separate script try to figure out how to drop all the items in your inv

    Then combine them

    Posted in: Minecraft Mods
  • To post a comment, please or register a new account.