I noticed a problem when using /itemnotify worldX - It only goes up to 8, if you try to do anything with the 9th or 10th slots you get an error, so I changed this to /itemnotify in enviro X
Also, things are changing, so the /ctrl is now /ctrlkey (ironically the command itself will tell you /ctrl <command> when done alone)
Here's an example of a fully realized add component macro with error checking and validation of empty slots. This of course is going to be slower than a barebones macro, you have to make the decision on the level of fault tolerance you want in your macros. I tend to go overboard.
WARNING:
A problem with this macro is the fact that it will find items in your combine pack if you are not using an enviromental container, e.g. a sewing pack.
You just have to check for that somewhere else or add checking for that in this. In my tradeskills macro I decided to forgo the use if ${FindItem} and do my own finding.
Code: Select all
#turbo
Sub Main
/call AddComp "@Param0" @Param1 @Param2
/return
sub AddComp(ComponentName,CombinePackNumber,CombineSlotNumber)
| ComponentName - Name of the component you want to add
| CombinePackNumber - Destination pack number, e for enviro
| CombineSlotNumber - Destination slot number
/declare iSlot local | The slot in which the item was found
/if (!${Defined[ComponentName]} || !${Defined[CombinePackNumber]} || !${Defined[CombineSlotNumber]}) {
/echo AddComp Error: You must specify the component, the container number, and the container slot in which to put the compents
/echo Syntax: /call AddComp "<Component Name>" <Pack Number> <Slot Number in Pack>
/return FALSE
}
| Check container to see if it is full
/if (${String[@CombinePackNumber].Equal[e]}) {
| No way I know of to check enviro containers for space - but I'm ignorant so...
} else {
/if (${Me.Inventory[pack@CombinePackNumber].Container}-${Me.Inventory[pack@CombinePackNumber].Items}==0) {
/echo AddComp Error: Unable to add this item to the container, it is full
/return FALSE
}
}
| Look for the item
/varset iSlot ${FindItem[@ComponentName].InvSlot}
/if (@iSlot) {
:FindEmptySlot
/echo CombineSlot = @CombineSlotNumber
/if (${String[@CombinePackNumber].Equal[e]}) {
/if (@CombineSlotNumber>10) {
/echo AddComp Error: Unable to add this item to the container, it is full
/return FALSE
}
} else {
/if (@CombineSlotNumber>${Me.Inventory[pack@CombinePackNumber].Container}) {
/echo AddComp Error: Unable to add this item to the container, it is full
/return FALSE
}
}
| See if there's anything in the slot we are trying to put stuff
/if (${String[@CombinePackNumber].Equal[e]}) {
/itemnotify in enviro @CombineSlotNumber leftmouseup
| Make sure the cursor is clear, otherwise something was in that slot
/if (${Cursor.ID}!=NULL) {
/itemnotify in enviro @CombineSlotNumber leftmouseup
/varadd CombineSlotNumber 1
/varset CombineSlotNumber ${String[@CombineSlotNumber].Arg[0,.]}
/goto :FindEmptySlot
}
} else {
/if (${Me.Inventory[pack@CombinePackNumber].Item[@CombineSlotNumber].ID}!=NULL) {
/varadd CombineSlotNumber 1
/varset CombineSlotNumber ${String[@CombineSlotNumber].Arg[0,.]}
/goto :FindEmptySlot
}
}
| Slot is empty, so go ahead and put item into it
| Found it, pick it up and move it to the combine container
/ctrlkey /itemnotify @iSlot leftmouseup
/echo ComponentName = @ComponentName
/echo CombinePackNumber = @CombinePackNumber
/if (${String[@CombinePackNumber].Equal[e]}) {
/itemnotify in enviro @CombineSlotNumber leftmouseup
} else {
/itemnotify in pack@CombinePackNumber @CombineSlotNumber leftmouseup
}
} else {
/echo AddComp Error: Could not find << @ComponentName >>
/return FALSE
}
/return TRUE