Openkore.com
http://forums.openkore.com/

kinky if statement
http://forums.openkore.com/viewtopic.php?f=7&t=16727
Page 1 of 1

Author:  pawlow [ 14 Feb 2012, 13:02 ]
Post subject:  kinky if statement

I'm writing a tiny macro to bring my items to a waiting slavemule on a predetermined position, it runs fine untill I add items.

Now with this the interpreter seems to have a problem, telling me "munch, munch, strange block":

Code:
macro walkToSlave {
    do ai manual
    $rherb = @inventory ("Red Herb")
    $shell = @inventory ("Shell")
    $phracon = @inventory ("Phracon")
    do move 22 76 morocc
    pause 5
    $playerID = @player("tralfamador")
    pause 5
    do deal $playerID
    pause 1
    if($rherb != -1) {
        do deal add $rherb
        pause 1
    }

    if($shell != -1) {
        do deal add $shell
        pause 1
    }
   
    if($phracon != -1) {
        do deal add $phracon
        pause 1
    }
    do deal
    pause 5
    do deal
    pause 5
    do ai on
}


I've tried putting the actual adding of the items into extra macros and then just calling those, OpenKore then tells me "Unrecognized -> if <- subroutine".

Enlightment appreciated.

Author:  EternalHarvest [ 14 Feb 2012, 23:15 ]
Post subject:  Re: kinky if statement

Macro plugin doesn't have such a normal syntax as you're trying to use.

http://wiki.openkore.com/index.php/Macro#IF_statement

Author:  pawlow [ 15 Feb 2012, 14:03 ]
Post subject:  Re: kinky if statement

Thanks, found out about that myself. You just get used to the C syntax when you've been programming in it for years.

Here's what's working for me now if anyone's interested, all it does is go to my idling slave bot who sits at a fixed position and has dealAuto 2 on and deal him predetermined items that my farm bot is gonna pick up. Had to split it in two deals because all the items wouldn't fit into one deal. Rest is completely straightforward.

Code:
automacro checkWeight {
    weight >= 89%
    call dealItemsToSlave
}

macro dealItemsToSlave {
    do ai manual
    pause 1
    call walkToSlave
    call getItemIds
    call getSlaveId
    call dealOne
    call dealTwo
    do ai on
}

macro getItemIds {
    $shell = @inventory (Shell)
    pause 1
    $phracon = @inventory (Phracon)
    pause 1
    $bottle = @inventory (Empty Bottle)
    pause 1
    $china = @inventory (China)
    pause 1
    $rherb = @inventory (Red Herb)
    pause 1
    $guard = @inventory (Guard [1])
    pause 1
    $card = @inventory (Peco Peco Egg Card)
    pause 1
    $milk = @inventory (Milk)
    pause 1
    $feather = @inventory (Feather)
    pause 1
    $bfeather = @inventory (Feather of Birds)
    pause 1
    $ygem = @inventory (Yellow Gemstone)
    pause 1
    $mucus = @inventory (Sticky Mucus)
    pause 1
}

macro getSlaveId {
    $playerID = @player("slaveName")
    pause 1
}

macro walkToSlave {
    do move 110 291 morocc
    pause 1
}

macro dealSlave {
    do deal $playerID
    pause 1
}

macro dealOne {
    do deal $playerID
    pause 1
    if ($shell != -1) call addshells
    pause 1
    if ($phracon != -1) call addphracs
    pause 1
    if ($china != -1) call addchinas
    pause 1
    if ($rherb != -1) call addrherbs
    pause 1
    if ($guard != -1) call addguards
    pause 1
    if ($card != -1) call addcards
    pause 1
    do deal
    pause 2
    do deal
    pause 2
}

macro dealTwo {
    do deal $playerID
    pause 1
    if ($bottle != -1) call addbottles
    pause 1
    if ($milk != -1) call addmilks
    pause 1
    if ($feather != -1) call addfeathers
    pause 1
    if ($bfeather != -1) call addbfeathers
    pause 1
    if ($ygem != -1) call addygems
    pause 1
    if ($mucus != -1) call addmucus
    pause 1
    do deal
    pause 2
    do deal
    pause 2
}

macro addshells {
    do deal add $shell
}

macro addphracs {
    do deal add $phracon
}

macro addbottles {
    do deal add $bottle
}

macro addchinas {
    do deal add $china
}

macro addrherbs {
    do deal add $rherb
}

macro addguards {
    do deal add $guard
}

macro addcards {
    do deal add $card
}

macro addmilks {
    do deal add $milk
}

macro addygems {
    do deal add $ygem
}

macro addfeathers {
    do deal add $feather
}

macro addbfeathers {
    do deal add $bfeather
}

macro addmucus {
    do deal add $mucus
}

Author:  hynospt [ 31 May 2017, 23:32 ]
Post subject:  Re: kinky if statement

thankyou pawlow its work :)

macro version 2.0.3

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/