Well when you click on the tree it's not like your character immediately starts animating does it? Well your script is programmed in a way to were it will click the tree and immediately wait for the player to animate. Of course it will click again.
First I think choptree should be changed to a function called 'clickedTree'. It's confusing to add a check for the animation in the choptree procedure, it's out of place and confusing
Simba Code:
function clickedTree():boolean;
var
Tree: TReflectObject;
begin
if Tree.Find(objGame, 'Tree', 16) then
if Tree.IsOnMS then
begin
Reflect.Mouse.Move(Tree.GetMSPoint, 10, 10);
if Reflect.Text.IsUpText('Chop down Tree') then
begin
Reflect.Mouse.Click(MOUSE_LEFT);
result := true; // since we clicked the tree the function returns true
end;
end else
rotateCameraToTile(Tree.GetTile);
end;
What I did here was remove unnecessary begins/ends to make it easier to read. I also took out the animating check as that should be done elsewhere You don't need a begin/end block if you are only going to have '1 command' on the next line like right here:
Simba Code:
if Tree.Find(objGame, 'Tree', 16) then
if Tree.IsOnMS then
The place were you should do the animation check is in 'loopLogic'
Simba Code:
procedure loopLogic();
begin
case (GetState()) of
CHOP_TREE:
if foundTree() then
begin
wait(1500);
if not myPlayer.IsAnimating then
// code here whatever you want to do if the player isn't animating
end;
end;
end;
Now I don't know what you want to do with the loop logic I'll leave that up to you but the command for waiting is wait(timeinmilliseconds)
There might even be a command for waiting for the player to animate you would have to ask @
Kyle; I'm sure there is but I can't think of it off the top of me head