Mining Macro help

Discussion in 'Basic Tutorials' started by AstroDawg, Dec 27, 2016.

  1. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    I'm having some problems with this small macro.. I want this macro to do "/sell Cobblestone" after every 60sec or after so many cobblestone are picked up(Like 26). I've been trying to find out what I did wrong in the code.

    Code:
    DO()
    LOG("Auto Sell Cobblestone On")
    IF(PICKUPID = 4)
    ECHO("/sell Cobblestone")
    WAIT(60)
    LOOP()
    endif()
    LOG("Auto Sell Cobblestone Off")
    
     
    • Optimistic Optimistic x 1
    • Creative Creative x 1
    • List
  2. BrokeMel

    BrokeMel broke
    Resident ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 26, 2013
    Messages:
    1,018
    Trophy Points:
    61,160
    Gender:
    Female
    Ratings:
    +830
    *shrug*

    Doesn't loop every 60 seconds but sells after you pick up 4 stacks of cobble.

    Bind to onPickupItem
    Code:
    $${
        IF(%PICKUPID%="cobblestone")
            INC(#totalcobble,%PICKUPAMOUNT%)
            IF(%#totalcobble% >= 256)
                ECHO(/sell cobble)
                SET(#totalcobble,0)
            ENDIF
        ENDIF
    }$$
    idek what I'm doing
     
  3. GoatsRMeLife

    GoatsRMeLife Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Jun 7, 2016
    Messages:
    441
    Trophy Points:
    13,690
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +342
  4. 314

    314 Irratioπal President, former ServerAdmin
    Mythic ⚔️ I ⚔️ President ⛰️⛰️ Ex-President ⚒️⚒️ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    6,963
    Trophy Points:
    87,660
    EcoDollars:
    $0
    Ratings:
    +4,866
    I haven't tested it yet, but... I guess. I have no idea how much better my idea is, though.
    Code:
    $${
    IF(%PICKUPITEM%="cobblestone")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
            ECHO("/sell cobble")
            @#totalcobble = 0
        ENDIF
    ENDIF
    }$$
    
    Changes made to Mel's macro:
    • Use of %PICKUPITEM%. ID values are deprecated since quite a few MC versions. Not to mention that you would require the numeric ID instead.
    • @#totalcobble as a global variable. A different script instance is executed each time you pick up an item, so a local variable should always start as 0 in this script, discarding the previous value.
    • ECHO with proper quotation marks.
    • An easier way to read SET().
    As always: Not tested, no warranty.
    Oh, and this script may not work in a local world, earlier macro mod versions had problems with %PICKUPAMOUNT% in Singleplayer.
     
  5. _Smokin

    _Smokin S&S Constuction
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 7, 2013
    Messages:
    141
    Trophy Points:
    43,370
    Ratings:
    +31
    I would recommend also having a toggle key/button to turn on and off this script.

    Code:
    $${
    IF(mining)
      UNSET(mining)
      UNSET(@sell_cobblestone)
      LOG("&fAuto Sell Cobblestone - &4Off")
    ELSE
      SET(mining)
      SET(@sell_cobblestone)
      LOG("&fAuto Sell Cobblestone  - &aOn")
      @#totalcobble = 0
    ENDIF
    }$$

    Code:
    $${
    IF(@sell_cobblestone)
      IF(%PICKUPITEM% = "Cobblestone")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
            ECHO("/sell cobble")
            @#totalcobble = 0
        ENDIF
      ENDIF
    ENDIF
    }$$
     
  6. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    You're code worked good too. Thank all of you guys for the help!
     
  7. 314

    314 Irratioπal President, former ServerAdmin
    Mythic ⚔️ I ⚔️ President ⛰️⛰️ Ex-President ⚒️⚒️ Premium Upgrade

    Joined:
    Apr 1, 2014
    Messages:
    6,963
    Trophy Points:
    87,660
    EcoDollars:
    $0
    Ratings:
    +4,866
    I'm a little confused... a new instance of the macro is executed whenever you activate it, so shouldn't it discard the content of "mining" because it is a local variable?

    By the way, your post has the ID 900000 on the forum. Congratulations!
     
  8. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    I have no clue how it works, but it does.
     
  9. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    Your code works.. But how would I add other blocks? I tried this and it doesn't sell anything but cobby?
    Code:
    $${
    IF(@sell_cobblestone)
      IF(%PICKUPITEM% = "Cobblestone")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
            ECHO("/sell cobble")
            @#totalcobble = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Diorite")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
            ECHO("/sell Diorite")
            @#totalcobble = 0
        ENDIF
      ENDIF
    IF(%PICKUPITEM% = "Andesitee")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
            ECHO("/sell Andesitee")
            @#totalcobble = 0
        ENDIF
      ENDIF
    IF(%PICKUPITEM% = "Dirt")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
            ECHO("/sell Dirt")
            @#totalcobble = 0
        ENDIF
      ENDIF
    ENDIF
    }$$
     
  10. _Smokin

    _Smokin S&S Constuction
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 7, 2013
    Messages:
    141
    Trophy Points:
    43,370
    Ratings:
    +31
    You needed to change the variables to each item.
    Code:
    $${
    IF(@sell_cobblestone)
    LOG("%PICKUPITEM%")
      IF(%PICKUPITEM% = "Cobblestone")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 256)
          ECHO("/sell cobble")
          @#totalcobble = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Andesite")
        INC(@#totalandesite,%PICKUPAMOUNT%)
        IF(%@#totalandesite% >= 256)
          ECHO("/sell andesite")
          @#totalandesite = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Dirt")
        INC(@#totaldirt,%PICKUPAMOUNT%)
        IF(%@#totaldirt% >= 256)
          ECHO("/sell dirt")
          @#totaldirt = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Diorite")
        INC(@#totaldiorite,%PICKUPAMOUNT%)
        IF(%@#totaldiorite% >= 256)
          ECHO("/sell diorite")
          @#totaldiorite = 0
        ENDIF
      ENDIF
    ENDIF
    }$$
    

    You would also need to reset the totals to zero on the other script.
    Code:
    $${
    IF(mining)
      UNSET(mining)
      UNSET(@sell_cobblestone)
      LOG("&fAuto Sell Cobblestone - &4Off")
    ELSE
      SET(mining)
      SET(@sell_cobblestone)
      LOG("&fAuto Sell Cobblestone  - &aOn")
      @#totalcobble = 0
      @#totalandesite = 0
      @#totaldirt = 0
      @#totaldiorite = 0
    ENDIF
    }$$
    
     
  11. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    Thank you so much! :D
     
  12. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    Now every time I break a cobblestone it says cobblestone as a log.
     
  13. _Smokin

    _Smokin S&S Constuction
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jul 7, 2013
    Messages:
    141
    Trophy Points:
    43,370
    Ratings:
    +31
    Opps,
    Code:
    $${
    IF(@sell_cobblestone)
      IF(%PICKUPITEM% = "Cobblestone")
        INC(@#totalcobble,%PICKUPAMOUNT%)
        IF(%@#totalcobble% >= 4)
          ECHO("/sell cobble")
          @#totalcobble = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Andesite")
        INC(@#totalandesite,%PICKUPAMOUNT%)
        IF(%@#totalandesite% >= 4)
          ECHO("/sell andesite")
          @#totalandesite = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Dirt")
        INC(@#totaldirt,%PICKUPAMOUNT%)
        IF(%@#totaldirt% >= 4)
          ECHO("/sell dirt")
          @#totaldirt = 0
        ENDIF
      ENDIF
      IF(%PICKUPITEM% = "Diorite")
        INC(@#totaldiorite,%PICKUPAMOUNT%)
        IF(%@#totaldiorite% >= 4)
          ECHO("/sell diorite")
          @#totaldiorite = 0
        ENDIF
      ENDIF
    ENDIF
    }$$
    
     
  14. AstroDawg

    AstroDawg Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Dec 26, 2016
    Messages:
    26
    Trophy Points:
    7,450
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +26
    Thank you. :D