Post Reply Home » Forums » Vanguard » VGExtreme General Discussion

Log File Interaction : VGExtreme General Discussion

Posted: March 23rd, 2007
Total Posts:154 Joined:2006
Looking for the code to interact with a log file.

If I do /log in the game it does not write the file till I close out that log file.

How can Interact with events without closing and opening the log file?

I know a few people that are working on bots have been doing this if someone could post the code please.
Posted: March 23rd, 2007
xaraph
If you check the code I pm'd to you for the crafting bot, you'll see some FileSystemObject(FSO) declarations (a windows API) along with WyvernX's EnableChatLog() function. Basically, you enable the chatlogfunction first, then set your FSO objects to the log (it's in your xum folder, I think it's called VGChatLog). Using the FSO you can load each line of the log dynamically into a txt string or array if you choose. Repeated calls to the ReadLine method will load any new lines so you can set it in a loop with a sleep command and constantly check new lines in the log. If you're unfamiliar with the FSO there are tons of tutorials on the web.
Posted: March 23rd, 2007
xaraph
Here's some basics:

Code: Select all

Dim fso
Dim path As String
Dim file
Dim txtLine As String
txtLine = ""

Function OpenLogFile ()
	On Error GoTo ErrHandler 
	Set fso = COM.CreateCOMObject("Scripting.FileSystemObject")
	path =  root.GetExhumeDirectory & "\VGLogDump.log"
	Set file = fso.opentextfile(path, 1)
	'lets loop through all the old stuff and get to the end of the file before we start generating new content
	Do Until file.AtEndOfStream
		txtLine = file.ReadLine
	Loop
	'Now enable the chatlog in preparation for new content
	EnableChatLog
	OpenLogFile = True
	Exit Function
	
	ErrHandler:
	OpenLogFile = False
End Function
and to loop through the chatlog once it's open:

Code: Select all

Do Until file.AtEndOfStream
   txtLine = file.ReadLine
   If InStr(txtLine, "Crafting recipe selected") Then
	bCraftStart = True
   End If
Loop

after each file.Readline, it reads a new line of the chatlog for you to run your checks against (in my case, I was checking if the string held "Crafting Recipe Selected").
Posted: March 23rd, 2007
Total Posts:154 Joined:2006
Thanks xaraph was looking through when I came back here.

Did not notice you had sent me the file sorry.
Ready to join the community? Click here and see all of the benefits!
blue large dotWho is online
Users browsing this forum: No registered users and 5 guests
Post Reply