Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;UPDATE 2016-05-24 this script is now obsolete, as the launcher has fixed these issues. 708 hits
- ;I leave, however, the last version below
- ;-----------------------------------------------------------------------
- ;-----------------------------------------------------------------------
- ; 2014-10-17
- ;mc_stat_save_lite.ahk
- ;Minecraft stats and achievements rescuing script by Mgis
- ;It saves stats for cracked versions of Minecraft
- ;not the fancy version
- ; updates at http://pastebin.com/u/mgis90
- ;-----------------------------------------------------------------------
- #SingleInstance force
- #KeyHistory 0 ; Disable keyboard and mouse event history.
- ;#Warn ;enables variable checks, debug mode
- GoSub,settings
- GoSub,java_check
- Loop, % dir_saves . "\*",2,0 ;walk through the dir, retrieve folders only
- {
- ;here we get world1 world2 ... folders
- max=0 ;max FileTimeModified for the next WorldFolder
- Loop, % A_LoopFileFullPath . "\*.json",0,1 ;only files, recurse
- {
- if (A_LoopFileTimeModified > max)
- {
- max:=A_LoopFileTimeModified
- max_path:=A_LoopFileLongPath
- StringTrimRight,max_folder,max_path, % StrLen(A_LoopFileName) ;warning! contains last backslash
- }
- } ;after this we have now the freshest file of this world. we change that filename to nick
- ;if not [ inString of (freshest fileNAME only) there is nick ]
- if NOT (InStr(max_path,nick,false,StrLen(max_folder)))
- {
- FileMove,%max_path%, % max_folder . nick . ".json",1
- worlds_saved+=1
- } ;cleanup removed in this version
- worlds_num:=A_Index
- } ;done world
- if not silent
- {
- if (worlds_saved=0)
- TrayTip,%ScriptName%,Nothing to save.,5,1
- else
- TrayTip,Saved - %ScriptName%,Saved %worlds_saved% out of %worlds_num% worlds.,3,1
- Sleep 3000
- } else Sleep 1000
- ExitApp
- return ;autoexec
- java_check: ;protects the script from working and possibly arguing with Minecraft for files
- if (WaitForJava=2)
- { ;wait and wake when Minecraft closed, then show a little dialog informing that we save
- Process,WaitClose,javaw.exe ;wait indefinitely
- if silent
- return
- ;so the user doesnt get the dialog so quickly (missclicks happened to me)
- TrayTip,%ScriptName%,Saving statistics in a few seconds...
- Sleep 2000
- TrayTip
- MsgBox,3,%ScriptName%,Script will save stats for %nick%.
- IfMsgBox,Yes
- return
- else
- ExitApp
- } else if (WaitForJava=1) { ;wait one second, if Minecraft process exists then exit script
- Process,WaitClose,javaw.exe,1
- if ErrorLevel
- {
- MsgBox,48,Java found! - %ScriptName%,Whew! I saved you!`nIt seems that there is an instance of JAVAW.EXE running.`nTo prevent damage the script will exit after this message.`n`nMake sure you close Minecraft before running this script.
- ExitApp
- }
- }
- return ;java_check
- settings:
- worlds_saved=0
- ScriptName=Mc stat save lite
- StringTrimRight,file_ini,A_ScriptFullPath, 3
- file_ini.="ini"
- IniRead,dir_saves,%file_ini%,Settings,dir_saves, % A_AppData . "\.minecraft\saves"
- IniRead,nick,%file_ini%,Settings,nick,ERROR
- IniRead,AlwaysAskForNick,%file_ini%,Settings,AlwaysAskForNick,0
- IniRead,WaitForJava,%file_ini%,Settings,WaitForJava,2
- IniRead,silent,%file_ini%,Settings,silent,0
- if (nick="ERROR") or (StrLen(nick)<2) or AlwaysAskForNick
- { ;please enter your nick
- InputBox,nick,Your Minecraft nick,Please enter Your Minecraft nick:,,250,120,,,,,Player
- if ErrorLevel ;dismissed nick input
- ExitApp
- }
- IfNotExist, %file_ini%
- {
- FileAppend,`;Descriptions and default values. Delete this Ini to regenerate it.`n, %file_ini%
- FileAppend,`;-----------------------------------------------------------------------`n, %file_ini%
- FileAppend,`;dir_saves=`%AppData`%\.minecraft\saves`n`;`tThis is the directory of your saves folder. No longer you have to configure this! But you may. Right here. In case you need.`n, %file_ini%
- FileAppend,`;nick=`n`;`tYour Minecraft nickname`n, %file_ini%
- FileAppend,`;AlwaysAskForNick=0`n`;`tfor multi-nickname situations`n, %file_ini%
- FileAppend,`;WaitForJava=2`n`;`tMethod of protection javaw.exe check handling [0-disable check 1-SINGLE CHECK-abort script when java found running 2-wait for java to close and then ask you]`n, %file_ini%
- FileAppend,`;silent=0`n`;`tSaves without asking. Decreases dialogs.`n, %file_ini%
- FileAppend,`;-----------------------------------------------------------------------, %file_ini%
- Sleep 100
- IniWrite, % A_AppData . "\.minecraft\saves",%file_ini%,Settings,dir_saves
- IniWrite,%nick%,%file_ini%,Settings,nick
- IniWrite,%AlwaysAskForNick%,%file_ini%,Settings,AlwaysAskForNick
- IniWrite,%WaitForJava%,%file_ini%,Settings,WaitForJava
- IniWrite,%silent%,%file_ini%,Settings,silent
- MsgBox,,Ini not found - %ScriptName%,Default values restored.,1
- }
- return ;settings
- ;----- changelog ----- times are in CET/CEST, UTC/GMT +2 hours
- /*
- 03:47 2014-10-04
- lite version
- 22:11 2014-10-17
- disabled #warn
- 14:21 2016-05-24
- found out that the launcher fixed these issues
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement