What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

CollectItemsAtFarm is a loop?

Galaxylog

New Member
Joined
Dec 14, 2014
Messages
4
Reaction score
0
I was just playing around with Archbuddy API and it seems like CollectItemsAtFarm is a loop, dosent stop until it finishes the whole farm.

I was trying to collect single items instead of everything around it.

I tried

while (labor > 999 ) // my current labor - 1
{
CollectItemsAtFarm (blahblah)
}

and it wasnt working, it still collects entire farm.

any pro can help? =D
 
CollectItemsAtFarm is a Method with loop in it.
You probably could write your own Method on getting list of plants and looping through it if you like rly need it.

P.S. Not a pro here.
 
try:

Code:
            private const string SkillHarvest = "harvest crops";

            ....
                // use your logic here, to get your single item
                var plant = GetPlants()
                    .Where(doodad => doodad.growthTime == 0)
                    .FirstOrDefault();

                if (plant != null)
                {
                     var skill = plant.getUseSkills().First(s => s.desc.Contains(SkillHarvest)).id;
                     MoveTo(plant);                
                     UseDoodadSkill(skill, plant, true);
                }

not tested, btw, but I think this will work
 
Thanks

try:

Code:
            private const string SkillHarvest = "harvest crops";

            ....
                // use your logic here, to get your single item
                var plant = GetPlants()
                    .Where(doodad => doodad.growthTime == 0)
                    .FirstOrDefault();

                if (plant != null)
                {
                     var skill = plant.getUseSkills().First(s => s.desc.Contains(SkillHarvest)).id;
                     MoveTo(plant);                
                     UseDoodadSkill(skill, plant, true);
                }

not tested, btw, but I think this will work

Hey, Thanks for input, i tired ur code but its giving me a error, i have replaced the "harvest crops" to exact string of that skill ex(Farming: Spend 1 Labor to harvest crops.)

private const string SkillHarvest = "harvest crops"; // error CS1518: Expected class, delegate, enum, interface, or struct
 
this private line must be inside class body, not method.
and dont need to be exact string, because the code find for first skill who contains that part (but it will work if u replace, no problems)


Code:
public class Plugin : Core
{
    private const string SkillHarvest = "harvest crops";
    public void PluginRun()
    {
                var plant = GetPlants()
                    .Where(doodad => doodad.growthTime == 0)
                    .FirstOrDefault();

                if (plant != null)
                {
                     var skill = plant.getUseSkills().First(s => s.desc.Contains(SkillHarvest)).id;
                     MoveTo(plant);                
                     UseDoodadSkill(skill, plant, true);
                }
    }
}
 
Thank you again but!

this private line must be inside class body, not method.
and dont need to be exact string, because the code find for first skill who contains that part (but it will work if u replace, no problems)


Code:
public class Plugin : Core
{
    private const string SkillHarvest = "harvest crops";
    public void PluginRun()
    {
                var plant = GetPlants()
                    .Where(doodad => doodad.growthTime == 0)
                    .FirstOrDefault();

                if (plant != null)
                {
                     var skill = plant.getUseSkills().First(s => s.desc.Contains(SkillHarvest)).id;
                     MoveTo(plant);                
                     UseDoodadSkill(skill, plant, true);
                }
    }
}

Heyy Thank you again for answer! but i got an another error .
error CS0103: The name 'GetPlants' does not exist in the current context // i have tried to input "rice" or anyother things inside getplants but still seems like got problem when compile!
 
I thought you were a developer, my code is an example only.
You need to learn how to code to make complex logics.

The GetPlants needs to return a doodad list filter by your plant.
I dont have AB atm to test/write.
look for getDoodads() in API, filter doodad.name by "rice" (ex) and doodad.plantZoneId by your farm id.
 
Back
Top