Jump to content

pause script until a variable is set


Recommended Posts

hi, right now i am trying to set up our save games for Steam, and i need the script to pause until the process variable is set, to the list of games that we have on there. so is there a way that i can make the program sleep for 1min to wait to see if this variable to set to one of our games that have save files if not the program can end. so that if one of the games listed are launched, then it will set the process variable to it and will wait until that game closes, if none of the listed games are launched then they do not have save files so the program can end if variable is not set in about 1min 30s.

any help would be appreciated.

Dim $user
$user = RegRead("HKCU\Environment", "asc_user");assigns the user to a varible ($user)

; Saves for all games copied down to local computer
DirCopy("y:\"& $user & "\Painkiller\", "D:\Valve\Steam\SteamApps\common\Painkiller Gold Edition\SaveGames", 1); Copies users file to account dir.
DirCopy("y:\"& $user & "\AdventRising\", "D:\Valve\Steam\SteamApps\common\Advent Rising\System\Saves", 1)
DirCopy("y:\"& $user & "\BloodRayne2\", "D:\Valve\Steam\SteamApps\common\BloodRayne 2\SaveGame", 1)
DirCopy("y:\"& $user & "\Flatout2\", "D:\Valve\Steam\SteamApps\common\FlatOut2\Savegame", 1)
DirCopy("y:\"& $user & "\InsaneAquarium\", "D:\Valve\Steam\SteamApps\common\Insaniquarium Deluxe\userdata", 1)
DirCopy("y:\"& $user & "\HL2E1\", "D:\Valve\Steam\SteamApps\valvecafepc798\half-life 2 episode one\episodic\SAVE", 1)
DirCopy("y:\"& $user & "\Psychonauts\", "D:\Valve\Steam\SteamApps\common\Psychonauts\Profiles", 1)
MsgBox(0,"Notice","**IF PLAYING SAVEABLE GAMES - Please ensure you exit from steam FULLY, closing the icon in the corner before logging off to save your games!! **",4)


;sets the process variable, so script knows when to close
Dim $process
If ProcessExists("HL2.exe") then $process="hl2.exe"
If ProcessExists("advent.exe") then $process="advent.exe"
If ProcessExists("rayne.exe") then $process="rayne.exe"
If ProcessExists("flatout2.exe") then $process="flatout.exe"
If ProcessExists("painkiller.exe") then $process="painkiller.exe"
If ProcessExists("psychonauts.exe") then $process="psychonauts.exe"

If IsDeclared("process") then ProcessWaitClose(""& $process&"");if $process variable has been set, script will wait for it to close 

; Saves for all games copied back to the personal drives then removed locally
;Painkiller Gold
DirCopy("D:\Valve\Steam\SteamApps\common\Painkiller Gold Edition\SaveGames", "y:\"& $user & "\Painkiller\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\common\Painkiller Gold Edition\SaveGames", 1)
;Advent Rising
DirCopy("D:\Valve\Steam\SteamApps\common\Advent Rising\System\Saves", "y:\"& $user & "\advent rising\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\common\Advent Rising\System\Saves", 1)
DirCopy("D:\Valve\Steam\SteamApps\common\BloodRayne 2\SaveGame", "y:\"& $user & "\bloodrayne 2\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\common\BloodRayne 2\SaveGame", 1)
DirCopy("D:\Valve\Steam\SteamApps\common\FlatOut2\Savegame", "y:\"& $user & "\Flatout2\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\common\FlatOut2\Savegame", 1)
;Insane Aquarium Deluxe
DirCopy("D:\Valve\Steam\SteamApps\common\Insaniquarium Deluxe\userdata", "y:\"& $user & "\InsaneAquarium\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\common\Insaniquarium Deluxe\userdata", 1)
DirCopy("D:\Valve\Steam\SteamApps\valvecafepc798\half-life 2 episode one\episodic\SAVE", "y:\"& $user & "\HL2E1\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\valvecafepc798\half-life 2 episode one\episodic\SAVE", 1)
DirCopy("D:\Valve\Steam\SteamApps\common\Psychonauts\Profiles", "y:\"& $user & "\Psychonauts\", 1); Copies users file to account dir.
DirRemove("D:\Valve\Steam\SteamApps\common\Psychonauts\Profiles", 1)
Link to comment
Share on other sites

Well, I'm guessing you're looking for a simple loop, like this:

$timer = TimerInit()
$end = 0
While $end = 0
    If TimerDiff($timer) > 60000 Then $end = 1
    If (......) Then $end = 1
Msgbox(0,"","$x is no longer equal to 0!")

Is that what you needed?


EDIT: Added timer

Edited by _Kurt

Awaiting Diablo III..

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

  • Recently Browsing   0 members

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