Results 1 to 15 of 15

Thread: [OGL] Operator "AND" not compatible

  1. #1
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default [OGL] Operator "AND" not compatible

    Getting the Following error - any suggestions on workarounds or what I am doing wrong would be appreciated.

    Error: Operator "AND" not compatible with types "Int32" and "array of record [0]Int32; [4]Int32; [8]Int32; [12]Int32; [16]Int32; [20]record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end; end" at line 101
    Compiling failed.

    Simba Code:
    procedure Heal;
    begin
      if ogl.getTextures(tPotato) then
      writeLn('HP is getting low... eating potato!');
      inventory.clickItem(tPotato);
      canEat.setTime(Random(600, 1200));
    end;

    procedure Heal2;
    begin
      writeLn('HP is getting low... eating food!');
      inventory.clickItem(Food);
      canEat.setTime(Random(600, 1200));
    end;
    Simba Code:
    else if actionBar.getLifePoints() >= 100 and ogl.getTextures(tPotato) and canEat.isFinished() then
        Reaction:=@Heal
      else if actionBar.getLifePoints() >=100 and ogl.getTextures(Food) and canEat.isFinished() then
        Reaction:=@Heal2
      else if ogl.getTextures(Food).isEmpty and ogl.getTextures(tPotato).isEmpty then
        Reaction:=@Terminate

    I am aware the HP are both set at 100 was intended so I could test that it would eat all of my food, in order, and when running out will terminate the script. I've also tried using inventory.getItem(tPotato) but this too gives me the same error.

  2. #2
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    Parenthesis.




    Skype: obscuritySRL@outlook.com

  3. #3
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Obscurity View Post
    Wrap your conditions in brackets. Also, what are your conditions with ogl.getTextures? If it's empty? Full? Length = x? What?
    Simba Code:
    {else if actionBar.getLifePoints() >= 100 and length(ogl.getTextures(tPotato)) then
        Reaction:=@Heal}

      else if [actionBar.getLifePoints() >=100] and [length(ogl.getTextures(Food))] then
        Reaction:=@Heal2
      else if [ogl.getTextures(Food).isEmpty] and [ogl.getTextures(tPotato).isEmpty] then
        Reaction:=@Terminate

    The first line is what I changed it to - works, doesn't pick up that the length is missing though...
    The second line is what I interpreted your last response - get error "AND" not compatible with types.
    The last line again, doesn't get picked up for some reason it keeps thinking those textures still exist.

    I just want it to find that if it has potatos and it's under this amount of hp it eats them, then if those are gone and its under x amount hp and theres food to eat that food I input. If it can't pick up either then to terminate the script. It's aggravating as I have done this already, yet CLEARLY not alot of this scripting has been sticking...
    Last edited by Clutch; 04-23-2015 at 04:22 AM.

  4. #4
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    Simba Code:
    {else if actionBar.getLifePoints() >= 100 and length(ogl.getTextures(tPotato)) then
        Reaction:=@Heal}

      else if [actionBar.getLifePoints() >=100] and [length(ogl.getTextures(Food))] then
        Reaction:=@Heal2
      else if [ogl.getTextures(Food).isEmpty] and [ogl.getTextures(tPotato).isEmpty] then
        Reaction:=@Terminate

    The first line is what I changed it to - works, doesn't pick up that the length is missing though...
    The second line is what I interpreted your last response - get error "AND" not compatible with types.
    The last line again, doesn't get picked up for some reason it keeps thinking those textures still exist.

    I just want it to find that if it has potatos and it's under this amount of hp it eats them, then if those are gone and its under x amount hp and theres food to eat that food I input. If it can't pick up either then to terminate the script.
    length(ogl.getTextures(Food)) = what?

    It's not a condition yet.

    (length(ogl.getTextures(Food)) > 0) would imply that the array is not empty, which is probably what you're looking for.

  5. #5
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    length(ogl.getTextures(Food)) = what?

    It's not a condition yet.

    (length(ogl.getTextures(Food)) > 0) would imply that the array is not empty, which is probably what you're looking for.
    That does the trick, but now it'll eat the potatos and hang there trying to eat more potatos even though there are none, and there are clearly sharks in the inventory (labeled as food).

    I feel like last time I did inventory.getItem(Food) but...that's not working now.
    Last edited by Clutch; 04-23-2015 at 04:48 AM.

  6. #6
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    length(ogl.getTextures(Food)) = what?

    It's not a condition yet.

    (length(ogl.getTextures(Food)) > 0) would imply that the array is not empty, which is probably what you're looking for.
    if Length([1,2,3]) then is actually a valid-condition, since integers are implicitly converted to booleans. So if Length(..) = 0 it would be False.. if it's anything else it's True.
    !No priv. messages please

  7. #7
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Why wrap the conditions in brackets? Wrap them in parentheses like a normal person

  8. #8
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    That does the trick, but now it'll eat the potatos and hang there trying to eat more potatos even though there are none, and there are clearly sharks in the inventory (labeled as food).

    I feel like last time I did inventory.getItem(Food) but...that's not working now.
    We might have to see the rest of your script to figure that out.
    What is your "heal" function?

    Also, Obscurity has written functions for this sort of thing, such as:
    (not arrayFood.isEmpty())

    Just an easier way to do it.


    Quote Originally Posted by slacky View Post
    if Length([1,2,3]) then is actually a valid-condition, since integers are implicitly converted to booleans. So if Length(..) = 0 it would be False.. if it's anything else it's True.
    Interesting, so why wasn't it working for him before?

  9. #9
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Interesting, so why wasn't it working for him before?
    Idk, I don't care enough to check
    Last edited by slacky; 04-23-2015 at 12:53 PM.
    !No priv. messages please

  10. #10
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    We might have to see the rest of your script to figure that out.
    What is your "heal" function?

    Also, Obscurity has written functions for this sort of thing, such as:
    (not arrayFood.isEmpty())

    Just an easier way to do it.




    Interesting, so why wasn't it working for him before?
    After sleeping and starting with a fresh mind, I feel like that is what I did last time (I had a rorarius script - fully functioning but my PC crashed and didn't have a backup so I am redoing it)..gonna experiment around with that today and see what we can't accomplish! Thanks for all the suggestions and help.

    Quote Originally Posted by slacky View Post
    if Length([1,2,3]) then is actually a valid-condition, since integers are implicitly converted to booleans. So if Length(..) = 0 it would be False.. if it's anything else it's True.
    Yeah, I've done it like that multiple times - sometimes I do have to use length(ogl.blah blah blah) though in order for it to work sometimes. I don't understand the difference between the two but it's always something I try when I start getting errors or problems.

  11. #11
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    We might have to see the rest of your script to figure that out.
    What is your "heal" function?

    Also, Obscurity has written functions for this sort of thing, such as:
    (not arrayFood.isEmpty())

    Just an easier way to do it.




    Interesting, so why wasn't it working for him before?
    Because [length(ogl.getTextures(Food))].

    We also have inventory methods.




    Skype: obscuritySRL@outlook.com

  12. #12
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Obscurity View Post
    Because [length(ogl.getTextures(Food))].

    We also have inventory methods.
    I'll try
    if inventory.getItem(72420) again tonight, but last night couldn't get it to work. Although right now I think I've got it all working get it to compile with no errors just need to actually run it to verify it works as intended now... currently at work so can't actually run it (firewall).

    I think I did the following for pots, thinking the same should apply for food. Although may run back into problems like I originally was...will have to test it out tonight.

    Rough example - literally wrote in 10 seconds...

    Simba Code:
    program example;

    Const

    Food := ogl.getTextures(TCardinalArray([1234, 5678])

    procedure eat;
    begin
    inventory.clickItem(Food)
    end;

    procedure mainloop;

    if (not Food.isEmpty()) then
    Reaction:=@eat
    else if Food.isEmpty() then
    terminate
    Last edited by Clutch; 04-23-2015 at 08:39 PM.

  13. #13
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    Texture IDs aren't cardinals. .




    Skype: obscuritySRL@outlook.com

  14. #14
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Obscurity View Post
    Texture IDs aren't cardinals. .
    What do I label them as then...?

    Thanks @Ross; gave up trying -- cheated and pretty much used your eat function.


    Simba Code:
    program example;



    Food := ogl.getTextures([72420, 112710])
    procedure eat;
    begin
    inventory.clickItem(Food)
    end;

    procedure mainloop;

    if (not Food.isEmpty()) then
    Reaction:=@eat
    else if Food.isEmpty() then
    terminate
    Last edited by Clutch; 04-23-2015 at 11:49 PM.

  15. #15
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    What do I label them as then...?

    Thanks @Ross; gave up trying -- cheated and pretty much used your eat function.


    Simba Code:
    program example;



    Food := ogl.getTextures([72420, 112710])
    procedure eat;
    begin
    inventory.clickItem(Food)
    end;

    procedure mainloop;

    if (not Food.isEmpty()) then
    Reaction:=@eat
    else if Food.isEmpty() then
    terminate
    They're TIntegerArrays.

    I shorten mine to:
    Simba Code:
    procedure eat;
    begin
    inventory.clickItem(ogl.getTextures([72420, 112710]));
    end;

    But that's because I like to reduce lines wherever possible haha.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •