Need help with reading Minecraft chat

Ask gaming related questions (AHK v1.1 and older)
CaptainArschbart
Posts: 26
Joined: 07 Jan 2021, 12:59

Re: Need help with reading Minecraft chat

24 Sep 2021, 08:11

Thats working fine but it still clicks even if the 2nd text (Du hast etwas aus dem Mülleimer geholt) is in log
CaptainArschbart
Posts: 26
Joined: 07 Jan 2021, 12:59

Re: Need help with reading Minecraft chat

24 Sep 2021, 13:37

it should stop the loop if "Du hast etwas aus dem Mülleimer geholt" is in the log
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Need help with reading Minecraft chat

24 Sep 2021, 19:21

I believe it does the following: "if it has clicked the right slot there's "Du hast etwas aus dem Mülleimer geholt" in chat, then the script should stop and search for the first one again". You can reorder the lines if needed to do something different. You can also add lines that display the result of each conditional statement, to help you understand what is happening along the way.

Line 7 contains a sleep. It's possible that the sleep is too short. You can do some testing at your end to determine that.
CaptainArschbart
Posts: 26
Joined: 07 Jan 2021, 12:59

Re: Need help with reading Minecraft chat

30 Sep 2021, 13:14

Could you do that for me?
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Need help with reading Minecraft chat

30 Sep 2021, 13:30

I do not use Minecraft and so cannot test it. I think that you will want to understand each line, and what is happening with each line during the execution. As a start to debugging, you could add MsgBox display lines that show you the result of each conditional statement. I have no secret tools but just do the same kinds of things myself when I debug my own scripts.

If your question is how to increase the sleep on line 7, you would increase the number on that line.
CaptainArschbart
Posts: 26
Joined: 07 Jan 2021, 12:59

Re: Need help with reading Minecraft chat

30 Sep 2021, 13:40

I even tried doing it with a imagesearch for each item that can be ingame but now it doesnt click the right places

Code: Select all

#SingleInstance, force
log = C:\Users\garle\AppData\Roaming\.minecraft\logs\latest.log
lastLine(file) {
 If FileExist(file) {
  FileRead, ttext, %file%
  line := StrSplit(Trim(ttext, "`r`n"), "`n")
  Return line[line.Count()]
 } Else MsgBox, 48, Error, File not found.`n`n%file%
}


loop {
If Instr(lastLine(log), "Du durchwühlst den Mülleimer")
If (ErrorLevel = 0) {
	imagesearch, imgx1, imgy1, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\apple.png
	if errorlevel = 1
	sleep 1
	else
	Mouseclick , left, imgx1+10, imgy1+10, 1, 0

	imagesearch, imgx2, imgy2, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\potato.png
	if errorlevel = 1
	sleep 1
	else
	Mouseclick , left, imgx2+10, imgy2+10, 1, 0

	imagesearch, imgx3, imgy3, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\rottenflesh.png
	if errorlevel = 1
	sleep 1
	else
	Mouseclick , left, imgx3+10, imgy3+10, 1, 0

	imagesearch, imgx4, imgy4, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\paper.png
	if errorlevel = 1 
	sleep 1
	else
	Mouseclick , left, imgx4+10, imgy4+10, 1, 0

	imagesearch, imgx5, imgy5, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, images\carrot.png
	if errorlevel = 1
	sleep 1
	else {
	Mouseclick , left, imgx5+10, imgy5+10, 1, 0
}}}

numpad3::ExitApp

Return
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Need help with reading Minecraft chat

30 Sep 2021, 13:48

For each search, you can add a MsgBox that displays the ErrorLevel as well as the image's coordinates when an image is found. Since your script does not work, start with one search instead of five, so that you can get the basic search working. Coordinates are relative to the active window, unless you use CoordMode to change that.

When the image is not found, instead of looping as fast as possible, add a short sleep. Your CPU will thank you, and you will be pleased with the extra breathing room.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 85 guests