Scripting Resources & Utilities > Orion UO Client

Orion.FindList

(1/2) > >>

The Ghost:
Trying to learn by making small function 

so I 'm Trying to send some wood into a bag at the  bank.   Find some documentation and trying to get this to work. 

I build a list into  Orion assistant ,  no error is present when i run it.   Any idea what I'm dong wrong.


--- Code: ---var runebook = "0x429C9158"
var bankbag = "0x40CF7E6A"

function LootToBank()
{
Orion.Say('Bank');
var sorttobag = Orion.FindList('Loot', 'backpack', '1');
if(sorttobag.length) {
var sort = sorttobag.length;
for (i = 0; i < sort; i++) {
Orion.MoveItem(sorttobag[i], 0, bankbag);
Orion.Wait(600);
}
}
}


--- End code ---





altiric:
function LootToBank()
{
   Orion.Say('Bank');
   var sorttobag = Orion.FindList('Loot', 'backpack', '1');     
   if(sorttobag.length) {
      var sort = sorttobag.length;
      for (i = 0; i < sort; i++) {
         Orion.MoveItem(sorttobag, 0, bankbag);
         Orion.Wait(600);
      }
   }
}
Orion.Say("Bank"); This will open your bank box but without a delay after (like Orion.WaitForContainerGump()) the next commands can be processed before your bank even opens.
Orion.FindList(list, container, flags); flags are listed in the help tab under FindFlags, in this case you just need 'item' instead of '1'
-You'll also need to have a list named "Loot" in your Lists->Find Tab with each item you want moved (If you don't).
Orion.MoveItem(serial, qty, container); For moving to a bank box, the easy way is to use Player.BankSerial()

I added a pile of gold to my "Loot" list and ran the following, it worked.


--- Code: ---function LootToBank()
{
Orion.Say('Bank');
    Orion.WaitForContainerGump();
var sorttobag = Orion.FindList('Loot', 'backpack', 'item');
if(sorttobag.length) {
for (i = 0; i < sorttobag.length; i++) {
Orion.MoveItem(sorttobag[i], 0, Player.BankSerial());
Orion.Wait(600);
}
}
}

--- End code ---

This will only move 1 item from the Loot list though, changing if(sorttobag.length)  to while() will keep it going til there are no found items left in the list.

Here is another example that does the same thing using some JavaScript magic :)


--- Code: ---function LootToBank(){
Orion.Say('Bank');
        Orion.WaitForContainerGump();
Orion.FindList('Loot', 'backpack', 'item').forEach(function(item){
            Orion.MoveItem(item, 0, Player.BankSerial());
            Orion.Wait(600);
        });
}

--- End code ---

kdzhii:
I think in your for loop you should declare i as var.. so

--- Code: ---for (var i = 0; i < sort; i++)
--- End code ---
not sure if that helps

altiric:

--- Quote from: kdzhii on May 21, 2022, 12:29:12 PM ---I think in your for loop you should declare i as var.. so

--- Code: ---for (var i = 0; i < sort; i++)
--- End code ---
not sure if that helps

--- End quote ---

Javascript allows you to set a variable without the var as long as you add a value to it.
var i, or i=0 is the same thing as far as its concerned.

The Ghost:
Thx altiric for the clarification, 
event with your function nothing moving.  Since if work on your side,  for me it back to learning how to make list again.

Navigation

[0] Message Index

[#] Next page

Go to full version