Jump to content

Help with logging, simple problem I think.


Recommended Posts

Here is the code

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"Kanes Mining Bot started at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)

FileClose($log1)

Then at the end I have it as

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)

FileClose($log1)

Now what is happening is, it writes perfect fine the first time around. But when it goes to write after I restart the script. it gives me the error that it is unable to parse the line, unless I delete all the text in the MiningLog.txt. Any ideas how to fix this fairly easily? Thanks in advance for the help

Link to comment
Share on other sites

$Ore = 100
$Log1=FileOpen("MiningLog.txt", 1)
FileWriteline($Log1,"Kanes Mining Bot started at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)
FileClose($Log1)

;Then at the end I have it as
$Log1=FileOpen("MiningLog.txt", 1)
FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")
FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)
FileClose($Log1)

Link to comment
Share on other sites

$Ore = 100
$Log1=FileOpen("MiningLog.txt", 1)
FileWriteline($Log1,"Kanes Mining Bot started at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)
FileClose($Log1)

;Then at the end I have it as
$Log1=FileOpen("MiningLog.txt", 1)
FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")
FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)
FileClose($Log1)

Maybe I'm missing your answer... but the only difference I see is you added the variable which is already in the other part of the script... so I don't think that was the issue that causes this file write error.

Link to comment
Share on other sites

Maybe I'm missing your answer... but the only difference I see is you added the variable which is already in the other part of the script... so I don't think that was the issue that causes this file write error.

Your code works fine for me - is there a part that is missing?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

With the exception of the $ore value that was missing from your code example (which KaFu addresses in his) I can not reproduce your error.

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Here is the full script. Maybe it will help reproduce the error

HotKeySet("^!q", "MyExit")

Hotkeyset("^m", "Mine")

HotkeySet("^p", "Pause")

$Gem=0

$Ore=0

#include "MiningLog.txt"

While 1;

ToolTip("Ore = " & $Ore & " " & "Gems Dropped = " & $Gem & " " & "Exp = " & $Ore*35,566,120)

Sleep(10000)

Wend

Func Mine()

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"Kanes Mining Bot started at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)

FileClose($log1)

While 1;

ToolTip("Ore = " & $Ore & " " & "Gems Dropped = " & $Gem & " " & "Exp = " & $Ore*35,566,120)

$Run1=PixelGetColor (845,252)

If $Run1 = 0x63D3E7 Then

Sleep(100)

Elseif $Run1 <> 0X63D3E7 Then

Sleep(1000)

Mouseclick("Left",845,252,1,1)

Sleep(500)

Endif

$pix1 = PixelSearch (143,156,418,480,0x101C31,5,1)

If @error then

Sleep(5000)

MouseMove (700,700,0)

$pix1 = PixelSearch (143,156,418,480,0x182039,5,1)

Endif

If @error then

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year&" Due to a random event or system failure")

FileClose($log1)

Endif

MouseClick ("Left", $pix1[0], $Pix1[1],1,1)

$Ore=$Ore+1

ToolTip("Ore = " & $Ore & " " & "Gems Dropped = " & $Gem & " " & "Exp = " & $Ore*35,566,120)

Sleep(5000)

$random1 = Random (250,500)

Sleep($random1)

$pix2 = PixelSearch (143,156,418,480,0x101C31,5,1)

If @error then

Sleep(5000)

MouseMove (700,700,0)

$pix2 = PixelSearch (143,156,418,480,0x182039,5,1)

Endif

If @error then

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year&" Due to a random event or system failure")

FileClose($log1)

Endif

MouseClick ("Left", $pix2[0], $Pix2[1],1,1)

$Ore=$Ore+1

ToolTip("Ore = " & $Ore & " " & "Gems Dropped = " & $Gem & " " & "Exp = " & $Ore*35,566,120)

Sleep(5000)

$random1 = Random (250,500)

Sleep($random1)

$pix3 = PixelSearch (143,156,418,480,0x101C31,5,1)

If @error then

Sleep(5000)

MouseMove (700,700,0)

$pix3 = PixelSearch (143,156,418,480,0x182039,5,1)

Endif

If @error then

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year&" Due to a random event or system failure")

FileClose($log1)

Endif

MouseClick ("Left", $pix3[0], $Pix3[1],1,1)

$Ore=$Ore+1

ToolTip("Ore = " & $Ore & " " & "Gems Dropped = " & $Gem & " " & "Exp = " & $Ore*35,566,120)

Sleep(5000)

$random1 = Random (250,500)

Sleep($random1)

$pix4 = PixelSearch (143,156,418,480,0x101C31,5,1)

If @error then

Sleep(5000)

MouseMove (700,700,0)

$pix4 = PixelSearch (143,156,418,480,0x182039,5,1)

Endif

If @error then

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year&" Due to a random event or system failure")

FileClose($log1)

Endif

MouseClick ("Left", $pix4[0], $Pix4[1],1,1)

$Ore=$Ore+1

ToolTip("Ore = " & $Ore & " " & "Gems Dropped = " & $Gem & " " & "Exp = " & $Ore*35,566,120)

Sleep(5000)

$random1 = Random (250,500)

Sleep($random1)

$pix5 = PixelSearch (475,270,643,491,0x101C31,5,1)

If @error then

Sleep(5000)

MouseMove (700,700,0)

$pix5 = PixelSearch (475,270,643,491,0x1820391,5,1)

Endif

If @error then

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year&" Due to a random event or system failure")

FileClose($log1)

Endif

MouseClick ("Left", $pix5[0], $Pix5[1],1,1)

Sleep(5000)

$random1 = Random (250,500)

Sleep($random1)

$Inv=PixelGetColor (759,323)

If $Inv = 0x21287B Then

Sleep(100)

Elseif $Inv <> 0X21287B Then

Sleep(1000)

Mouseclick("Left",759,323,1,1)

Sleep(500)

Endif

Do

$random1 = Random (150,500)

Sleep($random1)

$Drop1=PixelSearch(682,359,858,609,0x182039,5,1)

If @error then

Exitloop

endif

Mouseclick("Right",$Drop1[0],$Drop1[1],1,1)

Mouseclick("Left",$Drop1[0]-40,$Drop1[1]+40,1,1)

Sleep(200)

Until @error

Do

$random1 = Random (150,500)

Sleep($random1)

Sleep(500)

$Drop1=PixelSearch(682,359,858,609,0x730C08,5,1)

If @error then

Sleep(750)

Exitloop

endif

Mouseclick("Right",$Drop1[0],$Drop1[1],1,1)

Mouseclick("Left",$Drop1[0]-40,$Drop1[1]+40,1,1)

Sleep(200)

$Gem=$Gem+1

Until @error

Do

$random1 = Random (150,500)

Sleep($random1)

$Drop1=PixelSearch(682,359,858,609,0x086D08,5,1)

If @error then

Sleep(750)

Exitloop

endif

Mouseclick("Right",$Drop1[0],$Drop1[1],1,1)

Mouseclick("Left",$Drop1[0]-40,$Drop1[1]+40,1,1)

Sleep(200)

$Gem=$Gem+1

Until @error

wend

EndFunc

Func MyExit()

$Log1=FileOpen("MiningLog.txt", 1)

FileWriteline($Log1,"You Mined "&":"&$Ore&" "&"You gained :"&$Ore*35&" "&"Experience")

FileWriteline($Log1,"Kanes Mining Bot stopped at "&@Hour&":"&@Min&":"&@Sec&" "&@Mon&"/"&@Mday&"/"&@Year)

FileClose($log1)

Exit

EndFunc

Func Pause()

While 1;

Sleep(600000)

wend

Endfunc

Link to comment
Share on other sites

What is

#include "MiningLog.txt"

supposed to be doing for you?

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

I would get rid of that line

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...