Author Topic: Problem with if statements?  (Read 3910 times)

0 Members and 1 Guest are viewing this topic.

Offline alaskanTopic starter

  • Jr. Member
  • **
  • Posts: 29
  • Activity:
    0%
  • Reputation Power: 1
  • alaskan has no influence.
  • Gender: Male
  • Respect: 0
  • Referrals: 0
    • View Profile
Problem with if statements?
« on: May 11, 2014, 06:36:58 AM »
0
Code: [Select]
;====================Harvest=====================
sub Harvest
  FindItem %flax1 G_0
  set #lobjectid #findid
  while #findcnt > 0
  {
    Event Macro 17 0
    wait 3s
  }
  FindItem %flax2 G_0
  set #lobjectid #findid
  while  #findcnt > 0
  {
    Event Macro 17 0
    wait 3s
    finditem %bundle C_ , %backpack
    set #lobjectid #findid
    if #findcnt = 10
    {
      exevent drag #findid #findstack
      wait 10
      exevent dropc %hboh
      wait 10
      if #charposx = 2282 && #charposy = 1708     ;First Crop
      {
        event macro 5 1
      }
      if #charposx = 2282 && #charposy = 1707  ;Second Crop
      {
        event macro 5 7
      }
      if #charposx = 2281 && #charposy = 1707    ;Thrid Crop
      {
        event macro 5 7
      }
      if #charposx = 2280 && #charposy = 1707   ;Fourth Crop
      {
        event macro 5 7
      }
      if #charposx = 2279 && #charposy = 1707     ;Fifth Crop
      {
        for %next 0 2
          event macro 5 1
      }
      if #charposx = 2279 && #charposy = 1705     ;Sixth Crop
      {
        event macro 5 3
      }
      if #charposx = 2280 && #charposy = 1705     ;Seventh Crop
      {
        event macro 5 3
      }
      if #charposx = 2281 && #charposy = 1705     ;Eigth Crop
      {
        event macro 5 3
      }
      if #charposx = 2282 && #charposy = 1705     ;Ninth Crop
      {
        event macro 5 1
      }
      if #charposx = 2282 && #charposy = 1704     ;Tenth Crop and moves to Spinning Wheel
      {
        for %next 0 2
        {
          event macro 5 1
        }
        wait 5
        for %next 0 2
        {
          event macro 5 7
        }
        wait 5
      }
    }
  }
return
Ok so I'm writing a flax harvest script and it harvests the flax just fine but then it doesn't drag and drop the %bundle to %hboh and doesn't move to the next crop. I'm sure I'm missing something or don't have something written correctly. Any and all help is much appreciated. Thanks in advance guys  :)
"You miss 100% of the shots you don't take" - Wayne Gretzky

Offline Grandewd

  • Full Member
  • ***
  • Posts: 239
  • Activity:
    0%
  • Reputation Power: 3
  • Grandewd has no influence.
  • Respect: +24
  • Referrals: 0
    • View Profile
Re: Problem with if statements?
« Reply #1 on: May 17, 2014, 11:39:31 PM »
0
Um, I pretty much suck at this... But, G_0 ?
Anyway, you say it finds the %flax but doesn't drop it.
If it doesn't drop it, how do you know it found it?  Anyway, the syntax looks fine to me, wondering if you've set %flax and/or %hboh correctly...
« Last Edit: May 17, 2014, 11:47:41 PM by Grandewd »

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Problem with if statements?
« Reply #2 on: May 18, 2014, 03:54:42 AM »
0
Need a little more info. How are %Flax1 and %Flax2 getting values? I've never done this actual task, no idea what flax is in the game lol. Should this be similar to, say, harvesting cotton where you look for a cotton plant, if found walk to it and pick it, then look for another plant, rinse repeat?

Does flax spawn at the same spot over and over?
Can there be more than one that spawns at each spot?

There are some definite logic issues in your snippet but I would need to know a little more to tell you what they are.

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline alaskanTopic starter

  • Jr. Member
  • **
  • Posts: 29
  • Activity:
    0%
  • Reputation Power: 1
  • alaskan has no influence.
  • Gender: Male
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Problem with if statements?
« Reply #3 on: May 29, 2014, 09:27:38 AM »
0
Yeah, sorry it sounds like flax is very similar to cotton then. I have about 10 crops and yeah they're static in-game. I have %flax1 and %flax2 just set to the different types of flax, %flax1 is the first type of flax before it's "harvested" and %flax2 is the type that it is after it's been harvested once.
"You miss 100% of the shots you don't take" - Wayne Gretzky

