hello,
i want to add a log of what the bot did at the end of the script, what type of variable would i have to store this in?
hello,
i want to add a log of what the bot did at the end of the script, what type of variable would i have to store this in?
if you're trying to record the debug of certain actions, record them in a variable, then call a procedure that prints them to console (i.e. like ProgressReport).Simba Code:AddOnTerminate('ProgressReport');
I think you mean the above?
I know some people like to make a separate procedure for a ``FinalReport,'' but I think they're one in the same.
-Lj
i already have that but i dont know how to make it print like a log of what the bot did
Ok now I'm on my computer so I can elaborate:
There would be a procedure like when it banks I would call
Simba Code:AddReport('Banking')
And when the user clicks stop script a log is printed on the writeln of everything the bot did like:
Code:withdrawing banking fletching waiting waiting fletching waiting banking withdrawing
Well I guess you could just add a debug procedure which prints the status to the debug box. In my script the output is something like:
You could just add + TimeRunning if you want the time-stamp. I think this is what you mean. If you wanted to actually get the number of times each action was performed then you would have to assign each to a variable and increase it by 1 each time it was performed.We are taking a break in 0h 56m 32s
We have Oak Logs in our inventory
We are currently walking to the Sawmill (using SPS)
We found Planker Object DTM, walking there now
Walked to planker using ObjDTM
Searching for the Planker using TPAFinderPlanker
We found the Planker with TPAFinderPlanker
Waiting for the plank interface
We found the plank interface
We have Oak Planks in our inventory
We are currently walking to the Bank (using SPS)
Failed to find Bank Object DTM, finding symbol
Found Bank symbol, walking there now
Searching for the Banker using OpenBankNPCEx
Searching for the Banker using OpenBankFast
Found Banker using OpenBankFast
Depositing planks
Withdrawing logs
We have Oak Logs in our inventory
Potentially engaging in AntiBan
We are currently walking to the Sawmill (using SPS)
I don't want to do that as the script is running because it ruins the progress report :s I want it to print everything at the end, maybe to a file perhaps so users can show me it so I can find bugs better
EDIT: Sort of answered my question here:
Simba Code:Program Hi;
Procedure AddReport(Report:TStringArray);
Begin
Writeln('' + ToStr(Report))
End;
Begin
AddReport(['Banking']);
AddReport(['Withdrawing']);
AddReport(['Withdrawing']);
End.
But how do I make it Writethe timestamp like I can with writeln
Simba Code:SetScriptProp(SP_WriteTimeStamp, [True]);
Are you actually trying to save a file log of the script's action's during runtime?
see SRLlog.simba (/includes/srl/core/)
Simba Code:const
DEBUG = True; //let the user set this.
procedure Debugln(s:String);
begin
if DEBUG then
writeLn(s);
end;
Actually nevermind after testing it it is only saving 1 string at a time
Simba Code:Program Hi;
Var
GlobalReport:String;
Procedure WriteReport;
Begin
Writeln('' + GlobalReport)
End;
Procedure AddReport(Report:TStringArray);
Begin
GlobalReport := ToStr(Report);
// Writeln('' + ToStr(Report))
End;
Begin
SetScriptProp(SP_WriteTimeStamp, [True]);
AddReport(['Banking']);
wait(1000)
AddReport(['Withdrawing']);
wait(1000)
AddReport(['Withdrawing']);
wait(1000)
WriteReport;
End.
EDIT:
I think I got it:
Simba Code:Program TestSave;
function OpenReportFile(): integer;
var
fileName,Bot_SavePath: string;
begin
Bot_SavePath := 'C:/Simba/'
if (not directoryExists(Bot_SavePath)) then
forceDirectories(Bot_SavePath);
// make sure it's a valid file name (Windows)
fileName := 'Fletcher Log.txt';
// fileName := replace(fileName, '/', '-');
//fileName := replace(fileName, ':', ' ');
fileName := Bot_SavePath + fileName;
try
if (fileExists(fileName)) then
result := appendFile(fileName)
else
result := createFile(fileName);
except
writeln('OpenSRLLogFile: '+exceptionToString(exceptionType, exceptionParam));
end;
end;
procedure AddToReport(s: string);
var
tmpFile: integer;
begin
writeln(s);
tmpFile := OpenReportFile();
if (tmpFile >= 0) then
try
writeFileString(tmpFile,s);
// writeFileString(tmpFile, '['+msToTime(getTimeRunning(), TIME_BARE)+']: '+s+#13+#10);
except
Writeln('Error writing File');
finally
closeFile(tmpFile);
end;
end;
Begin
AddToReport('Hello')
End.
There are currently 1 users browsing this thread. (0 members and 1 guests)