Author Topic: Orion.FindList  (Read 4697 times)

0 Members and 1 Guest are viewing this topic.

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Referrals: 0
    • View Profile
Orion.FindList
« on: May 21, 2022, 11:46:37 AM »
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: [Select]
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);
}
}
}







There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
loot list.JPG

Offline altiric

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Re: Orion.FindList
« Reply #1 on: May 21, 2022, 12:05:20 PM »
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: [Select]
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);
}
}
}

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: [Select]
function LootToBank(){
Orion.Say('Bank');
        Orion.WaitForContainerGump();
Orion.FindList('Loot', 'backpack', 'item').forEach(function(item){
            Orion.MoveItem(item, 0, Player.BankSerial());
            Orion.Wait(600);
        });
}
« Last Edit: May 21, 2022, 12:11:26 PM by altiric »

Offline kdzhii

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Referrals: 0
    • View Profile
Re: Orion.FindList
« Reply #2 on: May 21, 2022, 12:29:12 PM »
I think in your for loop you should declare i as var.. so
Code: [Select]
for (var i = 0; i < sort; i++)not sure if that helps

Offline altiric

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Re: Orion.FindList
« Reply #3 on: May 21, 2022, 12:30:59 PM »
I think in your for loop you should declare i as var.. so
Code: [Select]
for (var i = 0; i < sort; i++)not sure if that helps

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.

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Referrals: 0
    • View Profile
Re: Orion.FindList
« Reply #4 on: May 21, 2022, 12:33:30 PM »
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.

Offline kdzhii

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 1
  • kdzhii has no influence.
  • Referrals: 0
    • View Profile
Re: Orion.FindList
« Reply #5 on: May 21, 2022, 12:34:23 PM »
ok ty, now i know :)
try setting backpack not as a string. in Orion scripts section you will notice it will  highlight, i think thats the way to use it.

Offline altiric

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Re: Orion.FindList
« Reply #6 on: May 21, 2022, 12:37:24 PM »
Go into your Lists Tab->Find Tab.
One the left side, Click New, add "Loot" as List Name
On the right side, click New->Select by Target
Add each item you want moved to that list.

Post Merge: May 21, 2022, 12:41:02 PM
ok ty, now i know :)
try setting backpack not as a string. in Orion scripts section you will notice it will  highlight, i think thats the way to use it.

You are correct. Instead of using a string you can use 'backpack' which is a global variable with you backback.Serial() :)

Post Merge: May 21, 2022, 12:43:56 PM
Sorry, had not noticed the picture before. Your Loot name named 'Loot' not Loot (take out the ('))
« Last Edit: May 21, 2022, 12:43:56 PM by altiric »

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Referrals: 0
    • View Profile
Re: Orion.FindList
« Reply #7 on: May 21, 2022, 12:49:30 PM »
I have my  list name as 'loot' ,  so I name it LOOT and it work. 

Offline Crisis

  • Global Moderator
  • *
  • *
  • Posts: 2998
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Referrals: 2
    • View Profile
Re: Orion.FindList
« Reply #8 on: January 28, 2023, 10:33:56 AM »
*NECRO*

I am late to the party but can someone explain .length and what the 2nd line is telling Orion to do?

Code: [Select]
if(sorttobag.length) {
for (i = 0; i < sorttobag.length; i++) {

Offline bendel

  • Full Member
  • ***
  • Posts: 215
  • Activity:
    0%
  • Reputation Power: 4
  • bendel has no influence.
  • Referrals: 0
    • View Profile
Re: Orion.FindList
« Reply #9 on: January 29, 2023, 10:57:16 AM »
The ".length" property is a property of an array in JavaScript that returns the number of elements in the array.

The 2nd line of the code uses a for loop to iterate over the elements in the "sorttobag" array. The loop starts from 0 and goes until the end of the array, which is determined by "sorttobag.length". The variable "i" is used as the loop counter and is incremented on each iteration.


Sorry, I had this to chatgpt and it seems correct 😅

Tags: