SRL Archive - General Botting Help

[OGL] Operator "AND" not compatible


Clutch

2015-04-22 23:53:58

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.

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;
  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.

Obscurity

2015-04-22 23:56:27

Parenthesis.

Clutch

2015-04-23 00:16:55

From: Obscurity
Wrap your conditions in brackets. Also, what are your conditions with ogl.getTextures? If it's empty? Full? Length = x? What?


{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…

Ross

2015-04-23 00:22:50

From: Clutch

{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.

Clutch

2015-04-23 00:31:59

From: Ross
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.

slacky

2015-04-23 01:15:55

From: Ross
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.

Gu3st...

2015-04-23 07:43:53

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

Ross

2015-04-23 08:08:08

From: Clutch
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.


From: slacky
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?

slacky

2015-04-23 08:46:43

From: Ross
Interesting, so why wasn't it working for him before?

Idk, I don't care enough to check :p

Clutch

2015-04-23 09:10:23

From: Ross
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.

From: slacky
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.

Obscurity

2015-04-23 14:16:52

From: Ross
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.

Clutch

2015-04-23 16:22:37

From: Obscurity
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…

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

Obscurity

2015-04-23 16:58:34

Texture IDs aren't cardinals. ;).

Clutch

2015-04-23 17:12:19

From: Obscurity
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.


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

Ross

2015-04-23 20:14:01

From: Clutch
What do I label them as then…?

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


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:

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

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