Create and read from logfile?
Posted: Mon Feb 18, 2013 10:32 am
I was wondering if there is a way to create a log file with some basic info in it, and then be able to read the info from that text file later. I'm wanting to use a logfile for a bot to keep track of the bot's current quest and completion state so when I later load my questing script, it can read the file to know what the last quest was that it was working on and whether it had completed it or not, that way I can make it automatically go to the waypoint it needs to in order to continue where it left off.
I was thinking maybe doing it as an XML file, but wasn't sure if there was an easy way to read and interpret the contents of a text file versus an XML file.
I was thinking something along the lines of this:
Filename would be charactername\charactername_status.xml
contents of the file would look something like:
When the bot accepts a quest in my code, I would basically overwrite this file with the new quest name and a status of accepted.
When the bot completes a quest, it would update the status of that quest to "completed."
When I start my bot, I would want to read the log file to see what the last quest it was working on and whether it still needs to be completed (in which case it would go to that quests waypoint) or if it already completed it (in which case I would have it go to the next quest). Of course I woudl still need to figure out how to store all that information to tell it where to go.
So anyway, with an XML file set up like the above one, how would I read that? Also how would I go about making the bot program write a log file in the form of an XML? is there an easy way?
Unless, of course, someone else has already figured out a good way to keep track of where a questing bot has left off. Thanks.
I was thinking maybe doing it as an XML file, but wasn't sure if there was an easy way to read and interpret the contents of a text file versus an XML file.
I was thinking something along the lines of this:
Filename would be charactername\charactername_status.xml
contents of the file would look something like:
Code: Select all
<log>
<quest name="Frightening Giant Mosquitoes" status="accepted" />
</log>
When the bot completes a quest, it would update the status of that quest to "completed."
When I start my bot, I would want to read the log file to see what the last quest it was working on and whether it still needs to be completed (in which case it would go to that quests waypoint) or if it already completed it (in which case I would have it go to the next quest). Of course I woudl still need to figure out how to store all that information to tell it where to go.
So anyway, with an XML file set up like the above one, how would I read that? Also how would I go about making the bot program write a log file in the form of an XML? is there an easy way?
Unless, of course, someone else has already figured out a good way to keep track of where a questing bot has left off. Thanks.