Handin.mac

For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!

Moderator: MacroQuest Developers

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Handin.mac

Post by kagonis » Wed Jun 09, 2004 10:06 am

I'm a bit rusty on doing macro's, so I'm gonna pass it through here first.

I've tried to rewrite the handin.mac I made some time back, to the new MQ2Data format, here is what I got so far. I was hoping someone could doublecheck it for me and point out any errors they see, thanks in advance :)

Code: Select all

| handin.mac
|
| Author(s):
| - Kagonis
| - Corrections and suggestions by various people..
|   SukMage
|   DKAA
|   Wassup
|
| Description:
| - Used to make handins to NPCs, nifty for those who
|    doesn't feel like getting carpal tunnel syndrome to
|    complete a quest that requires a lot of hand ins.
|
| Usage:
| - /macro handin.mac <pp|gp|sp|cp|"Item Name"> <amount> ["destroy"]
|    The you must type "destroy" for the macro to destroy items returned.
|
| Example:
| - /macro handin.mac "Batwing" 4 "destroy"
|    Will hand in 4 Batwing's and destroy the item(s) returned from the NPC.


Sub Main(string TheItem, int TheAmount, string DoDestroy)

    /declare Loopcount int local
    /declare Timeout timer local

    :GiveItem
        /if (!${Defined[TheItem]} || !${Defined[TheAmount]}) /call Syntax
        /for Loopcount 1 to ${TheAmount}
            /if (${TheItem.Equal[pp]}) {
                /ctrl /notify InventoryWindow IW_Money0 leftmouseup
            } else /if (${TheItem.Equal[gp]}) {
                /ctrl /notify InventoryWindow IW_Money1 leftmouseup
            } else /if (${TheItem.Equal[sp]}) {
                /ctrl /notify InventoryWindow IW_Money2 leftmouseup
            } else /if (${TheItem.Equal[cp]}) {
                /ctrl /notify InventoryWindow IW_Money3 leftmouseup
            } else {
                /ctrl /itemnotify ${FindItem[${TheItem}].InvSlot} leftmouseup
            }

            :WaitForItem
            /varset Timeout 5s
            /if (!${Cursor.ID}) {
                /if (!${Timeout.Value}) /goto :Done
                /delay 0
                /goto :WaitForItem
            }
            /click left target

            :Wait
            /varset Timeout 10s
            /if (${Cursor.ID}) {
                /if (!${Timeout.Value}) /goto :Done
                /delay 0
                /goto :Wait
            }
        /next Loopcount
        /click left npctrade give
        /delay 5

        :ClearCursor
        /if (${Cursor.ID}) {
            /if (${Defined[DoDestroy]} && ${DoDestroy.Equal[destroy]}) {
                /destroy
            } else {
                /autoinv
            }
            /delay 0
            /goto :ClearCursor
        }
    /goto :GiveItem
    :Done
        /endmacro
/return

Sub Syntax
    /echo Syntax: /macro handin <pp|gp|sp|cp|"Item Name"> <#> [destroy]
    /echo ..
    /echo Example: /macro handin gp 2 destroy
    /echo Will hand in 2 pieces of gold to the targeted NPC and then click give, and will destroy anything you get back on your cursor.
    /echo ..
    /echo Example: /macro handin "Batwing" 4
    /echo Will hand in 4 batwings to the targeted NPC and then click give, and will keep anything you get back on your cursor.
    /endmacro
/return
Edit: Cleaned up a few errors, still can't find the proper replacement for /finditem. So far my best guess is /itemnotify, but then I actually have to know the bag and slot the wanted item is in, or have I misunterstood it?

