Page 1 of 1

Question about portable mailbox

Posted: Fri Jan 03, 2014 11:01 pm
by AngelDrago
I have a question on a portable mailbox not the envelope one but the you buy for diamonds i would like to check the backpack and it if sees it full it should than open up the portable mailbox to send out some of the loot that is not bound. any ideas that could help me. thx everyone

Re: Question about portable mailbox

Posted: Sat Jan 04, 2014 2:51 am
by kuripot
not sure but you can try

Code: Select all

	function bagcheck()
		if inventory:itemTotalCount(0) == 0 then
      		 	sendMacro("OpenMail()");
			yrest(1000);
			UMM_SendByNameOrId("Recievername",{ItemID},180)
			yrest(1000)
			sendMacro("CloseWindows()")
		end
	end

Re: Question about portable mailbox

Posted: Sat Jan 04, 2014 6:01 am
by rock5
Firstly, the mailbox opens automatically these days so you only have to use the actual send command. The function you use will depend on what sort of loot you want to send. Most likely you would use the "SendByType" function and send weapons and armor and any other types of loot you want to send. Note: all the UMM functions exclude items that are bound so you don't have to do anything specific for that.

Wait, there is no SendByType function. I should probably add one at some stage. At least the SendAdvanced function supports types, eg.

Code: Select all

UMM_SendAdvanced("recipient",nil,nil,nil,nil,{"Weapons","Armor"})

Re: Question about portable mailbox

Posted: Mon Jan 06, 2014 12:43 am
by AngelDrago
Thank you for the reply, so i would add it to my onload or should i add it in the waypoint? please advice

Re: Question about portable mailbox

Posted: Mon Jan 06, 2014 1:46 am
by rock5
Do you want it to do it when you load the waypoint file or when you are at a particular way point? Normally you could just put all your code in a way point but if you want to check your mail numerous times you might want to create a function in the onload then call the function at the waypoints.

So it depends.

Re: Question about portable mailbox

Posted: Mon Jan 06, 2014 9:46 am
by AngelDrago
yes, i would like it to be checked every time so when the backpack is full it needs to be sending out the specific items and than continue what it was doing

Re: Question about portable mailbox

Posted: Mon Jan 06, 2014 9:02 pm
by Ego95
Then probably add it to the onLeaveCombat? =)

Re: Question about portable mailbox

Posted: Tue Jan 07, 2014 3:47 am
by kuripot
AngelDrago wrote:yes, i would like it to be checked every time so when the backpack is full it needs to be sending out the specific items and than continue what it was doing
in your onload waypoint

Code: Select all

   function bagcheck()
      if inventory:itemTotalCount(0) == 0 then
                sendMacro("OpenMail()");
         yrest(1000);
         UMM_SendAdvanced("recipient",nil,nil,nil,nil,{"Weapons","Armor"})
         yrest(1000)
         sendMacro("CloseWindows()")
      end
   end

in your profile

Code: Select all

	<onLoad><![CDATA[

	]]></onLoad>

	<onDeath><![CDATA[

	]]></onDeath>

	<onLeaveCombat><![CDATA[
          bagcheck()
	]]></onLeaveCombat>

	<onLevelup><![CDATA[

	]]></onLevelup>

	<onSkillCast><![CDATA[

	]]></onSkillCast>

	<onHarvest><![CDATA[

	]]></onHarvest>

	<onUnstickFailure><![CDATA[

	]]></onUnstickFailure>

im right??

Re: Question about portable mailbox

Posted: Tue Jan 07, 2014 7:42 am
by rock5
Don't forget, you shouldn't need to open the mailbox in recent versions of the UMM functions. It does it automatically.

Put the "bagcheck()" in the profile if you want it to always do that check regardless of which waypoint file you use. If you do that then it's not a good idea to put the function in the waypoint onload because if you load another waypoint file you will get an error when it tries to run bagcheck() from the profile.

So either put it all in the profile:

Code: Select all

   <onLeaveCombat><![CDATA[
       function bagcheck()
          if inventory:itemTotalCount(0) == 0 then
             UMM_SendAdvanced("recipient",nil,nil,nil,nil,{"Weapons","Armor"})
             yrest(1000)
             sendMacro("CloseWindows()")
          end
       end
       bagcheck()
   ]]></onLeaveCombat>
Although, you don't need to create a function, you could just have the contents of the function,eg.

Code: Select all

   <onLeaveCombat><![CDATA[
          if inventory:itemTotalCount(0) == 0 then
             UMM_SendAdvanced("recipient",nil,nil,nil,nil,{"Weapons","Armor"})
             yrest(1000)
             sendMacro("CloseWindows()")
          end
   ]]></onLeaveCombat>
Or, if you want it to only apply for a particular waypoint file you can change the profile onleavcombat from the waypoint onload, eg.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<onload>
		if oldOnLeaveCombat == nil and settings.profile.events.onLeaveCombat then
			oldOnLeaveCombat = settings.profile.events.onLeaveCombat
		end
		function settings.profile.events.onLeaveCombat()
			if oldOnLeaveCombat then
				oldOnLeaveCombat()
			end
			if inventory:itemTotalCount(0) == 0 then
				UMM_SendAdvanced("recipient",nil,nil,nil,nil,{"Weapons","Armor"})
				yrest(1000)
				sendMacro("CloseWindows()")
			end
		end
	</onload>

Re: Question about portable mailbox

Posted: Sun Jan 12, 2014 1:30 pm
by AngelDrago
thank you for all the input i will try that... i will give update later

Re: Question about portable mailbox

Posted: Thu Sep 04, 2014 2:34 pm
by AngelDrago
OK tried this one out and I'm getting this

Code: Select all

Sending items to xxxxx...  Nothing to send.
Use MACRO: Executing RoMScript "CloseWindows()".
[string "return {_uilua.lightuserdate="userdata: 39DD0..."]:1: '}' expected near '='
error per say it will not send anything out and I'm using this in my profile

Code: Select all

        if inventory:itemTotalCount(0) == 0 then
             UMM_SendAdvanced("meme",nil,nil,nil,nil,{"Recipe", "Legendary Arrow", "Elven Herb", "Mysterious Elf Stone", "Blend Rune", "Ring", "Earring", "Necklace"})
             yrest(1000)
             sendMacro("CloseWindows()")
          end

Re: Question about portable mailbox

Posted: Thu Sep 04, 2014 10:50 pm
by rock5
The fact that the error message appears after the CloseWindows() message suggests it might be due to some code after the code you showed us. Try adding a print message after the sendMacro. Eg.

Code: Select all

print("CloseWindows() completed")
If it prints that message before the error then the error is caused by some code after that bit you showed us.

If you add a few print messages through your code it will help to narrow down which command is causing the error.