1. angryuser

    angryuser Active Member

    Messages:
    3
    Hi all,

    I'd appreciate a bit of help. What I am trying to achieve is to get randomized list of Asteroids.
    Lets say we get 27 asteroid entities and I need the ${iterator:next} to go through all 27 of them BUT in random order. Can't have it skip one or jump to either one twice.

    What I have so far for the asteroid entity filter is this:

    Code (Text):
    function main()
    {
        variable index:entity Asteroids
        variable iterator AsteroidsIterator    
        variable string RoidQuery
        EVE:QueryEntities[Asteroids]        
        RoidQuery:Set[${LavishScript.CreateQuery["CategoryID != 25"]}]
        Asteroids:RemoveByQuery[${RoidQuery}]    
        LavishScript:FreeQuery[${RoidQuery}]
        Asteroids:GetIterator[AsteroidsIterator]
        if ${AsteroidsIterator:First(exists)}
        do
        {
            echo <${Time}> (ID ${AsteroidsIterator.Value.ID}) - ${AsteroidsIterator.Value.Name} - ${AsteroidsIterator.Value.CategoryID}"        
        }
        while ${AsteroidsIterator:Next(exists)}
    }
     
    I was only able to find this http://www.lavishsoft.com/wiki/index.php/ObjectType:iterator
    Sadly me being a newbie I wasn't able to figure out how to use the RandomAccess (or whether it would even do what I expect to) without some examples/snippets.
  2. gair

    gair Active Member

    Messages:
    55
    EVEBox does something like this to random the asteroid list:



    function main()
    {

    variable iterator AsteroidIt
    variable index:entity AsteroidListTmp
    variable int Count
    variable int Max


    EVE:QueryEntities[AsteroidListTmp, "CategoryID == 25"]


    echo "Used: ${AsteroidListTmp.Used}"


    if ${AsteroidListTmp.Used} > 3
    {
    Max:Set[${AsteroidListTmp.Used}]
    for (Count:Set[0] ; ${Count} < ${Max} ; Count:Inc)
    {
    AsteroidListTmp:Swap[${Math.Rand[${Max}]:Inc},${Math.Rand[${Max}]:Inc}]
    }
    }

    AsteroidListTmp:GetIterator[AsteroidIt]

    if ${AsteroidIt:First(exists)}

    {

    do
    {
    echo <${Time}> (ID ${AsteroidIt.Value.ID}) - ${AsteroidIt.Value.Name} - ${AsteroidIt.Value.CategoryID}"

    }
    while ${AsteroidIt:Next(exists)}
    }
    }
    Last edited: Jul 4, 2013
  3. angryuser

    angryuser Active Member

    Messages:
    3
    Interesting. I'll try using that once I get home.

    Anyway, I was trying to figure out how to get the RandomAccess to work, but there just seems to be something missing. Since the RandomAccess member is bool, I tried to set it as TRUE and use the Jump method (as stated in the documentation) but that just wouldn't do anything. Neither would Next. Actually it didn't even seem like the ${Variable.RandomAccess} would return anything else but NULL. I have to be going about it the wrong way. The lack of documentation on that particular member is painful :(
  4. angryuser

    angryuser Active Member

    Messages:
    3
    Tested it and it works wonderously. Thank you!

Share This Page