# cryTools: TD Tools

## External Apps

There are some exe's in the root directory (/maxscript)
scmd.exe - this is an app that will silently execute a dos command, this is no longer used, as the the latest exporter plugin now has this functionality. In the example below I sync a directory via perforce:
scmd ("p4 sync \"" + BuildPathFull_crytools + "Tools\\...\"") true
md5.exe - this is a freeware md5 hash generator, it is called from the crytools md5 function.

## Global Struct

These globally available variables can be accessed through the crytools struct. Because they are members of the struct, you must access them through it, for instance: crytools.BuildPathFull
_fnStore, _fnStoreIndex, _varStore, _varStoreIndex, - These are global storage arrays that allow variables and functions to be stored and passed via the storeFn, retrieveFn, storeVar, retrieveVar functions. These are never directly accessed.
localBuildNumber - returns the number of the local build. (The build that the current crytools /maxscript dir is loaded from)
print crytools.localBuildNumber
"5571"
BuildPathFull - returns string of the artists build path to the bin32 directory
print crytools.BuildPathFull
"J:\Game02\bin32\"
maxDirTxt - returns string of the max root dir.
print crytools.MaxDirTxt
"C:\3dsmax7\"
editorPath - path string to the Editor
crytools.editorPath
"J:\Game02\bin32\Editor.exe"
cryINI - path string to the CryTools INI file
crytools.cryINI
"C:\Program Files\Autodesk\3ds Max 2008\plugins\CryExport.ini"
maxVersionNum - returns the version number of 3D Studio Max that the script is being run on
print crytools.maxVersionNum
"8"
project_name - returns the name of the project the artist resides on, taken from the build path.
print crytools.project_name
"Game02"
latest_build - returns the name of the latest build on S:\, this global variable is set from within UpdateTools.ms, which refreshes the 'latest_builds.txt' stored in cry_temp. This is set to "NET_ERROR" if the location cannot be found on the network.
print crytools.latest_build
"Game02(2670)_03_27_FastBuild"
latestBuildNumber - returns the number of the latest build available on S:\, this global variable is set from within 'UpdateTools.ms', which refreshes the 'latest_builds.txt' stored in cry_temp.
print crytools.latestBuildNumber
"2670"
cryExportPresent - set to true or false based on whether or not the exporter plugin is loaded.
print crytools.cryExportPresent
true
cbaPath - returns string of the CBA path.
print crytools.cbaPath
"J:\Game02\Game\Animations\Animations.cba"
rollback_status - returns whether or not the exporter is currently rolled back to a previous version. This is currently stored in rollback_status.ini in the cryTemp folder.
print crytools.rollback_status
"false"
DOMAIN - returns the network domain of the network the computer is plugged into. This is set via GetDNS() once and written to the first line of cryTools.ini and then read in from there every time at load after. This var is set by AddCryTools.ms
print crytools.DOMAIN
"INTERN.CRYTEK.DE"

## Functions

These functions are added on load within AddCryTools.ms, and made available through the crytools struct.
scmd <command> wait - Silently runs a dos command using the cryengine export plugin (csexport.export.execute_command_line).
crytools.scmd ("mkdir \"" + crytools.maxDirTxt + "cry_temp\\bad\\\"") true
OK
md5 <filename_string> - Returns string MD5 hash for file queried, you must feed it a valid file. This function uses an open source, public domain MD5 executable stored in the /maxscript folder.
crytools.md5 "C:\\WINDOWS\\explorer.exe"
"A0732187050030AE399B241436565E64"
storeFn <function> <overwrite> - This stores a function in the global crytools struct where it can be used by any other script. Overwrite will overwrite any existing fn with the same name. You use retrieveFn to retrieve the var you have stored. Here is an example below from the MorphTools script:
cryTools.storeFn collapseVerts true --collapseVerts fn now stored in crytools._fnStore
crytools._fnstore
#(collapseVerts())
crytools.retrieveFn "collapseVerts()")() --now we grab the fn and use it
OK
storeVar <var> <alias> <overwrite> - This stores a variable in the global crytools struct where it can be used by any other script. The 'var' is the item you are storing, and the 'alias' is the associated name. Overwrite will overwrite a stored var with the same alias. You use retrieveVar to retrieve the var you have stored. Here is an example below from the MorphTools script:
cryTools.storeVar $ "obj1" true --selected object now stored in crytools._varStore
crytools._varstore
#($Box:Box01 @ [-101.424500,-0.000001,25.641026])
crytools.retrieveVar "obj1" --now we grab the var
$Box:Box01 @ [-101.424500,-0.000001,25.641026]
alienBrain <command_argument_string> - This executes AlienBrain command arugments from within Studio Max. It is set to execute the command via a JDK bridge/DOS command. This does not load ALienBrain.exe (or the long load screen associated with it) and executes the commands instantly and transparently in the background.
crytools.alienBrain "getlatest"
or something more complex like:
crytools.alienBrain ("ab getlatest Bin32\Tools\maxscript -s Server3 -d " + project_name + " -u login -p passwd -forcefileupdate -overwritewritable skip")
existFile <filename_string> - Returns true/false whether file exists or not
crytools.existFile "C:\\WINDOWS\\explorer.exe"
true
existDir <filename_string> - Returns true/false whether directory exists or not
crytools.existDir "C:\\WINDOWS"
true
or something more complex like:
if (crytools.existDir (maxDirTxt + "cry_temp")) == true then (print "cry_temp exists")
"cry_temp exists"
getDNS() - Returns the Domain Name Server of the local network. This uses a dos command to dump and read ipconfig info from a temp file that is then deleted; so it pops up a black cmd window for a milisecond when called. CryTools calls this once, and saves that info in cryTools.ini located in the cryTemp directory in the max root dir.
crytools.getDNS()
"INTERN.CRYTEK.DE"
MirrorObjs <Obj1> <Obj2> <MObj> <MAxis> <OAxis> - Function for mirroring joint orientations over an arbitrary axis. The below example is from CryAnimationTools.ms, you can look there to see it in use.
crytools.MirrorObjs right_arm[i] left_arm[i] $root #x #x
matchPivot <Obj1> <Obj2> - Aligns the pivot of an object to that of another
crytools.matchPivot $obj1 $obj2
findRoot <Obj> - Returns the root of the hierarchy the object is a member of
crytools.findroot $'Bip01 L Forearm'
$Editable_Mesh:Bip01 @ [0.000000,0.000038,90.368042]
getChildren <Obj> - Returns the root of the hierarchy the object is a member of
print (crytools.getchildren $'Bip01 L Thigh')
$PolyMesh:Bip01 L Calf @ [12.594235,-1.113732,49.932632]
$PolyMesh:Bip01 L Foot @ [16.074495,4.691678,9.804122]
$Editable_Mesh:Bip01 L Toe0 @ [17.749069,-7.237181,0.444188]
$Dummy:_Bip01LToeHelper @ [19.030598,-16.366177,0.444188]
$Bone:Bip01 L Toe0Nub @ [19.145245,-17.182899,0.149435]
$Bone:Bip01 L Heel @ [16.074499,4.691682,-0.687943]
$Editable_Mesh:Bip01 L knee @ [12.464909,-0.477371,47.556950]
$Dummy:Bip01 L knee_end @ [13.773256,-8.799936,43.612862]
$Editable_Mesh:weaponPos_pistol_L_leg @ [23.779840,-4.798794,68.739929]
getBips - Returns the Bipeds in the current scene
for obj in crytools.getBips() do print obj.name
"Bip01"
"Bip02"
"Bip03"
"Bip04"
getBindPoseVertexTarget <targetNode> <sourceNode> <vertexID>
CreateBindPoseMorph <targetNode> <sourceNode> <deleteYN> <addMorphYN> <channelNum> <extractedNode>
inFromUDP <targetNode> - This function reads the User Defined Properties for an object into an array
crytools.inFromUDP $
#("mass = 110", "capsule")
outToUDP <targetNode> <string_array> <echo> - This function reads/writes to the User Defined Properties buffer for an object
crytools.outToUDP #("I have needed this","for quite some time") $ true
"I have needed this
for quite some time
"
getUserPropBuffer $
"I have needed this
for quite some time
"
crytools.inFromUDP $
#("I have needed this", "for quite some time")
local2unc <string> - This will convert a local drive letter to a UNC path
crytools.local2unc "p"
"\\192.168.0.9\public"
crytools.local2unc "k"
"\\server2\Artists"
forceLowerCase <string> - This will convert a string to lowercase
crytools.forceLowerCase "MaSs = 19.9"
"mass = 19.9"
inFromINI <path> echo - This will read in a text file line by line and return an array where array element number corresponds to the line number.
crytools.infromINI (crytools.maxDirTxt + "\\plugins\\CryExport.ini") true
"[Sandbox]"
"path = J:\Game02\Bin32\Editor.exe"
"animlistpath = J:\Game02\Game\Animations\Animations.cba"
#("[Sandbox]", "path = J:\Game02\Bin32\Editor.exe", "animlistpath = J:\Game02\Game\Animations\Animations.cba")
outToINI <data> <path> echo - This will export an array to a text file line by line where array element number corresponds to the line number.
crytools.outtoini test (crytools.maxDirTxt + "\\plugins\\CryExport.ini") true
"[Sandbox]"
"path = J:\Game02\Bin32\Editor.exe"
"animlistpath = J:\Game02\Game\Animations\Animations.cba"
plusR <path> - this will check if the file exists and make it read-only
crytools.plusR (crytools.maxDirTxt + "\\plugins\\CryExport.ini")
minusR <path> - this will check if the file exists and make it writable
crytools.minusR (crytools.maxDirTxt + "\\plugins\\CryExport.ini")
objTrajectoryToSpline <obj> - this will create a spline showing the trajectory of all selected objects
cutString <string input> <string to cut> - this removes the 'string to cut' from the 'string input'.
crytools.cutString "Crysis is a beautiful, meticulously designed game" ", meticulously designed"
"Crysis is a beautiful game"
vertDistance <pos> <pos> - this will output the distance between two positions in space
crytools.vertDistance $Box01.pos $Box02.pos
169.997
copyPasteController <parentObj> <selOrChild> <copyWhat> - this will copy and paste a controller, here is an example from CryRiggingTools:
crytools.copyPasteController mObj "children" "rp"
sliderMan - this is a fn that works on a selection callback, when you select a slider manipulator, it always goes into manipulate mode so that it can be used.

## Items Stored In cry_temp\

A folder named 'cry_temp' is created by AddCryTools.ms, CryTools store many things in this folder, like the following examples:
crytools.ini - This stores suer-specific options, such as window layout and control panel settings. I will work to fold some of the other droppings below into this single INI file. Here are some of the things stored within:
DOMAIN:INTERN.CRYTEK.DE
WARNMATS:true
REPARENT:true
SUPPRESS:false
NO_UNPARENT_WEAPON:false
RIGGING_POS:1396:78
ANIMATION_POS:1192:78
MORPH_POS:2072:70
ARTIST_POS:698:457
SPLASH:true
UPDATE_COLLECTIONS:false
SYNC_COLLECTIONS:false
LOADOLDANIMTOOLS:false
GENERATEMENU:true
latest_builds.txt - When UpdateTools.ms is run, it dumps the latest builds from S:\_Builds\ into this txt file.
paths.txt - When CryTools were installed, the InstallCryTools.vbs created this txt file, it stores the install path of StudioMax and Photoshop. The first line is always StudioMax and the second Photoshop.
C:\3dsmax7C:\graphics\Adobe Photoshop CS2\Plug-Ins\
rollback_status.ini - A value of true/false is stored in this file. When an artist has rolled back their exporter, the file is set to 'true', when 'Get Latest Tools From AlienBrain/Latest Build' is pressed in UpdateTools, rollback status is set to 'false' because the latest exporter is installed.
CryExport7.dlu, Morpher.dlm, MorpherMXS.dlx - When new copies of these are installed, the prior versions are saved here, where they can be rolled back to on demand. Currently, the rollback function only exists for CryExport7.dlu.