Edit: Found replacements for the obsolote commands I was using, thanks to DKAA :)
This should by the final working version, allthough I need to test it (and find something to test it on where I'm not KoS as a low leezurd).

Edit: Used SukMage's suggestions for use with /notify for picking up coins instead of the old /mouseto plat etc. method. Thanks :)
Fixed the error that SukMage found (I hope). Needed to use Timeout.Value[0] instead of Timeout.Equal[0].

Edit: Fixed some errors pointed out by Wassup ${amount} wasn't declared cause it was supposed to be ${TheAmount}. Sorry about that one.
Took some highlights from Wassup's code along, stil not sure what's wrong with them.. It's supposed to be Timeout.Value.Equal[0] instead?

Edit: Should be fully converted now, just me that is slow and didn't understand what Wassup was trying to tell me in his first post, thanks Wassup :)

Moving this to Macro Depot now, thanks for all the help guys/girls :)
Last edited by kagonis on Fri Jun 11, 2004 3:40 pm, edited 7 times in total.

Azum
a hill giant
a hill giant
Posts: 229
Joined: Wed Jun 04, 2003 5:04 am

Post by Azum » Wed Jun 09, 2004 10:40 am

NM, too early for me to be looking at code!

Oid
a snow griffon
a snow griffon
Posts: 416
Joined: Thu Oct 17, 2002 3:26 am
Contact:

Post by Oid » Wed Jun 09, 2004 3:53 pm

only one i see at a skim is /finditem is dead
Smokey the Lax says only you can prevent reproduction.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Wed Jun 09, 2004 5:17 pm

I've looked through the readme.chm for a replacement for /finditem but can't seem to find one.

Edited the initial post with a few corrections.

I also need to find a replacement for /click left auto it seems, I found /destroy as a replacement for /click left destroy, but can't find the autoequip's equivilant, hope someone is able to help.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Wed Jun 09, 2004 6:31 pm

/ctrl /itemnotify ${FindItem[${TheItem}].InvSlot} leftmouseup

for auto inventory use
/autoinv
or
/notify InventoryWindow IW_CharacterView leftmouseup

User avatar
SukMage
a ghoul
a ghoul
Posts: 88
Joined: Fri Jun 04, 2004 5:08 pm

Post by SukMage » Thu Jun 10, 2004 7:21 pm

When running it i get:

Code: Select all

[color=red]No such 'timer' member 'Equal'[/color]
handin.mac@46 (Main(string TheItem, int TheAmount, string DoDestroy)): /if (${Timeout.Equal[0]}) /goto :Done 
Found this browsing to find how to write/fix my Sol Ro Faction macro but think this would be more versatile if I or someone can get it to work. I can't pick up the gp needed in mine. The /mouseto gold won't work for me and reading the code here and the error I am getting, that might be the problem here as well.

User avatar
SukMage
a ghoul
a ghoul
Posts: 88
Joined: Fri Jun 04, 2004 5:08 pm

Post by SukMage » Thu Jun 10, 2004 7:58 pm

Code: Select all

/notify InventoryWindow IW_Money0 leftmouseup | for plat
/notify InventoryWindow IW_Money1 leftmouseup | for gold
/notify InventoryWindow IW_Money2 leftmouseup | for silver
/notify InventoryWindow IW_Money3 leftmouseup | for copper
That works in my macro I'm trying to build to open the "Quantity Window" but I need to find how to move the slider to the quantity desired. I haven't tested this macro with an item to see if it works.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Fri Jun 11, 2004 6:01 am

Thanks SukMage. I used the suggested way for retrieving coins, and I think I fixed the error you are getting as well..

User avatar
SukMage
a ghoul
a ghoul
Posts: 88
Joined: Fri Jun 04, 2004 5:08 pm

Post by SukMage » Fri Jun 11, 2004 8:10 am

Code: Select all

            /if (${TheItem.Equal[pp]}) { 
                /ctrl /notify InventoryWindow IW_Money0 leftmouseup 
            } else /if (${TheItem.Equal[gp]}) { 
                /ctrl /notify InventoryWindow IW_Money1 leftmouseup 
            } else /if (${TheItem.Equal[sp]}) { 
                /ctrl /notify InventoryWindow IW_Money2 leftmouseup 
            } else /if (${TheItem.Equal[cp]}) { 
                /ctrl /notify InventoryWindow IW_Money3 leftmouseup 
Added the /ctrl in front on it and it now picks up the 1 gold but doesn't trade it to the targeted NPC. I get 1 gold on the cursor and the macro ends. Am I doing something wrong or is it not quite fixed yet?

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Fri Jun 11, 2004 8:18 am

The only syntax errors I could see are highlighted in light blue:

Code: Select all

| handin.mac
|
| Author(s):
| - Kagonis
| - Corrections and suggestions by various people..
|   SukMage
|   DKAA
|
| Description:
| - Used to make handins to NPCs, nifty for those who
|    doesn't feel like getting carpal tunnel syndrome to
|    complete a quest that requires a lot of hand ins.
|
| Usage:
| - /macro handin.mac <pp|gp|sp|cp|"Item Name"> <amount> ["destroy"]
|    The you must type "destroy" for the macro to destroy items returned.
|
| Example:
| - /macro handin.mac "Batwing" 4 "destroy"
|    Will hand in 4 Batwing's and destroy the item(s) returned from the NPC.


Sub Main(string TheItem, int TheAmount, string DoDestroy)

    /declare Loopcount int local
    /declare Timeout timer local

    :GiveItem
        /if (!${Defined[TheItem]} || !${Defined[TheAmount]}) /call Syntax
        [color=cyan]| amount variable not declared[/color]
        /for Loopcount 1 to [color=cyan]${amount}[/color] 
            /if (${TheItem.Equal[pp]}) {
                /notify InventoryWindow IW_Money0 leftmouseup
            } else /if (${TheItem.Equal[gp]}) {
                /notify InventoryWindow IW_Money1 leftmouseup
            } else /if (${TheItem.Equal[sp]}) {
                /notify InventoryWindow IW_Money2 leftmouseup
            } else /if (${TheItem.Equal[cp]}) {
                /notify InventoryWindow IW_Money3 leftmouseup
            } else {
                /ctrl /itemnotify ${FindItem[${TheItem}].InvSlot} leftmouseup
            }

            :WaitForItem
            /varset Timeout 5s
            /if (!${Cursor.ID}) {
                /if ([color=cyan]!${Timeout.Value}[/color]) /goto :Done
                /delay 0
                /goto :WaitForItem
            }
            /click left target

            :Wait
            /varset Timeout 10s
            /if (${Cursor.ID}) {
                /if ([color=cyan]!${Timeout.Value}[/color]) /goto :Done
                /delay 0
                /goto :Wait
            }
        /next Loopcount
        /click left npctrade give
        /delay 5

        :ClearCursor
        /if (${Cursor.ID}) {
            /if (${Defined[DoDestroy]} && ${DoDestroy.Equal[destroy]}) {
                /destroy
            } else {
                /autoinv
            }
            /delay 0
            /goto :ClearCursor
        }
    /goto :GiveItem
    :Done
        /endmacro
/return

Sub Syntax
    /echo Syntax: /macro handin <pp|gp|sp|cp|"Item Name"> <#> [destroy]
    /echo ..
    /echo Example: /macro handin gp 2 destroy
    /echo Will hand in 2 pieces of gold to the targeted NPC and then click give, and will destroy anything you get back on your cursor.
    /echo ..
    /echo Example: /macro handin "Batwing" 4
    /echo Will hand in 4 batwings to the targeted NPC and then click give, and will keep anything you get back on your cursor.
    /endmacro
/return

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Fri Jun 11, 2004 11:29 am

Thanks Wassup, the undeclared variable was a naming error, should have been TheAmount :)

I'm not sure what the error is with the Timeout.Value.. Should it be
if (${Timeout.Value.Equal[0]}) instead?

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Fri Jun 11, 2004 1:44 pm

kagonis wrote:Thanks Wassup, the undeclared variable was a naming error, should have been TheAmount :)

I'm not sure what the error is with the Timeout.Value.. Should it be
if (${Timeout.Value.Equal[0]}) instead?
if (${Timeout.Value.Equal[0]}) is what is was before. In my post I changed it to what it should be to get the value of the timer.

${Timeout.Value} returns an integer representing the value of Timeout

So:

Code: Select all

/if (!${Timeout.Value}) 
Is TRUE when Timeout.Value returns 0 as the value