Figured i'd share some of the procedures/functions I've been using in my scripts that could come in handy for someone else.

CheckIfFrozen, whenever you go into a Loading Please Wait, it freezes the screen until it's done loading. This will simply wait for the screen to un-freeze using Pixel Shift. If it finds the player isn't moving and the current pixelShift is greater than 500 it simply exits so there isn't any downtime if the player is already standing still.
Simba Code:
{------------------------------------------------------------------------------)
 Function: CheckIfFrozen
 Description: Checks if the screen is frozen/is in a loading screen by using PixelShift
 Credits: Twinki
(------------------------------------------------------------------------------}

function CheckIfFrozen(MarkerWaitTime: Integer = 5000): boolean;
Var
  pS, i: Integer;
  FrozenTimer: TTimeMarker;
begin
FrozenTimer.start();
result := true;
repeat
  pS := getPixelShift(mainscreen.getBounds(), 500);
  WriteLn('Current PixelShift: '+toStr(pS));
  if Ps <= 100 then
  begin
    repeat
     Wait(randomRange(250, 750));
     pS := getPixelShift(mainscreen.getBounds(), 500);
    until (Ps >= 500) or (FrozenTimer.getTime() >= 10000);
  end;
  if not (minimap.isPlayerMoving()) and (Ps >= 500) then
    break();
until FrozenTimer.getTime() >= MarkerWaitTime;
end;


PrintError, just a very basic Error code system. Just call it in your script with PrintError(1); where 1 is your error code you'd like to assign the specific error, make sure you add in your error text in the case. I'm sure a simple WriteLn('some stuff went wrong'); would be easier, but I figured this could come in handy for a very long script or an easy way to organize and find if something goes wrong.
Simba Code:
{------------------------------------------------------------------------------)
 Procedure: PrintError
 Description: Prints the error that's occured
 Credits: Twinki
(------------------------------------------------------------------------------}

procedure PrintError(ErrorCode: Integer);
Var
  Error: String;
begin
  case ErrorCode of
  1: Error := '';
  2: Error := '';
  3: Error := '';
  end;

  smartEnableDrawing := false;
  ClearDebug();
  WriteLn('***************\ScriptName/***************');
  WriteLn('* Time Running: '+ToStr(TimeRunning));
  WriteLn('* We terminated due to an error');
  WriteLn('* ERROR '+ToStr(ErrorCode)+': '+Error);
  WriteLn('******************************************');
  TerminateScript();
end;