Offline Grandewd

  • Full Member
  • ***
  • Posts: 239
  • Activity:
    0%
  • Reputation Power: 3
  • Grandewd has no influence.
  • Respect: +24
  • Referrals: 0
    • View Profile
Re: Problem with if statements?
« Reply #4 on: May 29, 2014, 10:20:24 AM »
0
Did you try G_2 ?
G_0 is forcing it to look at the tile your standing on...
« Last Edit: May 30, 2014, 12:31:18 PM by Grandewd »

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Problem with if statements?
« Reply #5 on: May 30, 2014, 06:10:51 AM »
0
If it's helpful, there is a cotton picker in my script library you can take a look at. All it does is hang out in a field looking for cotton. When it finds one it walks over and harvests it then waits for another one to appear. Maybe it would be helpful to look at the logic a little.

In yours, why are you dropping it to the ground? Sorry for all the questions, just understanding the mechanics well is the only way to truly get the logic correct :)

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline alaskanTopic starter

  • Jr. Member
  • **
  • Posts: 29
  • Activity:
    0%
  • Reputation Power: 1
  • alaskan has no influence.
  • Gender: Male
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Problem with if statements?
« Reply #6 on: June 06, 2014, 02:02:17 PM »
0
Quote
In yours, why are you dropping it to the ground? Sorry for all the questions, just understanding the mechanics well is the only way to truly get the logic correct Smiley

X
Ok cool yeah I'll take a look at yours and see what I'm doing wrong with mine hehe. I'm trying to drag the harvested flax into one of my bags after the find count is equal to 10.
"You miss 100% of the shots you don't take" - Wayne Gretzky

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: Problem with if statements?
« Reply #7 on: June 07, 2014, 05:51:02 PM »
0
Quote
In yours, why are you dropping it to the ground? Sorry for all the questions, just understanding the mechanics well is the only way to truly get the logic correct Smiley

X
Ok cool yeah I'll take a look at yours and see what I'm doing wrong with mine hehe. I'm trying to drag the harvested flax into one of my bags after the find count is equal to 10.
Dude, I might be wrong here, since I haven't messed with Easyuo in a while... But I think the problem you have is using #FINDCNT.

#FINDCNT will always be one, no matter how large the stack.

#FINDSTACK will return how many items there are in the stack found by #FINDTYPE.

So you should do something like this:

Code: [Select]
;====================Harvest=====================
sub Harvest
  FindItem %flax1 G_0
  set #lobjectid #findid
  while #findcnt > 0
  {
    Event Macro 17 0
    wait 3s
  }
  FindItem %flax2 G_0
  set #lobjectid #findid
  while  #findcnt > 0
  {
    Event Macro 17 0
    wait 3s
    finditem %bundle C_ , %backpack
    set #lobjectid #findid
    if #FINDSTACK >= 10 ; probably safer to use >= instead of =, in case you skip an iteration or something
    {
      exevent drag #findid #findstack
      wait 10
      exevent dropc %hboh
      wait 10
      if #charposx = 2282 && #charposy = 1708     ;First Crop
      {
        event macro 5 1
      }
      if #charposx = 2282 && #charposy = 1707  ;Second Crop
      {
        event macro 5 7
      }
      if #charposx = 2281 && #charposy = 1707    ;Thrid Crop
      {
        event macro 5 7
      }
      if #charposx = 2280 && #charposy = 1707   ;Fourth Crop
      {
        event macro 5 7
      }
      if #charposx = 2279 && #charposy = 1707     ;Fifth Crop
      {
        for %next 0 2
          event macro 5 1
      }
      if #charposx = 2279 && #charposy = 1705     ;Sixth Crop
      {
        event macro 5 3
      }
      if #charposx = 2280 && #charposy = 1705     ;Seventh Crop
      {
        event macro 5 3
      }
      if #charposx = 2281 && #charposy = 1705     ;Eigth Crop
      {
        event macro 5 3
      }
      if #charposx = 2282 && #charposy = 1705     ;Ninth Crop
      {
        event macro 5 1
      }
      if #charposx = 2282 && #charposy = 1704     ;Tenth Crop and moves to Spinning Wheel
      {
        for %next 0 2
        {
          event macro 5 1
        }
        wait 5
        for %next 0 2
        {
          event macro 5 7
        }
        wait 5
      }
    }
  }
return
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Tags: