Advertisement
Guest User

Untitled

a guest
Aug 14th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. #   sdGetGlobal( 'MyModName', 'GlobalVariableName' )
  2. #   Fetches a specific variable's value from the mod's global data set.
  3. def sdGetGlobal( ModID, var ):
  4.     szGlobal = 'Global'
  5.     mTable   = sdModLoad(ModID)
  6.     if ( mTable.has_key(szGlobal) ):
  7.         eTable    = pickle.loads(mTable[szGlobal])
  8.         if ( eTable.has_key(var) ):
  9.             # sdEcho('%s : sdGetGlobal : %s, %s = %d' %(ModID, szGlobal, var, eTable[var]))
  10.             return eTable[var]
  11.  
  12. #   sdSetGlobal( 'MyModName', 'GlobalVariableName', any_value )
  13. #   Stores a specific variable's value within the mod's global data set.
  14. def sdSetGlobal( ModID, var, val ):
  15.     szGlobal = 'Global'
  16.     mTable           = sdModLoad(ModID)
  17.     if ( mTable.has_key(szGlobal) ):
  18.         eTable   = pickle.loads(mTable[szGlobal])
  19.     else:
  20.         eTable   = {}
  21.     eTable[var]      = val
  22.     mTable[szGlobal] = pickle.dumps(eTable)
  23.     sdModSave(ModID, mTable)
  24.  
  25. #   sdDelGlobal( 'MyModName', 'GlobalVariableName' )
  26. #   Removes a specific variable from the mod's global data set.
  27. #   Returns bool False on failure, bool True on success.
  28. def sdDelGlobal( ModID, var ):
  29.     szGlobal = 'Global'
  30.     mTable           = sdModLoad(ModID)
  31.     if ( mTable.has_key(szGlobal) ):
  32.         eTable           = pickle.loads(mTable[szGlobal])
  33.         if ( eTable.has_key(var) ):
  34.             del eTable[var]
  35.             mTable[szGlobal] = pickle.dumps(eTable)
  36.             sdModSave(ModID, mTable)
  37.             return True
  38.     return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement