def DOOR(cont): owner = cont.owner ray = owner.get("RAYCAST", None) cls = None if ray != None: if keymap.BINDS["ACTIVATE"].tap(): cls = ray if cls != None: gd = logic.globalDict scn = owner.get("SCENE", None) door = owner.get("OBJECT", owner.name) map = owner.get("MAP", "") + ".blend" if map in gd["BLENDS"]: #cls.alignPlayer() gd["DATA"]["Portal"]["Door"] = door settings.openWorldBlend(map, scn) owner["MAP"] = "" if "GROUND" in owner: del owner["GROUND"] owner["RAYCAST"] = None
def OPEN(args=[], kwa=None): """Open a Map -list Print blend files in "//MAPS/" -map <x> Directly open "x.blend" or blendlist[x] if integer""" def checkNumber(x): try: int(x) return True except Exception: return False if kwa != None: map = kwa if ".blend" not in kwa: map = kwa + ".blend" if checkNumber(kwa) == True: if int(kwa) in range(len(logic.globalDict["BLENDS"])): map = logic.globalDict["BLENDS"][int(kwa)] if map in logic.globalDict["BLENDS"]: settings.openWorldBlend(map) return "LOAD" ERROR() return False if len(args) == 1: OPEN(["", "list"]) logic.CLASS.NEWLINE("'.blend' suffix not required, accepts numbers", 2, 1, (0.7, 0.5, 0.7, 1)) logic.CLASS.ENTRYLINE(["MAP"]) logic.CLASS.prompt = OPEN return if "list" in args: for i in range(len(logic.globalDict["BLENDS"])): map = logic.globalDict["BLENDS"][i] split = map.split(".blend") logic.CLASS.NEWLINE(str(i) + ": " + split[0], 1, 1, (1, 1, 1, 1)) logic.CLASS.NEWLINE() return for i in args: split = i.split(" ") if split[0] == "map" and len(split) == 2: map = split[1] + ".blend" if checkNumber(split[1]) == True: if int(split[1]) in range(len(logic.globalDict["BLENDS"])): map = logic.globalDict["BLENDS"][int(split[1])] if map in logic.globalDict["BLENDS"]: settings.openWorldBlend(map) logic.CLASS.NEWLINE("LOADING...", 2, 2, (1, 1, 1, 1)) return ERROR()
def ZONE(cont): owner = cont.owner cls = None if "COLLIDE" not in owner: owner["COLLIDE"] = [] owner["FAILS"] = [] owner["ZONE"] = False owner["TIMER"] = 0 for hit in owner["COLLIDE"]: if hit.PORTAL == True: vehicle = hit.data.get("PORTAL", None) if vehicle == True and owner.get("VEHICLE", True) == False: vehicle = False if vehicle in [None, True]: cls = hit #if vehicle == False: # if hit not in owner["FAILS"]: # obj = hit.objects["Root"] # LV = obj.localLinearVelocity.copy()*-1 # obj.localLinearVelocity = LV # owner["FAILS"].append(hit) #for hit in owner["FAILS"]: # if hit not in owner["COLLIDE"]: # owner["FAILS"].remove(hit) if owner["TIMER"] > 120: owner["TIMER"] = 200 owner.color = (0, 1, 0, 0.5) else: owner["TIMER"] += 1 owner.color = (1, 0, 0, 0.5) if cls != None: if owner["TIMER"] == 200: gd = logic.globalDict scn = owner.get("SCENE", None) map = owner.get("MAP", "") + ".blend" door = owner.get("OBJECT", owner.name) if map in gd["BLENDS"]: lp, lr = cls.getTransformDiff(owner) gd["DATA"]["Portal"]["Zone"] = [lp, lr] gd["DATA"]["Portal"]["Door"] = door settings.openWorldBlend(map, scn) owner["MAP"] = "" else: owner["TIMER"] = 0 if "GROUND" in owner: del owner["GROUND"] owner["COLLIDE"] = []
def RESUME(args=[], kwa=None): """Resume from Last Save""" current = logic.globalDict["CURRENT"] profile = logic.globalDict["PROFILES"][current["Profile"]] map = current["Level"] scn = current["Scene"] if map == None or map not in logic.globalDict["BLENDS"]: logic.CLASS.NEWLINE("ERROR:", 1, 1, (0.3, 0.5, 0.7, 1)) logic.CLASS.NEWLINE("Map Not Available...", 2, 2, (1, 1, 1, 1)) return #if map not in profile["LVLData"]: # logic.CLASS.NEWLINE("ERROR:", 1, 1, (0.3,0.5,0.7,1)) # logic.CLASS.NEWLINE("Something Happened...", 2, 2, (1,1,1,1)) # return settings.openWorldBlend(map, scn) logic.CLASS.NEWLINE("LOADING...", 2, 2, (1, 1, 1, 1))
def KEYMAP(args=[], kwa=None): """Open Keymap Utility""" settings.openWorldBlend("KEYMAP")
def manageKeys(cont): owner = cont.owner scene = owner.scene camera = scene.active_camera cursor = scene.objects["Cursor"] info = scene.objects["Info"] cursor.localPosition[0] = (logic.mouse.position[0] - 0.5) * camera.ortho_scale cursor.localPosition[1] = (logic.mouse.position[1] - 0.5 ) * -camera.ortho_scale * keymap.MOUSELOOK.ratio cursor.localPosition[2] = -2 if logic.FREEZE != None: status = logic.FREEZE() info.text = status if status == "END": logic.FREEZE = None return ms = logic.mouse.events wu = events.WHEELUPMOUSE wd = events.WHEELDOWNMOUSE rate = owner["SCROLL"] - owner.worldPosition[1] if ms[wu] in [1, 2] and owner["SCROLL"] > 0: owner["SCROLL"] -= 2 if ms[wd] in [1, 2] and owner["SCROLL"] < owner["LENGTH"]: owner["SCROLL"] += 2 owner.worldPosition[1] += rate * 0.1 rayto = cursor.worldPosition.copy() rayto[2] += -1 rayOBJ = cursor.rayCastTo(rayto, camera.far, "RAYCAST") if rayOBJ: rayOBJ["RAYCAST"] = True split = rayOBJ.name.split(".") if rayOBJ.name == "Back": map = logic.globalDict["CURRENT"]["Level"] if map == None or map not in logic.globalDict["BLENDS"]: info.text = "Return to the Launcher" if ms[events.LEFTMOUSE] == 1: settings.openWorldBlend("LAUNCHER") else: info.text = "Return to Game" if ms[events.LEFTMOUSE] == 1: scn = logic.globalDict["CURRENT"]["Scene"] settings.openWorldBlend(map, scn) elif rayOBJ.name == "Save": info.text = "Save the Current Configuration" if ms[events.LEFTMOUSE] == 1: settings.SaveBinds() elif rayOBJ.name == "Quit": info.text = "Exit the Utility" if ms[events.LEFTMOUSE] == 1: logic.endGame() else: info.text = rayOBJ.get("DOCSTRING", "") else: info.text = "" if keymap.SYSTEM["SCREENSHOT"].tap() == True: logic.globalDict["SCREENSHOT"]["Trigger"] = True scene.objects["Save"]["RAYCAST"] = False