MMOMinion

Full Version: Is it possible to have compound ["condition"] and ["complete"] blocks?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

I'm trying to maximize my crystal and shard gathering.

One issue that I see is if you're gathering shards/crystals at the lvl 30 nodes and you have condition set to ItemCount(x) < 9999, if you have 9998 in your inv when you start gathering a node it gets 1 shard and is capped, then it keeps trying to hit the same item, basically trapped in an infinite loop. What I've done is changed the condition to < 9990 which works rather well, but I can foresee a slight chance of the loop again if a big bonus happens. I can always lower the condition more it that happens.

Another issue is if I'm gathering both shards and crystals and if the crystals get capped then infinite loop again. So, I was thinking if I could check the ItemCount of both shards and crystals in one condition, I could overcome this issue. But I'm not sure if it can be done, or how to do it.

We'll use Fire Shards/Crystals as an example:

Pseudo code:

Task 1 (Gather Shards and Crystals until 9990 Shards or Crystals)
Condition: Fire Shards < 9990 and Fire Crystals < 9990
Complete: Fire Shards >= 9990 or Fire Crystals >= 9990

Task 2 (Gather Shards until 9990, in case Task 1 filled up Crystals)
Condition: Fire Shards < 9990
Complete: Fire Shards >= 9990

This is what I came up with, didn't try it, will it work?

Code:
local obj1 = {
  ["setup"] = {
    ["gearsetmining"] = 22;
    ["gearsetbotany"] = 23;
  };
  ["tasks"] = {
    [1] = {
      ["type"] = "mining";
      ["radius"] = 150;
      ["item1"] = "Fire Crystal";
      ["item2"] = "Fire Shard";
      ["minlevel"] = 26;
      ["mapid"] = 145;
      ["pos"] =  {
        ["x"] = 134;
        ["y"] = 8.31;  
        ["z"] = -80.08;
      };
      ["usestealth"] = true;
      ["gathermaps"] = false;
      ["skillprofile"] = "Crystals";
      ["dangerousarea"] = true;
      ["condition"] = {
        ["ItemCount(2) < 9990 and ItemCount(8) < 9990"] = true;
      };
      ["complete"] = {
        ["ItemCount(2) >= 9990 or ItemCount(8) >= 9990"] = true;
      };  
    };
    [2] = {
      ["type"] = "mining";
      ["radius"] = 150;
      ["item1"] = "Fire Shard";
      ["item2"] = "None";
      ["minlevel"] = 26;
      ["mapid"] = 145;
      ["pos"] =  {
        ["x"] = 134;
        ["y"] = 8.31;  
        ["z"] = -80.08;
      };
      ["usestealth"] = true;
      ["gathermaps"] = false;
      ["skillprofile"] = "Crystals";
      ["dangerousarea"] = true;
      ["condition"] = {
        ["ItemCount(2) < 9990"] = true;
      };
      ["complete"] = {
        ["ItemCount(2) >= 9990"] = true;
      };  
    };
  };
}
return obj1
That should work; though, I took Sebb's advice and capped at 9950. Works beautifully.
you actually only need a condition in that case. if you have more than 9990 shards it wont be a valid task and wont do it.


["condition"] = {
["(ItemCount(x) < 9980) and (ItemCount(y) < 9980)"] = true;

Alternatly

["condition"] = {
["ItemCount(x) < 9990"] = true;
["ItemCount(y) < 9990"] = true;
};
(10-15-2015, 01:39 PM)sebbs Wrote: [ -> ]["condition"] = {
["(ItemCount(x) < 9980) and (ItemCount(y) < 9980)"] = true;
};

The parentheses you added are requred?

(10-15-2015, 01:39 PM)sebbs Wrote: [ -> ]["condition"] = {
["ItemCount(x) < 9990"] = true;
["ItemCount(y) < 9990"] = true;
};

Having multiple conditions will "AND" them?

is the profile evaluated before every node? If that's the case, then gathering never requires a ["complete"] block.

So here is my logic:

Assume limits are set to 9950

Code:
Scenario 1
Shards        Crystals
9949           9949            Task 1 is valid
Gather 4 Crystals
9949           9953            Task 1 is invalid, Task 2 is valid
Gather 4 Shards
9953           9953            Task 1 and 2 are invalid

Scenario 2
Shards        Crystals
9949           9949            Task 1 is valid
Gather 4 Shards
9953           9949            Task 1 and 2 are invalid

I'm gonna give it a go. I'll let you know how it goes. I'll post my profile if it works.
["condition"] = {
["ItemCount(x) < 9990"] = true;
["ItemCount(y) < 9990"] = true;
};

all conditions need to be true or it wont work

so if
9920 shards = true
9998 crystals = false

not valid.


["(ItemCount(x) < 9980) and (ItemCount(y) < 9980)"] = true;

both need to be true but its just the one line

9920 shards and 9998 crystals = false

not valid
As is eluded to here, a few things to note:

No special parenthesis requirement, the strings are evaluated as normal lua, so they are only necessary if they are necessary for the block to make sense programmatically.
Multiple lines are evaluated as "and".
"condition" is evaluated only entering the task, once the task is begun, even if the condition becomes untrue, it no longer matters.
"complete" is evaluated only to exit the task, if no complete is used then the normal rules for exiting apply, like maxtime or a higher priority task is found.