def GetChildInfo(args): import Plasma vault = Plasma.ptVault() hoodGUID = vault.getLinkToMyNeighborhood().getAgeInfo().getAgeInstanceGuid() print "hoodGUID: ",hoodGUID parentname = None agevault = Plasma.ptAgeVault() ageinfo = agevault.getAgeInfo() #agerules = agevault.getLinkingRules() parent = ageinfo.getParentAgeLink() if parent == None: agename = ageinfo.getAgeFilename() print "not a child age. age = ",agename #print "with linking rules: ",agerules return parentinfo = parent.getAgeInfo() parentname = parentinfo.getAgeFilename() parentGUID = parentinfo.getAgeInstanceGuid() print "parentGUID: ",parentGUID if parentname == "Neighborhood": if hoodGUID == parentGUID: print "child of hood: yes" else: print "child of hood: different" else: print "child of hood: no"
def ResetBahro(args): import Plasma #import PlasmaTypes ageName = Plasma.PtGetAgeName() if ageName == "Cleft": sdl = Plasma.PtGetAgeSDL() sdl["clftSceneBahroUnseen"] = (1,)
def PtVerifyGZMarker(): import Plasma import PlasmaTypes # get current GZ Game state (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) = PtDetermineGZ() # make sure there is room for the capture marker if GZPlaying: # set the marker status to 'gotten' # ...in the GZ marker chronicle vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(kChronicleGZMarkersAquired) if type(entry) != type(None): markers = entry.chronicleGetValue() # get what was really gotten totalGotten = markers.count(kGZMarkerCaptured) KIMarkerLevel = PtDetermineKIMarkerLevel() if KIMarkerLevel > kKIMarkerFirstLevel: # if this is the second wave of markers (or beyond) totalGotten -= 5 if totalGotten < 0: totalGotten = 0 if totalGotten > MarkerToGetNumber: totalGotten = MarkerToGetNumber if totalGotten != MarkerGottenNumber: PlasmaTypes.PtDebugPrint("PtVerifyGZMarker: Error! Gotten different than real. They say=%d We say=%d"%(MarkerGottenNumber,totalGotten),level=PlasmaTypes.kErrorLevel ) MarkerGottenNumber = totalGotten # save update to chronicle PtUpdateGZGamesChonicles(GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) Plasma.PtSendKIMessage(kGZUpdated,0) return (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber)
def SetSDL(varNameAndVal): import Plasma ageSDL = Plasma.PtGetAgeSDL() varNameAndValList = varNameAndVal.split("_") varName = varNameAndValList[0] newval = int(varNameAndValList[1]) oldval = ageSDL[varName][0] if newval == oldval: print "xCheat.SetSDL(): won't change, %s is already = %d" % (varName, newval) return ageName = Plasma.PtGetAgeName() if ageName == "Personal": vault = Plasma.ptVault() psnlSDL = vault.getPsnlAgeSDL() FoundValue = psnlSDL.findVar(varName) FoundValue.setInt(newval) vault.updatePsnlAgeSDL(psnlSDL) else: ageSDL.setFlags(varName, 1, 1) ageSDL.sendToClients(varName) #ageSDL.setNotify(self.key,varName,0.0) ageSDL[varName] = (newval, ) print "xCheat.SetSDL(): changing %s to %d" % (varName, newval)
def InstaPellets(args): import Plasma import string ageName = Plasma.PtGetAgeName() if ageName == "Ercana": sdl = Plasma.PtGetAgeSDL() if args == "": print "xCheat.InstantPellets: ERROR. Must specify a recipe value as argument." else: PelletsPresent = sdl["ercaPelletMachine"][0] if PelletsPresent: print "xCheat.InstantPellets: ERROR. Must flush current pellets before using this cheat." else: iarg = string.atoi(args) if iarg == 0: iarg = 1 recipeSDL = (iarg + 300) if recipeSDL < 1: recipeSDL = 1 print "xCheat.InstantPellets: 5 pellets now created with Recipe of %d." % (iarg) sdl["ercaPellet1"] = (recipeSDL,) sdl["ercaPellet2"] = (recipeSDL,) sdl["ercaPellet3"] = (recipeSDL,) sdl["ercaPellet4"] = (recipeSDL,) sdl["ercaPellet5"] = (recipeSDL,)
def PtVerifyGZMarker(): import Plasma import PlasmaTypes (GZPlaying, MarkerGottenColor, MarkerToGetColor, MarkerGottenNumber, MarkerToGetNumber) = PtDetermineGZ() if GZPlaying: vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleGZMarkersAquired) if (type(entry) != type(None)): markers = entry.chronicleGetValue() totalGotten = markers.count(kGZMarkerCaptured) KIMarkerLevel = PtDetermineKIMarkerLevel() if (KIMarkerLevel > kKIMarkerFirstLevel): totalGotten -= 5 if (totalGotten < 0): totalGotten = 0 if (totalGotten > MarkerToGetNumber): totalGotten = MarkerToGetNumber if (totalGotten != MarkerGottenNumber): PlasmaTypes.PtDebugPrint(( 'PtVerifyGZMarker: Error! Gotten different than real. They say=%d We say=%d' % (MarkerGottenNumber, totalGotten)), level=PlasmaTypes.kErrorLevel) MarkerGottenNumber = totalGotten PtUpdateGZGamesChonicles(GZPlaying, MarkerGottenColor, MarkerToGetColor, MarkerGottenNumber, MarkerToGetNumber) Plasma.PtSendKIMessage(kGZUpdated, 0) return (GZPlaying, MarkerGottenColor, MarkerToGetColor, MarkerGottenNumber, MarkerToGetNumber)
def GenerateCleftSolution(args): import Plasma import xRandom solutionlist = [3,2,5,0] cleftSolList = [3,2,5,0] while _AreListsEquiv(solutionlist, cleftSolList): solutionlist = [] while len(solutionlist) < 4: newint = xRandom.randint(0,6) if not newint in solutionlist: solutionlist.append(newint) vault = Plasma.ptVault() entry = vault.findChronicleEntry("BahroCave") entry.removeAllNodes() if entry != None: agelist = ["Teledahn", "Garrison", "Garden", "Kadish"] for v in range(len(agelist)): newnode = Plasma.ptVaultChronicleNode(0) newnode.chronicleSetName(agelist[v]) ageVal = str(solutionlist[v]) newnode.chronicleSetValue("1," + ageVal + "," + str(v + 1)) #newnode.chronicleSetValue("1," + str(solutionlist[v]) + "," + str(v + 1)) entry.addNode(newnode) print "%s solution is %s" % (agelist[v], ageVal)
def RemoveMarkerTag(args): import Plasma import PlasmaKITypes newlevel = "0" vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(PlasmaKITypes.kChronicleKIMarkerLevel) if type(entry) != type(None): entry.chronicleSetValue(newlevel) entry.save() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(PlasmaKITypes.kChronicleGZGames) if type(entry) != type(None): entry.chronicleSetValue("0") entry.save() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(PlasmaKITypes.kChronicleGZMarkersAquired) if type(entry) != type(None): entry.chronicleSetValue("") entry.save() Plasma.PtSendKIMessage(PlasmaKITypes.kGZUpdated,0) # get rid of the CGZ marker games MGs = [ 'MG01','MG02','MG03','MG04','MG05','MG06','MG07','MG08','MG09','MG10','MG11','MG12','MG13','MG14'] for mg in MGs: entry = vault.findChronicleEntry(mg) if type(entry) != type(None): entry.chronicleSetValue("") entry.save() entry = vault.findChronicleEntry("CGZPlaying") if type(entry) != type(None): entry.chronicleSetValue("") entry.save()
def GetAgeJourneyCloths(args): import Plasma ageChronNode = None ageName = Plasma.PtGetAgeName() if ageName == "Gira" or ageName == "Garden": ageName = "Eder" elif ageName == "Teledahn" or ageName == "Garrison" or ageName == "Kadish" or ageName == "Cleft": pass else: return vault = Plasma.ptVault() chron = vault.findChronicleEntry("JourneyClothProgress") ageChronRefList = chron.getChildNodeRefList() for ageChron in ageChronRefList: ageChild = ageChron.getChild() ageChild = ageChild.upcastToChronicleNode() if ageChild.chronicleGetName() == ageName: ageChronNode = ageChild break if type(ageChronNode) == type(None): newNode = Plasma.ptVaultChronicleNode(0) newNode.chronicleSetName(ageName) newNode.chronicleSetValue("abcdefg") chron.addNode(newNode) else: ageChronNode.chronicleSetValue("abcdefg") ageChronNode.save()
def ImportMarkers(args): "args = 'filename folder'" import Plasma import PlasmaVaultConstants arglist = args.split() if len(arglist) < 2: print 'ERROR - not enough arguments - ImportMarkers "filename foldername")' return filename = arglist[0] try: dfile = open(filename + '.py', 'r') except IOError: print "ERROR - file %d could not be found" % (filename + '.py') return dfile.close() argresidual = args[len(filename) + 1:] #== find the folder where the markerfolders might be # search thru the age journal folders vault = Plasma.ptVault() jfolder = None master_agefolder = vault.getAgeJournalsFolder() if type(master_agefolder) != type(None): agefolderRefs = master_agefolder.getChildNodeRefList() for agefolderRef in agefolderRefs: agefolder = agefolderRef.getChild() agefolder = agefolder.upcastToFolderNode() if type(agefolder) != type(None): # might be a foldername with spaces! so see if it starts with the name if argresidual.startswith(agefolder.folderGetName()): jfolder = agefolder argresidual = argresidual[len(agefolder.folderGetName()) + 1:] if jfolder: exec("import %s" % (filename)) exec("mgs = %s.mgs" % (filename)) for mg in mgs: # need to try to find the game to stick these in jfolderRefs = jfolder.getChildNodeRefList() for jref in jfolderRefs: jnode = jref.getChild() jnode = jnode.upcastToMarkerListNode() # is it a marker folder list? if type(jnode) != type(None): # is it named the right one? if jnode.folderGetName() == mg[1]: # yes, add the markers to this game for marker in mg[0][4]: nMarker = Plasma.ptVaultMarkerNode( PlasmaVaultConstants. PtVaultNodePermissionFlags.kDefaultPermissions) nMarker.markerSetText(marker[0]) pos = Plasma.ptPoint3(marker[1], marker[2], marker[3]) nMarker.markerSetPosition(pos) nMarker.markerSetAge(marker[4]) nMarker.markerSetGPS(marker[5], marker[6], marker[7]) jnode.addNode(nMarker)
def GZGetMarkers(args): import Plasma import PlasmaKITypes import string try: markersToGet = string.atoi(args) except ValueError: markersToGet = 0 if markersToGet: vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(PlasmaKITypes.kChronicleGZGames) if type(entry) != type(None): gameString = entry.chronicleGetValue() gargs = gameString.split() if len(gargs) == 3: try: markerGame = string.atoi(gargs[0]) colors = gargs[1].split(':') markerGottenColor = colors[0] markerToGetColor = colors[1] outof = gargs[2].split(':') markerGottenNumber = string.atoi(outof[0]) markerToGetNumber = string.atoi(outof[1]) newgotten = markerGottenNumber + markersToGet if newgotten > markerToGetNumber: newgotten = markerToGetNumber print "Updating markers gotten to %d from %d" % (newgotten,markerToGetNumber) upstring = "%d %s:%s %d:%d" % (markerGame,markerGottenColor,markerToGetColor,newgotten,markerToGetNumber) entry.chronicleSetValue(upstring) entry.save() # just pick some marker to have gotten # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(PlasmaKITypes.kChronicleGZMarkersAquired) if type(entry) != type(None): markers = entry.chronicleGetValue() for mnum in range(markersToGet): markerIdx = markers.index(PlasmaKITypes.kGZMarkerAvailable) if markerIdx >= 0 and markerIdx < len(markers): # Set the marker to "captured" if len(markers)-(markerIdx+1) != 0: markers = markers[:markerIdx] + PlasmaKITypes.kGZMarkerCaptured + markers[-(len(markers)-(markerIdx+1)):] else: markers = markers[:markerIdx] + PlasmaKITypes.kGZMarkerCaptured print "Update marker #%d - out string is '%s'" % (markerIdx+1,markers) entry.chronicleSetValue(markers) entry.save() # update the Plasma.PtSendKIMessage(PlasmaKITypes.kGZUpdated,0) return except ValueError: print "xKI:GZ - error trying to read GZGames Chronicle '%s'" % (gameString) else: print "xKI:GZ - error GZGames string formation error (len=%d)" % (len(gargs)) else: # if there is none, then error print "Error - there is no GZMarker game going!"
def GetSDL(varName): """ GetSDL is used to get the value of an Age SDL variable by name. Expects one argument: (string) VariableName """ import Plasma if not varName: print("xCheat.GetSDL(): GetSDL takes one argument: SDL variable name is required.\n Use 'all' to list all variables for the current Age.") return ageName = Plasma.PtGetAgeName() try: ageSDL = Plasma.PtGetAgeSDL() except: print(("xCheat.GetSDL(): Unable to retrieve SDL for '{}'.".format(ageName))) return varList = [] if varName == "all": if ageName == "Personal": varRecord = Plasma.ptVault().getPsnlAgeSDL() if varRecord: varList = varRecord.getVarList() else: vault = Plasma.ptAgeVault() if vault: varRecord = vault.getAgeSDL() if varRecord: varList = varRecord.getVarList() if not varList: print("xCheat.GetSDL(): Couldn't retrieve SDL list.") return maxlen = len(max(varList, key=len)) for var in varList: try: if len(ageSDL[var]) == 0: val = "" else: val = ageSDL[var][0] print(("xCheat.GetSDL(): {:>{width}} = {}".format(var, val, width=maxlen))) except: print(("xCheat.GetSDL(): Error retrieving value for '{}'.".format(var))) else: try: if len(ageSDL[varName]) == 0: print(("xCheat.GetSDL(): SDL variable '{}' is not set.".format(varName))) else: print(("xCheat.GetSDL(): {} = {}".format(varName, ageSDL[varName][0]))) except: print(("xCheat.GetSDL(): SDL variable '{}' not found.".format(varName))) return
def GetSDL(varName): """ GetSDL is used to get the value of an Age SDL variable by name. Expects one argument: (string) VariableName """ import Plasma if not varName: print("xCheat.GetSDL(): GetSDL takes one argument: SDL variable name is required.\n Use 'all' to list all variables for the current Age.") return ageName = Plasma.PtGetAgeName() try: ageSDL = Plasma.PtGetAgeSDL() except: print("xCheat.GetSDL(): Unable to retrieve SDL for '{}'.".format(ageName)) return varList = [] if varName == "all": if ageName == "Personal": varRecord = Plasma.ptVault().getPsnlAgeSDL() if varRecord: varList = varRecord.getVarList() else: vault = Plasma.ptAgeVault() if vault: varRecord = vault.getAgeSDL() if varRecord: varList = varRecord.getVarList() if not varList: print("xCheat.GetSDL(): Couldn't retrieve SDL list.") return maxlen = len(max(varList, key=len)) for var in varList: try: if len(ageSDL[var]) == 0: val = "" else: val = ageSDL[var][0] print("xCheat.GetSDL(): {:>{width}} = {}".format(var, val, width=maxlen)) except: print("xCheat.GetSDL(): Error retrieving value for '{}'.".format(var)) else: try: if len(ageSDL[varName]) == 0: print("xCheat.GetSDL(): SDL variable '{}' is not set.".format(varName)) else: print("xCheat.GetSDL(): {} = {}".format(varName, ageSDL[varName][0])) except: print("xCheat.GetSDL(): SDL variable '{}' not found.".format(varName)) return
def GetMarkersAddGZLink(): agelinks = Plasma.ptVault().getAgesIOwnFolder().getChildNodeRefList() for agelink in agelinks: aln = agelink.getChild().upcastToAgeLinkNode() age = aln.getAgeInfo().getAgeFilename() if age=="GreatZero": spawnpoint = Plasma.ptSpawnPointInfo("Great Zero","BigRoomLinkInPoint") aln.addSpawnPoint(spawnpoint) aln.save() return True return False
def HideObject(objectname): #Hides and disables a sceneobject #print "hide:"+objectname agename = Plasma.PtGetAgeName() try: av = Plasma.PtFindSceneobject(objectname, agename) except: print "_UamUtils.HideObject unable to find object: " + objectname return False av.draw.disable() av.physics.suppress(1) return True
def GetMarkersAddGZLink(): agelinks = Plasma.ptVault().getAgesIOwnFolder().getChildNodeRefList() for agelink in agelinks: aln = agelink.getChild().upcastToAgeLinkNode() age = aln.getAgeInfo().getAgeFilename() if age == "GreatZero": spawnpoint = Plasma.ptSpawnPointInfo("Great Zero", "BigRoomLinkInPoint") aln.addSpawnPoint(spawnpoint) aln.save() return True return False
def ImportMarkers(args): "args = 'filename folder'" import Plasma import PlasmaVaultConstants arglist = args.split() if len(arglist) < 2: print 'ERROR - not enough arguments - ImportMarkers "filename foldername")' return filename = arglist[0] try: dfile = open(filename+'.py','r') except IOError: print "ERROR - file %d could not be found" % (filename+'.py') return dfile.close() argresidual = args[len(filename)+1:] #== find the folder where the markerfolders might be # search thru the age journal folders vault = Plasma.ptVault() jfolder = None master_agefolder = vault.getAgeJournalsFolder() if type(master_agefolder) != type(None): agefolderRefs = master_agefolder.getChildNodeRefList() for agefolderRef in agefolderRefs: agefolder = agefolderRef.getChild() agefolder = agefolder.upcastToFolderNode() if type(agefolder) != type(None): # might be a foldername with spaces! so see if it starts with the name if argresidual.startswith(agefolder.folderGetName()): jfolder = agefolder argresidual = argresidual[len(agefolder.folderGetName())+1:] if jfolder: exec("import %s" % (filename)) exec("mgs = %s.mgs" % (filename)) for mg in mgs: # need to try to find the game to stick these in jfolderRefs = jfolder.getChildNodeRefList() for jref in jfolderRefs: jnode = jref.getChild() jnode = jnode.upcastToMarkerListNode() # is it a marker folder list? if type(jnode) != type(None): # is it named the right one? if jnode.folderGetName() == mg[1]: # yes, add the markers to this game for marker in mg[0][4]: nMarker = Plasma.ptVaultMarkerNode(PlasmaVaultConstants.PtVaultNodePermissionFlags.kDefaultPermissions) nMarker.markerSetText(marker[0]) pos = Plasma.ptPoint3(marker[1],marker[2],marker[3]) nMarker.markerSetPosition(pos) nMarker.markerSetAge(marker[4]) nMarker.markerSetGPS(marker[5],marker[6],marker[7]) jnode.addNode(nMarker)
def SetSDL(varNameAndVal): """ SetSDL is used to set an Age SDL variable by name. It expects two arguments: (string) VariableName, (int) NewValue """ import Plasma if not varNameAndVal: print("xCheat.SetSDL(): SetSDL takes two arguments: SDL variable name and new value are required.") return varNameAndValList = varNameAndVal.split("_") if (len(varNameAndValList) < 2) or varNameAndValList[1] == "": print("xCheat.SetSDL(): No new value specified.") return varName = varNameAndValList[0] try: newval = int(varNameAndValList[1]) except ValueError: print(("xCheat.SetSDL(): Can't use '{}'. Only numerical SDL values are supported.".format(varNameAndValList[1]))) return ageName = Plasma.PtGetAgeName() try: ageSDL = Plasma.PtGetAgeSDL() except: print(("xCheat.SetSDL(): Unable to retrieve SDL for '{}'.".format(ageName))) return try: oldval = ageSDL[varName][0] except KeyError: print(("xCheat.SetSDL(): SDL variable '{}' not found.".format(varName))) return if newval == oldval: print(("xCheat.SetSDL(): Not changing value, '{}' is already {}.".format(varName, newval))) return if ageName == "Personal": vault = Plasma.ptVault() psnlSDL = vault.getPsnlAgeSDL() FoundValue = psnlSDL.findVar(varName) FoundValue.setInt(newval) vault.updatePsnlAgeSDL(psnlSDL) else: ageSDL.setFlags(varName, 1, 1) ageSDL.sendToClients(varName) ageSDL[varName] = (newval,) print(("xCheat.SetSDL(): Setting '{}' to {} (was {}).".format(varName, newval, oldval)))
def PtUpdateCGZStartTime(time=None): chron = PtFindCreateMarkerChronicle("CGZ-StartTime") if time is None: import Plasma time = Plasma.PtGetServerTime() chron.setValue(str(time)) chron.save()
def PtDetermineGZ(): "Get the current GZ states" import Plasma import PlasmaTypes import string GZPlaying = 0 MarkerToGetColor = 'off' MarkerGottenColor = 'off' MarkerToGetNumber = 0 MarkerGottenNumber = 0 KIMarkerLevel = PtDetermineKIMarkerLevel() if KIMarkerLevel > kKIMarkerNotUpgraded: # see if they are playing a CGZ game (whichGame, state) = PtWhichCGZPlaying() if KIMarkerLevel < kKIMarkerNormalLevel or ( KIMarkerLevel == kKIMarkerNormalLevel and whichGame != -1): vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(kChronicleGZGames) if type(entry) != type(None): gameString = entry.chronicleGetValue() PlasmaTypes.PtDebugPrint("PtDetermineGZ: - game string is %s" % (gameString), level=PlasmaTypes.kDebugDumpLevel) args = gameString.split() if len(args) == 3: try: GZPlaying = string.atoi(args[0]) colors = args[1].split(':') MarkerGottenColor = colors[0] MarkerToGetColor = colors[1] outof = args[2].split(':') MarkerGottenNumber = string.atoi(outof[0]) MarkerToGetNumber = string.atoi(outof[1]) except ValueError: PlasmaTypes.PtDebugPrint( "xKI:GZ - error trying to read GZGames Chronicle", level=PlasmaTypes.kErrorLevel) # we don't know which one it errored on, so just reset them all GZPlaying = 0 MarkerToGetColor = 'off' MarkerGottenColor = 'off' MarkerToGetNumber = 0 MarkerGottenNumber = 0 else: PlasmaTypes.PtDebugPrint( "xKI:GZ - error GZGames string formation error", level=PlasmaTypes.kErrorLevel) pass else: # can't be playing a GZGame! # ...might be a MarkerTag game... let the KI determine that. pass PlasmaTypes.PtDebugPrint( "PtDetermineGZ: - returning game=%d colors=%s:%s markers=%d:%d" % (GZPlaying, MarkerGottenColor, MarkerToGetColor, MarkerGottenNumber, MarkerToGetNumber), level=PlasmaTypes.kDebugDumpLevel) return (GZPlaying, MarkerGottenColor, MarkerToGetColor, MarkerGottenNumber, MarkerToGetNumber)
def GetLakeScore(self): import Plasma lakeScoreList = Plasma.ptScoreMgr().getGlobalScores("LakeScore") if lakeScoreList: print "the global LakeScore = ",lakeScoreList[0].getValue() else: print "no LakeScore found!"
def PtGetCGZGameState(whichGame): import Plasma import PlasmaTypes if ((whichGame >= kCGZFirstGame) and (whichGame <= kCGZFinalGame)): vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) if (type(entry) != type(None)): allStates = entry.chronicleGetValue() PlasmaTypes.PtDebugPrint( ('PlasmaKITypes:PtGetCGZGameLevel current chronicle is %s' % allStates), level=PlasmaTypes.kDebugDumpLevel) state = kCGZMarkerInactive try: state = allStates[whichGame] except LookupError: PlasmaTypes.PtDebugPrint(( 'PlasmaKITypes:PtGetCGZGameLevel - CGZ marker game not there? chron=%s' % allStates), level=PlasmaTypes.kErrorLevel) return state else: PlasmaTypes.PtDebugPrint( 'PlasmaKITypes:PtGetCGZGameLevel no chronicle yet', level=PlasmaTypes.kDebugDumpLevel) else: PlasmaTypes.PtDebugPrint( ('PlasmaKITypes:PtGetCGZGameLevel - invalid CGZ game of %d' % whichGame), level=PlasmaTypes.kErrorLevel) return kCGZMarkerInactive
def PtUpdateGZGamesChonicles(GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber): "Update the GZ chronicle variable" import Plasma import PlasmaTypes vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(kChronicleGZGames) try: upstring = "%d %s:%s %d:%d" % (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) if type(entry) != type(None): entry.chronicleSetValue(upstring) entry.save() else: # if there is none, then just add another entry vault.addChronicleEntry(kChronicleGZGames,kChronicleGZGamesType,upstring) except TypeError: if type(GZPlaying) != type(0): PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be integer)",level=PlasmaTypes.kErrorLevel ) pass if type(MarkerToGetColor) != type(""): PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be string)",level=PlasmaTypes.kErrorLevel ) pass if type(MarkerGottenColor) != type(""): PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be string)",level=PlasmaTypes.kErrorLevel ) pass if type(MarkerToGetNumber) != type(0): PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be integer)",level=PlasmaTypes.kErrorLevel ) pass if type(MarkerGottenNumber) != type(0): PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be integer)",level=PlasmaTypes.kErrorLevel ) pass pass
def _IGetYeeshaPageDefs(self, old_method = BlackBarBodyKIHandler.xKI.IGetYeeshaPageDefs): print "_UamModReltopages._IGetYeeshaPageDefs" result = old_method(self) #Can only change this while in your Relto import Plasma vault = Plasma.ptVault() if not vault.inMyPersonalAge(): result += "<pb><pb><font size=20><p align=center>You can only change the fan-made pages while on your Relto." return result #Get the current status of the pages import uam chronstr = uam.GetAgeChronicle("UamReltoPages") #on, off, or unattained pages = _UamUtils._StringToDict(chronstr) for page in ReltoPages: pagedict = ReltoPages[page] pagenum = int(pagedict["pagenum"]) lang = _UamUtils.GetLanguage() print "language: "+`lang` linktext = pagedict["text--"+lang] linknum = pagenum + 200 #just to get it out of Cyan's hair turnedon = 1 #1 or 0 status = pages.get(page,pagedict["default"]) #Get the status or use the default for this page. print "status: "+status if status=="on": turnedon = 1 else: turnedon = 0 #either off or unattained if status=="on" or status=="off": result += '<pb><font size=20><p align=center>'+linktext+'<pb><img src="xYeeshaPageAlphaSketchFiremarbles*1#0.hsm" align=center check=00ff18,00800c,'+str(turnedon)+' link='+str(linknum)+'>' return result
def PtGetCGZGameState(whichGame): "Get the CGZ Game level" # assume that they have none... import Plasma import PlasmaTypes if whichGame >= kCGZFirstGame and whichGame <= kCGZFinalGame: vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) if type(entry) != type(None): allStates = entry.chronicleGetValue() PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel current chronicle is %s"%(allStates),level=PlasmaTypes.kDebugDumpLevel) state = kCGZMarkerInactive # assume inactive try: state = allStates[whichGame] except LookupError: PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel - CGZ marker game not there? chron=%s"%(allStates),level=PlasmaTypes.kErrorLevel) pass return state else: PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel no chronicle yet",level=PlasmaTypes.kDebugDumpLevel) else: PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel - invalid CGZ game of %d"%(whichGame),level=PlasmaTypes.kErrorLevel) pass # if couldn't be determine... just assume lowest form return kCGZMarkerInactive
def ShowHiddenFolder(args): import Plasma # search thru the age journal folders vault = Plasma.ptVault() jfolder = None master_agefolder = vault.getAgeJournalsFolder() if type(master_agefolder) != type(None): agefolderRefs = master_agefolder.getChildNodeRefList() for agefolderRef in agefolderRefs: agefolder = agefolderRef.getChild() agefolder = agefolder.upcastToFolderNode() if type(agefolder) != type(None): # look for the Hidden folder if "Hidden" == agefolder.folderGetName(): jfolder = agefolder break if jfolder: # need to try to find the game print "Hidden folder contents:" folderRefs = jfolder.getChildNodeRefList() for jref in folderRefs: jnode = jref.getChild() jnode = jnode.upcastToMarkerListNode() # is it a marker folder list? if type(jnode) != type(None): # is it named the right one? print "markerFolder - ",jnode.folderGetName() else: print "There is no Hidden folder"
def PtGetMarkerGameChronicle(): import Plasma vault = Plasma.ptVault() chron = vault.findChronicleEntry("MarkerBrain") if chron is None: vault.addChronicleEntry("MarkerBrain", 0, "") return vault.findChronicleEntry("MarkerBrain") return chron
def Timer(callback, time, isweak, removewhenlink): #calls the function with the given context in 'time' seconds #print "_UamTimer.Timer adding timer" id = _GetNextTimerId() if isweak: callback = weakref.ref(callback) _timers[id] = (callback, isweak, removewhenlink) Plasma.PtAtTimeCallback(uam._ki.key, time, id)
def _DisplayBook(text, isOpen, booktype): #booktype can be bkNotebook, bkBook, or bkBahroRockBook global _book _book = Plasma.ptBook(text, _ki.key) _book.setSize(1.0, 1.0) _book.setGUI(booktype) _book.allowPageTurning(True) _book.show(isOpen)
def GetSDL(varName): import Plasma ageName = Plasma.PtGetAgeName() ageSDL = Plasma.PtGetAgeSDL() varList = [] if varName == "all": vault = Plasma.ptVault() # myAges = vault.getAgesIOwnFolder() # myAges = myAges.getChildNodeRefList() # for ageInfo in myAges: # link = ageInfo.getChild() # link = link.upcastToAgeLinkNode() # info = link.getAgeInfo() # if not info: # continue # tmpAgeName = info.getAgeFilename() # if ageName == tmpAgeName: if ageName == "Personal": varRecord = vault.getPsnlAgeSDL() varList = varRecord.getVarList() else: #link = ageInfo.getChild() #if link.getType() == PlasmaVaultConstants.PtVaultNodeTypes.kSDLNode: #thisSDL = link.upcastToSDLNode() #thisSDL = info.getAgeSDL() #varRecord = ageSDL.getStateDataRecord() #varList = ageSDL.getVarList() pass if varList == []: print "xCheat.GetSDL(): couldn't retrieve SDL list" return for var in varList: try: val = ageSDL[var][0] print "xCheat.GetSDL():\t%s\t\t= %d" % (var,val) except: pass else: try: val = ageSDL[varName][0] print "xCheat.GetSDL(): %s = %d" % (varName,val) except: print "xCheat.GetSDL(): %s not found!" % (varName)
def ImportGames(args): "args = 'filename folder'" import Plasma import PlasmaVaultConstants arglist = args.split() if len(arglist) < 2: print 'ERROR - not enough arguments - ImportMarkers "filename foldername")' return filename = arglist[0] try: dfile = open(filename + '.py', 'r') except IOError: print "ERROR - file %d could not be found" % (filename + '.py') return dfile.close() argresidual = args[len(filename) + 1:] #== find the folder where the markerfolders might be # search thru the age journal folders vault = Plasma.ptVault() jfolder = None master_agefolder = vault.getAgeJournalsFolder() if type(master_agefolder) != type(None): agefolderRefs = master_agefolder.getChildNodeRefList() for agefolderRef in agefolderRefs: agefolder = agefolderRef.getChild() agefolder = agefolder.upcastToFolderNode() if type(agefolder) != type(None): # might be a foldername with spaces! so see if it starts with the name if argresidual.startswith(agefolder.folderGetName()): jfolder = agefolder argresidual = argresidual[len(agefolder.folderGetName()) + 1:] if jfolder: exec("import %s" % (filename)) exec("mgs = %s.mgs" % (filename)) for mg in mgs: nMarkerFolder = Plasma.ptVaultMarkerListNode( PlasmaVaultConstants.PtVaultNodePermissionFlags. kDefaultPermissions) nMarkerFolder.folderSetName(mg[1]) nMarkerFolder.setOwnerID(mg[0][0]) nMarkerFolder.setOwnerName(mg[0][1]) nMarkerFolder.setGameType(mg[0][2]) nMarkerFolder.setRoundLength(mg[0][3]) jfolder.addNode(nMarkerFolder)
def PtDetermineKIMarkerLevel(): import Plasma import string vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleKIMarkerLevel) if (type(entry) != type(None)): level = string.atoi(entry.chronicleGetValue()) return level return kKIMarkerNotUpgraded
def GZGiveMeFullAccess(args): import Plasma import PlasmaKITypes Plasma.PtSendKIMessageInt(PlasmaKITypes.kUpgradeKIMarkerLevel,PlasmaKITypes.kKIMarkerNormalLevel) #Make sure to update the markers too, as we don't want them to display!!! import grtzKIMarkerMachine grtzKIMarkerMachine.UpdateGZMarkers(PlasmaKITypes.kGZMarkerUploaded) #reset KI's marker display resetString = "0 off:off 0:0" vault = Plasma.ptVault() entry = vault.findChronicleEntry(PlasmaKITypes.kChronicleGZGames) if type(entry) != type(None): entry.chronicleSetValue(resetString) # Finally, update the KI display Plasma.PtSendKIMessage(PlasmaKITypes.kGZUpdated,0)
def GZGiveMeGPS(args): import Plasma import PlasmaKITypes vault = Plasma.ptVault() psnlSDL = vault.getPsnlAgeSDL() if psnlSDL: GPSVar = psnlSDL.findVar('GPSEnabled') GPSVar.setBool(1) vault.updatePsnlAgeSDL(psnlSDL)
def ImportGames(args): "args = 'filename folder'" import Plasma import PlasmaVaultConstants arglist = args.split() if len(arglist) < 2: print 'ERROR - not enough arguments - ImportMarkers "filename foldername")' return filename = arglist[0] try: dfile = open(filename+'.py','r') except IOError: print "ERROR - file %d could not be found" % (filename+'.py') return dfile.close() argresidual = args[len(filename)+1:] #== find the folder where the markerfolders might be # search thru the age journal folders vault = Plasma.ptVault() jfolder = None master_agefolder = vault.getAgeJournalsFolder() if type(master_agefolder) != type(None): agefolderRefs = master_agefolder.getChildNodeRefList() for agefolderRef in agefolderRefs: agefolder = agefolderRef.getChild() agefolder = agefolder.upcastToFolderNode() if type(agefolder) != type(None): # might be a foldername with spaces! so see if it starts with the name if argresidual.startswith(agefolder.folderGetName()): jfolder = agefolder argresidual = argresidual[len(agefolder.folderGetName())+1:] if jfolder: exec("import %s" % (filename)) exec("mgs = %s.mgs" % (filename)) for mg in mgs: nMarkerFolder = Plasma.ptVaultMarkerListNode(PlasmaVaultConstants.PtVaultNodePermissionFlags.kDefaultPermissions) nMarkerFolder.folderSetName(mg[1]) nMarkerFolder.setOwnerID(mg[0][0]) nMarkerFolder.setOwnerName(mg[0][1]) nMarkerFolder.setGameType(mg[0][2]) nMarkerFolder.setRoundLength(mg[0][3]) jfolder.addNode(nMarkerFolder)
def PtDetermineKIMarkerLevel(): "Get the KIMarkerLevel" # assume that they have none... import Plasma import string vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleKIMarkerLevel) if type(entry) != type(None): level = string.atoi(entry.chronicleGetValue()) return level # if couldn't be determine... just assume lowest form return kKIMarkerNotUpgraded
def DisplayLinkingBook(agename, spawnpoint): #self.showFlybys = showFlyby #self.curBookAge = None #self.curBookSpawnpoint = None #contents = '' #if (cover != None): # contents = (((contents + '<cover src="') + cover) + '">') #if self.isAgeInstalled(agename): # self.curBookAge = agename # self.curBookSpawnpoint = self.getSpawnpoint(agename) #if ((self.curBookAge == None) or ((self.curBookSpawnpoint == None) or ((self.curBookAge == '') or (self.curBookSpawnpoint == '')))): # self.curBookAge = None # self.curBookSpawnpoint = None # contents = (contents + '<font size=28 face=Uru ><p align=center >This Age is not installed.\n\n') # if showText: # contents = (((contents + self.getDescription(agename)) + '\n\n<font size=24 face=Uru>') + self.getText(agename)) # if (linkingImage != None): # contents = (((contents + '<pb><img src="') + linkingImage) + '" align=center blend=alpha >') # else: # contents = (contents + '<pb><img src="xLinkPanelBlackVoid*1#0.hsm" align=center blend=alpha >') #else: # contents = (contents + '<font size=28 face=Uru ><p align=center >') # if showText: # contents = (((contents + self.getDescription(agename)) + '\n\n<font size=24 face=Uru>') + self.getText(agename)) # if (linkingImage != None): # contents = (((contents + '<pb><img src="') + linkingImage) + '" align=center link=100 blend=alpha >') # else: # contents = (contents + '<pb><img src="xLinkPanelBlackVoid*1#0.hsm" align=center link=100 blend=alpha >') #self.output('Dustin: UAM: ', contents) #self.callersKey = keyToUse global _book global _agename global _spawnpoint global _islinkbook _islinkbook = True #global _isourbook _agename = agename _spawnpoint = spawnpoint contents = '<pb><img src="xLinkPanelBlackVoid*1#0.hsm" align=center link=100 blend=alpha >' #bookobj = _AgeBook(agename,spawnpoint) #_book = Plasma.ptBook(contents, self.callersKey) _book = Plasma.ptBook(contents, _ki.key) _book.setSize(1.0, 1.0) _book.setGUI('BkBook') _book.allowPageTurning(True) #if (cover == None): # self.book.show(1) #else: # self.book.show(0) #_isourbook = True _book.show(1)
def SetSDL(varNameAndVal): """ SetSDL is used to set an Age SDL variable by name. It expects two arguments: (string) VariableName, (int) NewValue """ import Plasma if not varNameAndVal: print("xCheat.SetSDL(): SetSDL takes two arguments: SDL variable name and new value are required.") return varNameAndValList = varNameAndVal.split("_") if (len(varNameAndValList) < 2) or varNameAndValList[1] == "": print("xCheat.SetSDL(): No new value specified.") return varName = varNameAndValList[0] try: newval = int(varNameAndValList[1]) except ValueError: print("xCheat.SetSDL(): Can't use '{}'. Only numerical SDL values are supported.".format(varNameAndValList[1])) return ageName = Plasma.PtGetAgeName() try: ageSDL = Plasma.PtGetAgeSDL() except: print("xCheat.SetSDL(): Unable to retrieve SDL for '{}'.".format(ageName)) return try: oldval = ageSDL[varName][0] except KeyError: print("xCheat.SetSDL(): SDL variable '{}' not found.".format(varName)) return if newval == oldval: print("xCheat.SetSDL(): Not changing value, '{}' is already {}.".format(varName, newval)) return if ageName == "Personal": vault = Plasma.ptVault() psnlSDL = vault.getPsnlAgeSDL() FoundValue = psnlSDL.findVar(varName) FoundValue.setInt(newval) vault.updatePsnlAgeSDL(psnlSDL) else: ageSDL.setFlags(varName, 1, 1) ageSDL.sendToClients(varName) ageSDL[varName] = (newval,) print("xCheat.SetSDL(): Setting '{}' to {} (was {}).".format(varName, newval, oldval))
def ListYeeshaPages(args): import Plasma import xLinkingBookDefs vault = Plasma.ptVault() if type(vault) != type(None): #is the Vault online? psnlSDL = vault.getPsnlAgeSDL() if psnlSDL: for sdlvar,page in xLinkingBookDefs.xYeeshaPages: FoundValue = psnlSDL.findVar(sdlvar) print "%s is %d" % (sdlvar, FoundValue.getInt()) else: print "Could not find personal age SDL" else: print "Could not find vault"
def PtDetermineKILevel(): "Get the KILevel" # assume that they have none... import Plasma import string vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleKILevel) if type(entry) != type(None): level = string.atoi(entry.chronicleGetValue()) # make sure it is a valid level if level >= kLowestKILevel and level <= kHighestKILevel: return level # if couldn't be determine... just assume lowest form return kMicroKI
def _DisplayBook(text, isOpen, booktype): #cover can be None(detect if theres a cover), True, or False #booktype can be bkNotebook, bkBook, or bkBahroRockBook global _book #global _isourbook _book = Plasma.ptBook(text, _ki.key) #if cover==None: # cover = text.find('<cover') >= 0 #showOpen if cover not found _book.setSize(1.0, 1.0) _book.setGUI(booktype) _book.allowPageTurning(True) #_isourbook = True #_book.show(not cover) _book.show(isOpen)
def _GetChron(needle, haystack): for i in haystack.getChildNodeRefList(): child = i.getChild().upcastToChronicleNode() if child is None: continue if child.getName() == needle: return child else: chron = Plasma.ptVaultChronicleNode() chron.setName(needle) if default is not None: chron.setValue(str(default)) haystack.addNode(chron) return chron
def CGZKillAll(args): import Plasma import PlasmaKITypes vault = Plasma.ptVault() # get rid of the CGZ marker games MGs = [ 'MG01','MG02','MG03','MG04','MG05','MG06','MG07','MG08','MG09','MG10','MG11','MG12','MG13','MG14'] for mg in MGs: entry = vault.findChronicleEntry(mg) if type(entry) != type(None): entry.chronicleSetValue("") entry.save() entry = vault.findChronicleEntry("CGZPlaying") if type(entry) != type(None): entry.chronicleSetValue("") entry.save()
def PtDetermineGZ(): "Get the current GZ states" import Plasma import PlasmaTypes import string GZPlaying = 0 MarkerToGetColor = 'off' MarkerGottenColor = 'off' MarkerToGetNumber = 0 MarkerGottenNumber = 0 KIMarkerLevel = PtDetermineKIMarkerLevel() if KIMarkerLevel > kKIMarkerNotUpgraded: # see if they are playing a CGZ game (whichGame,state) = PtWhichCGZPlaying() if KIMarkerLevel < kKIMarkerNormalLevel or (KIMarkerLevel == kKIMarkerNormalLevel and whichGame != -1): vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(kChronicleGZGames) if type(entry) != type(None): gameString = entry.chronicleGetValue() PlasmaTypes.PtDebugPrint("PtDetermineGZ: - game string is %s" % (gameString),level=PlasmaTypes.kDebugDumpLevel) args = gameString.split() if len(args) == 3: try: GZPlaying = string.atoi(args[0]) colors = args[1].split(':') MarkerGottenColor = colors[0] MarkerToGetColor = colors[1] outof = args[2].split(':') MarkerGottenNumber = string.atoi(outof[0]) MarkerToGetNumber = string.atoi(outof[1]) except ValueError: PlasmaTypes.PtDebugPrint("xKI:GZ - error trying to read GZGames Chronicle",level=PlasmaTypes.kErrorLevel) # we don't know which one it errored on, so just reset them all GZPlaying = 0 MarkerToGetColor = 'off' MarkerGottenColor = 'off' MarkerToGetNumber = 0 MarkerGottenNumber = 0 else: PlasmaTypes.PtDebugPrint("xKI:GZ - error GZGames string formation error",level=PlasmaTypes.kErrorLevel) pass else: # can't be playing a GZGame! # ...might be a MarkerTag game... let the KI determine that. pass PlasmaTypes.PtDebugPrint("PtDetermineGZ: - returning game=%d colors=%s:%s markers=%d:%d" % (GZPlaying, MarkerGottenColor, MarkerToGetColor ,MarkerGottenNumber, MarkerToGetNumber),level=PlasmaTypes.kDebugDumpLevel) return (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber)
def PtIsCGZDone(): "Has the player completed the CGZ stuff" import Plasma isDone = 0 vault = Plasma.ptVault() entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) if type(entry) != type(None): allStates = entry.chronicleGetValue() if len(allStates) > kCGZFinalGame: # assume that we are going to find them all isDone = 1 for i in range(kCGZFinalGame+1): if allStates[i] != kCGZMarkerUploaded: isDone = 0 break return isDone
def PtCaptureGZMarker(GZMarkerInRange): import Plasma import PlasmaTypes # get current GZ Game state (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) = PtDetermineGZ() # make sure there is room for the capture marker if GZPlaying and MarkerToGetNumber > MarkerGottenNumber: # set the marker status to 'gotten' # ...in the GZ marker chronicle vault = Plasma.ptVault() # is there a chronicle for the GZ games? entry = vault.findChronicleEntry(kChronicleGZMarkersAquired) if type(entry) != type(None): markers = entry.chronicleGetValue() markerIdx = GZMarkerInRange - 1 if markerIdx >= 0 and markerIdx < len(markers): # Set the marker to "captured" PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: starting with '%s' changing %d to '%s'" % (markers,GZMarkerInRange,kGZMarkerCaptured),level=PlasmaTypes.kDebugDumpLevel) if len(markers)-(markerIdx+1) != 0: markers = markers[:markerIdx] + kGZMarkerCaptured + markers[-(len(markers)-(markerIdx+1)):] else: markers = markers[:markerIdx] + kGZMarkerCaptured #PlasmaTypes.PtDebugPrint("xKI: out string is '%s'" % (markers),level=PlasmaTypes.kDebugDumpLevel) entry.chronicleSetValue(markers) entry.save() # update the marker Gotten count totalGotten = markers.count(kGZMarkerCaptured) KIMarkerLevel = PtDetermineKIMarkerLevel() if KIMarkerLevel > kKIMarkerFirstLevel: # if this is the second wave of markers (or beyond) totalGotten -= 5 if totalGotten < 0: totalGotten = 0 if totalGotten > MarkerToGetNumber: totalGotten = MarkerToGetNumber MarkerGottenNumber = totalGotten # save update to chronicle PtUpdateGZGamesChonicles(GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) else: PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: invalid marker serial number of %d" % (gGZMarkerInRange),level=PlasmaTypes.kErrorLevel ) pass else: PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: no chronicle entry found",level=PlasmaTypes.kErrorLevel ) pass else: PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: no game or this game is complete",level=PlasmaTypes.kErrorLevel ) pass