PMC - Pi's Macro Collection

Discussion in 'Basic Tutorials' started by 314, Sep 5, 2015.

  1. 314

    314 Irrational Moderator, former ServerAdmin
    SuperMod EcoLegend ⛰️⛰️⛰️⛰️ Ex-President ⚒️⚒️ Prestige ⭐ VI ⭐ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    7,046
    Trophy Points:
    97,160
    EcoDollars:
    $1,400,000
    Ratings:
    +4,917
  2. i8ablu

    i8ablu Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️ Premium Upgrade

    Joined:
    Dec 4, 2012
    Messages:
    98
    Trophy Points:
    35,740
    Ratings:
    +48
    @314
    I wasn't able to get the chat stats to work, so I did some digging.

    I traced it down to the STRIP command, on line 82 in PMC_Stats.txt.

    Simply change STRIP(%CHAT%,&chat) to STRIP(&chat,%CHAT%) Reference
     
  3. i8ablu

    i8ablu Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️ Premium Upgrade

    Joined:
    Dec 4, 2012
    Messages:
    98
    Trophy Points:
    35,740
    Ratings:
    +48
    Also, anyone know how to run a .command? For example .tool

    If I just put it in as a macro, or even with ECHO, it just says it in chat, bypassing any Macro Mod filtering.

    For now, I just use
    Code:
    $${
     
        TOGGLE(@pmctoolswitch)
     
        IF(@pmctoolswitch)
            LOG("&2&l[&a&lPMC: ToolSwitch&2&l]&6 ToolSwitch-Macro &aenabled&6.")
        ELSE
            LOG("&2&l[&a&lPMC: ToolSwitch&2&l]&6 ToolSwitch-Macro &cdisabled&6.")
        ENDIF
     
    }$$
    , taken from the top of PMC_Internal_ToolSwitch.txt, for anyone else wanting to toggle auto switch with a macro.
     
    #63 i8ablu, Dec 1, 2015
    Last edited: Dec 1, 2015
  4. 314

    314 Irrational Moderator, former ServerAdmin
    SuperMod EcoLegend ⛰️⛰️⛰️⛰️ Ex-President ⚒️⚒️ Prestige ⭐ VI ⭐ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    7,046
    Trophy Points:
    97,160
    EcoDollars:
    $1,400,000
    Ratings:
    +4,917
    Thanks, works now - I must have messed that one up during the PMC redesign.

    The wiki (https://github.com/ECC314/PMC/wiki/ToolSwitcher) lists
    Code:
    $${TOGGLE(@pmctoolswitch)}$$
    , but the fancier way would be what you posted, which I ue as a keybind for Z (or Y on non German keyboards).

    Reason why ECHO() does not work: ECHO is not affected by FILTER() or OnSendChatMessage, it seems. This causes ".tool" to be sent to the server without the macro mod filtering it. I might add code snippets to the README.txt which would allow for a copy-and-paste toggle feature to be inserted in other players' macros.


    //Github download updated.
     
  5. i8ablu

    i8ablu Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️ Premium Upgrade

    Joined:
    Dec 4, 2012
    Messages:
    98
    Trophy Points:
    35,740
    Ratings:
    +48
    Good to know, hopefully they'll add support for .commands at some point.

    I made a quick script to automatically collect available kits, cause why not.
    All you have to do is type /kit (Or bind a key with $${ECHO(/kit)}$$, and it will collect any available kits, as well as run again, every 61 minutes, until you either relog, or force close the onChat macro, via the topleft of the screen, when you press ~

    Add this code in a .txt and apply it to the onChat event. Make sure you add it at the end, otherwise anything after it won't run for another 61 minutes!
    Code:
    $${
    STRIP(&chat,%CHAT%)
    IFMATCHES(%&chat%,"^Kits: ")
    
        IFMATCHES(%CHAT%," Starter")
            ECHO(/kit starter)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Flint")
            ECHO(/kit flint)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Anvil")
            ECHO(/kit anvil)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Water")
            ECHO(/kit water)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Pyro")
            ECHO(/kit pyro)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Compass")
            ECHO(/kit compass)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Mobs")
            ECHO(/kit mobs)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Signs")
            ECHO(/kit signs)
            WAIT(1000ms)
        ENDIF
        IFMATCHES(%CHAT%," Enderchest")
            ECHO(/kit enderchest)
            WAIT(1000ms)
        ENDIF
    
        //Delete the next 2 lines to remove the automatic, hourly kit collector
        WAIT(3600000ms)
        LOG("&4&l[&c&lAuto-Kit&4&l] &6Collects in &c1 minute&6. Make room in your &6inventory!")
        PLAYSOUND(random.levelup)
        WAIT(55000ms)
        LOG("&4&l[&c&lAuto-Kit&4&l] &6Collects in &c5 seconds&6!")
        PLAYSOUND(random.levelup)
        WAIT(5000ms)
        PLAYSOUND(random.levelup)
        ECHO(/kit)
    
    ENDIF
    }$$
    
    This should include all the available kits, if I missed any, please let me know. If I ever figure out how to use the SPLIT command correctly, I'll change it to automatically detect any available kits, instead of just the pre-programmed ones.
    If you want to add this to your macro collection, @314 I'd be happy to add some statistics code along with it, too

    Also, does anyone else crash if you try to use the $$p command, then click [AddPlace]? For example, bind "/tp $$p" to a key, and test it.

    EDIT: Didn't realize kits still worked when your inventory was full, until it auto collected and they all fell on the ground. I changed the code to have a 1 minute warning before auto collect, then another at 5 seconds.
    EDIT 2: Script will stack on itself if you type /kit after it's already been run, essentially just making it run twice every 61 minutes. It will also error if you're in SG when it auto-collects. Working of a fix for both of these, as well as adding the ability to pick and choose which kits you collect, and collecting all kits at once, rather then 1 every second.
     
    #65 i8ablu, Dec 1, 2015
    Last edited: Dec 3, 2015
  6. i8ablu

    i8ablu Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️ Premium Upgrade

    Joined:
    Dec 4, 2012
    Messages:
    98
    Trophy Points:
    35,740
    Ratings:
    +48
    I added an automatic pumpkin and melon miner (automatically mines them when looked at and in range, this is not an afk script by any means, you still have to move around and aim yourself) and an auto eating function to 314's ToolSwitch script. I'll paste it here for anyone interested.

    All of these are toggled on/off with auto tool, using ".tool"

    Melon/Pumpkin Miner and Auto-Eat Files (easiest to install, but if you don't want all of them, use the other spoilers below):
    Automatic Pumpkin/Melon Miner: Automatically mines pumpkins and melons when they're in range and being looked at. I made it so I don't accidently break the stems while farming 2 rows at once and let's face it, holding down the left click button is just too much work.
    Add the line
    Code:
    &pmctoolswitch4 = "pumpkin$"
    to the top of PMC_ToolSwitch.txt, after the &pmctoolswitch3 line. And remove the word pumpkin from the &pmctoolswitch3 line as well. Then add this to the main loop:
    Code:
    IFMATCHES(%HITID%,"^(%&pmctoolswitch4%)")
        IF((@#pmctoolaxe > 0) && (@#pmctoolaxe < 10))
            SLOT(%@#pmctoolaxe%)
            KEY(ATTACK)
        ENDIF
    ENDIF
    (this assumes you're holding your relevant melon mining device in your 4th hotbar slot, for ".tool set" support, please refer to the "Melon .tool set "spoiler) Add the line
    Code:
    &pmctoolswitch5 = "melon_block$"
    to the top of PMC_ToolSwitch.txt, after the &pmctoolswitch3 line (or 4 if you have it). Then add this to the main loop:
    Code:
    IFMATCHES(%HITID%,"^(%&pmctoolswitch5%)")
        SLOT(4)
        KEY(ATTACK)
    ENDIF
    Add the line
    Code:
    &pmctoolswitch5 = "melon_block$"
    to the top of PMC_ToolSwitch.txt, after the &pmctoolswitch3 line (or after 4 if you have it). Then add this to the main loop:
    Code:
    IFMATCHES(%HITID%,"^(%&pmctoolswitch5%)")
        IF((@#pmctoolmelon > 0) && (@#pmctoolmelon < 10))
            SLOT(%@#pmctoolmelon%)
            KEY(ATTACK)
        ENDIF
    ENDIF
    Then add this to PMC_Internal_ToolSwitch.txt before the very last IF(@pmcerror) function
    Code:
    IFMATCHES(%@&pmccommand%,"(?i)^\.tool set melon (.+)$")
        MATCH(%@&pmccommand%,"(?i)^\.tool set melon (.+)$",{&var})
        SET(#var,%&var%)
        IF((#var > 9) || (#var < 1))
            LOG("&2&l[&a&lPMC: ToolSwitch&2&l]&c Error: Invalid slot (1-9).")
        ELSE
            @#pmctoolmelon = #var
            LOG("&2&l[&a&lPMC: ToolSwitch&2&l]&6 Melon in slot &e%@#pmctoolmelon%&6.")
        ENDIF
        UNSET(@pmcerror)
    ENDIF
    And finally, change line 66 of PMC_Internal_Help.txt to:
    Code:
    LOG("        &6<tool> parameters: &bsilk&6,&b shovel&6,&b axe&6,&b sword&6,&b fortune&6, &bmelon&6.")


    Auto Eat: Automatically eats when your hunger is at 18/20 or less.
    (this assumes your food is in slot 9, for ".tool set" support, refer to the "Auto Eat with ".tool set" Support" spoiler) Add this to the main loop in PMC_ToolSwitch.txt:
    Code:
    IF(%HUNGER% < 19)
        SLOT(9)
        KEY(USE)
    ENDIF
    Add this to the main loop in PMC_ToolSwitch.txt:
    Code:
    IF(%HUNGER% < 19)
        SLOT(%@#pmctoolfood%)
        KEY(USE)
    ENDIF
    Then add this to PMC_Internal_ToolSwitch.txt before the very last IF(@pmcerror) function
    Code:
    IFMATCHES(%@&pmccommand%,"(?i)^\.tool set food (.+)$")
        MATCH(%@&pmccommand%,"(?i)^\.tool set food (.+)$",{&var})
        SET(#var,%&var%)
        IF((#var > 9) || (#var < 1))
            LOG("&2&l[&a&lPMC: ToolSwitch&2&l]&c Error: Invalid slot (1-9).")
        ELSE
            @#pmctoolfood = #var
            LOG("&2&l[&a&lPMC: ToolSwitch&2&l]&6 Food in slot &e%@#pmctoolfood%&6.")
        ENDIF
        UNSET(@pmcerror)
    ENDIF
    And finally, change line 66 of PMC_Internal_Help.txt to (if you didn't use the melon miner script, remove "&bmelon&6,"):
    Code:
    LOG("        &6<tool> parameters: &bsilk&6,&b shovel&6,&b axe&6,&b sword&6,&b fortune&6, &bmelon&6, &bfood&6.")
     
    #66 i8ablu, Dec 2, 2015
    Last edited: Dec 3, 2015
  7. zr2002

    zr2002 Nub Moderator
    Resident ⛰️ Ex-EcoLeader ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Aug 17, 2014
    Messages:
    5,474
    Trophy Points:
    63,660
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +3,161
    I'm pretty sure the autuomatic pumpkin and melon miner is illegal
     
  8. Torzon

    Torzon Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Oct 21, 2015
    Messages:
    152
    Trophy Points:
    11,440
    Gender:
    Male
    Ratings:
    +49
    First, would it be legal to do a "if I have stone, /sell stone" macro? and if so, what would the if statement look like? I can replicate for other stuff, just don't know all the variables and such for this. I'm envisioning something like:
    If (inventory) stone =True
    then echo ("/sell stone") (syntax is off I'm sure)

    I have a sell stone types already, but when I don't have 1 of that item in my inventory, I get a bunch of error messages and would like to not get them.

    A few other questions:
    1. Can you have a "sell all except diamond" statement of some sort?
    2. Can you somehow say "sell all types of stone" without having to put them in 1 by 1?

    Sorry, I get basic scripting, but don't know all the variables/commands/context for this language. I'm not a developer by any means ;).
     
    #68 Torzon, Dec 3, 2015
    Last edited: Dec 3, 2015
  9. 314

    314 Irrational Moderator, former ServerAdmin
    SuperMod EcoLegend ⛰️⛰️⛰️⛰️ Ex-President ⚒️⚒️ Prestige ⭐ VI ⭐ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    7,046
    Trophy Points:
    97,160
    EcoDollars:
    $1,400,000
    Ratings:
    +4,917
    I am not exactly sure (although it should be not allowed) - I generally recommend to use as few automation as possible for anything to prevent interfering with the server rules, clause "Automation".

    I have yet to find any way to achieve something like that.
    1. No, unless you /sell every single item type in your inventory, one by one.
    2. I made a few tests about that; so far nothing worked.
    The disadvantage is, every time you use /kit for any reason, it creates another loop which is added to the already existing one.
    Also, if you are in SG when the time runs out, you will get spammed with error messages as your kits are not available there... oh, and you could modify it to only issue one single command which combines everything instead of using many.
     
  10. Torzon

    Torzon Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Oct 21, 2015
    Messages:
    152
    Trophy Points:
    11,440
    Gender:
    Male
    Ratings:
    +49
    Thanks Pi, I guess I'll have to learn to ignore the chat spam :(.
     
  11. i8ablu

    i8ablu Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️ Premium Upgrade

    Joined:
    Dec 4, 2012
    Messages:
    98
    Trophy Points:
    35,740
    Ratings:
    +48
    From what I understood from the Automation Clause, we're not allowed to use any macros/scripts/mods that automate things to the point where we don't have to do any work, and/or are able to be afk.

    To be clear about my script above (and I added this to the op, as well), it doesn't fully automate farming melon/pumpkins (I should have worded that differently before), it just auto tool switches, and mines them when they're in range and being looked at, taking the place of your left mouse button. You still have to walk around and aim at them yourself. I did it mainly to help prevent mining the stems when swinging back and forth to mine 2 rows at once.

    If it is actually against the rules, considered bending the rules, or staff doesn't want it posted for any reason, I apologize, and I'll take it down immediately and remove if from my game, as well. If any staff could comment on this, or pm me about that, that would be great.


    Good points, thank you. I'll see what I can do to fix these.

    I think I figured something out that could work as you were saying. Sadly, your inventory has to be open for a second or 2 for it to work, but it works pretty well aside from that. It was actually pretty fun to make and I definitely learned a lot from it.

    Code:
    $${
    //editable variables
    //add whatever items you want to auto-sell here
    &itemstosell = "stone|cobblestone|granite|diorite|andesite|dirt|gravel|flint"
    
    IF(GUI = "NONE")
        #amounttosell = 0
        UNSET(&sell[])
        GUI(INVENTORY)
        //cycles through all inventory slot ID's
        FOR(#slotid,9,44)
            //gets inventory slot info
            GETSLOTITEM(%#slotid%,&founditem,#stacksize,#datavar)
            //checks if the item is on the sell list
            IFMATCHES(%&founditem%, "^(%&itemstosell%)$")
            //detects what type of stone it is, a function like this is also needed for wood, planks, wool, decoration bricks/sandstone, colored glass, clay, etc...
                IF(&founditem = "stone")
                    IF(#datavar = 1)
                        &founditem = "granite"
                    ELSEIF(#datavar = 3)
                        &founditem = "diorite"
                    ELSEIF(#datavar = 5)
                        &founditem = "andesite"
                    ENDIF
                ENDIF
                //checks is an item is already in the sell array
                //I used this so instead of selling everything as it was found, it would save an array of items, then close your inventory so you could get back to what you were doing, then actually sell them, saving you a few seconds
                INDEXOF(&sell,#index,%&founditem%)
                //if item was not a duplicate
                IF(#index = -1)
                    //adds it to the sell array
                    PUSH(&sell,%&founditem%)
                    #amounttosell = #amounttosell + 1
                ENDIF
            
            ENDIF
        NEXT
        //closes inventory GUI, allowing you to go back to mining, as it sells everything
        GUI()
        //checks if anything needs to be sold
        IF(#amounttosell > 0)
            #endofarray = #amounttosell - 1
            //cycles through array for things to be sold
            FOR(#arrayposition,0,%#endofarray%)
                ECHO(/sell %&sell[%#arrayposition%]%)
                //anti command spam
                WAIT(1)
            NEXT
        ENDIF
    ENDIF
    }$$
    I tried to comment out what I thought would be important, so you could learn a bit from it or edit it to do whatever you want.
    There's also a Command Page, with examples of variables and events, and a page of User Made Scripts, some of which are a little outdated on formatting, but should still be useful to get some general ideas about what things do.
     
    #71 i8ablu, Dec 3, 2015
    Last edited: Dec 3, 2015
  12. zr2002

    zr2002 Nub Moderator
    Resident ⛰️ Ex-EcoLeader ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Aug 17, 2014
    Messages:
    5,474
    Trophy Points:
    63,660
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +3,161
    When you start farming them technically you're doing no work
     
  13. i8ablu

    i8ablu Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️ Premium Upgrade

    Joined:
    Dec 4, 2012
    Messages:
    98
    Trophy Points:
    35,740
    Ratings:
    +48
    You mean because you'd only be walking and aiming, rather than walking, aiming, and holding left click? I wouldn't exactly call that no work, unless you consider farming in general no work, as well.
     
  14. ScarabCoder

    ScarabCoder Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️

    Joined:
    Sep 12, 2015
    Messages:
    305
    Trophy Points:
    15,790
    Gender:
    Male
    Ratings:
    +235
    I wanna merge my LWC macro with PMC.... But your code is so much better and more advanced then mine! I'm still having trouble understanding it, and adapting my code to match the same layout :)
     
  15. 314

    314 Irrational Moderator, former ServerAdmin
    SuperMod EcoLegend ⛰️⛰️⛰️⛰️ Ex-President ⚒️⚒️ Prestige ⭐ VI ⭐ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    7,046
    Trophy Points:
    97,160
    EcoDollars:
    $1,400,000
    Ratings:
    +4,917
    :)

    I took a look at your LWC macro - I have seen certain interesting things which I might test in the future... my goal is to have a LWC macro condensed into one single, clean .txt file. :)
     
  16. ScarabCoder

    ScarabCoder Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️

    Joined:
    Sep 12, 2015
    Messages:
    305
    Trophy Points:
    15,790
    Gender:
    Male
    Ratings:
    +235
    Yeah, my pragmatic programming skills are nowhere near the best; when I look at how other people do it, it looks a lot cleaner and use functions I've never even heard about.
     
  17. Logannnnnn

    Logannnnnn Alaska シ
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Apr 18, 2012
    Messages:
    1,108
    Trophy Points:
    41,610
    Gender:
    Male
    Ratings:
    +651
    Thanks so much 314! :artist:
    I'll donate 5K when I see you in game!
     
  18. 314

    314 Irrational Moderator, former ServerAdmin
    SuperMod EcoLegend ⛰️⛰️⛰️⛰️ Ex-President ⚒️⚒️ Prestige ⭐ VI ⭐ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    7,046
    Trophy Points:
    97,160
    EcoDollars:
    $1,400,000
    Ratings:
    +4,917
    Thank you very much for this donation! :happy:

    Added you as the top supporter in the main post. :)
     
  19. ChaaadMaxxx

    ChaaadMaxxx fσσтвαℓℓ α∂∂ιςт єςσℓєα∂єя
    Builder ⛰️ Ex-EcoLeader ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Oct 20, 2015
    Messages:
    315
    Trophy Points:
    23,690
    Gender:
    Male
    Ratings:
    +276
    donating $7500!!! (I will donate plenty more if you keep up the good work)
    P.S.- Don't worry about that message in convo, .tool command fixed it lol.

    This saves tons of time and effort, and you deserve to be rewarded. Everyone can do this macro, and it will save you soooo much time :D.
    thanks again 314, you are a beast <3
     
  20. IamKarnii

    IamKarnii Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 5, 2015
    Messages:
    146
    Trophy Points:
    10,940
    Gender:
    Male
    Ratings:
    +70
    This macro tromps all others, works really well and the support you gave me to set it up was superb. Will donate 10k next time I see you in game. Thanks for your continuous support here at ECC!! :)