From c4c487b780cf718b39dc710aed427ec1e99bd74d Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 26 Dec 2020 15:51:03 -0300 Subject: Some optimizations to be more Python3 compliant (for when Renpy 8 comes out) Also, fix an edge scenario crash at tavern and a missed logging at battle story log --- game/02_init.rpy | 6 +++--- game/03_init.rpy | 10 +++++----- game/battle.rpy | 3 ++- game/inventory.rpy | 12 ++++++------ game/party.rpy | 4 ++-- game/quest.rpy | 4 ++-- game/recruit.rpy | 17 ++++++++++------- game/script.rpy | 2 +- game/units.rpy | 6 +++--- 9 files changed, 34 insertions(+), 30 deletions(-) diff --git a/game/02_init.rpy b/game/02_init.rpy index 9fc0663..d335b75 100644 --- a/game/02_init.rpy +++ b/game/02_init.rpy @@ -20,7 +20,7 @@ ############################################################################ init -1 python: stdout("======================= %s %s %s" % (config.name, config.version, persistent.release_name)) - print "[STDBY] Loading Basic functions......." + print("[STDBY] Loading Basic functions.......") # Search for array[?][key]==search in an array of dicts # Returns the dictionary, or returns ERR_INVALID @@ -65,7 +65,7 @@ init -1 python: rw=base64.b64decode(raw) raw=rw if (debug): - print "base64 decoded" + print("base64 decoded") except: traceback.print_exc() pass @@ -75,7 +75,7 @@ init -1 python: rw=zlib.decompress(raw) raw=rw if (debug): - print str(raw) + print(str(raw)) except: traceback.print_exc() pass diff --git a/game/03_init.rpy b/game/03_init.rpy index 218bc86..c81a868 100644 --- a/game/03_init.rpy +++ b/game/03_init.rpy @@ -87,7 +87,7 @@ init python: # We need to try to get the element try: e=allunits[int(cid)]["attribute"] - print str(e) + print(str(e)) except: e=0 @@ -147,7 +147,7 @@ init python: valb=dl_search(persistent.allfiles, 0, val)[1] if valb == ERR_INVALID: - print ("Invalid Sound: %s" % (val)) + print("Invalid Sound: %s" % (val)) return RetString("sfx/regnum.mp3").id() # FIXME return RetString(valb).id() @@ -286,7 +286,7 @@ init python: valb=dl_search(persistent.allfiles, 0, val)[1] if valb == ERR_INVALID: - print ("Invalid Image: %s (%s)" % (path, val)) + print("Invalid Image: %s (%s)" % (path, val)) return "gfx/spinner.png" return valb @@ -302,7 +302,7 @@ init python: # Have we downloaded this image previously? path=dl_search(persistent.allfiles, 0, img) - print str(path) + print(str(path)) # Image doesn't exists, we must download it while (path == ERR_INVALID): @@ -357,7 +357,7 @@ init python: # Image exists, but wasn't loaded yet if (path != ERR_INVALID and path is not None): - print "Detected not loaded image" + print("Detected not loaded image") # Valid Image Extensions: PNG, JPG, JPEG, GIF, WEBP if ext in [".png", ".jpg", ".jpeg", ".gif", ".webp"]: # Maybe it is an unit diff --git a/game/battle.rpy b/game/battle.rpy index 2f8b3b1..accb755 100644 --- a/game/battle.rpy +++ b/game/battle.rpy @@ -245,9 +245,10 @@ label results: stdout("Failed to hide screen battle D:") pass hud_story() - print ".:: Story logs (%d) ::." % qid + print(".:: Story logs (%d) ::." % qid) if isinstance(story["post_dialog"], str) or isinstance(story["post_dialog"], unicode): + print("Calling in new context: %s" % (story["post_dialog"])) renpy.call_in_new_context(story["post_dialog"]) else: bg_is_showing=False diff --git a/game/inventory.rpy b/game/inventory.rpy index 0b0372d..73a3db1 100644 --- a/game/inventory.rpy +++ b/game/inventory.rpy @@ -37,7 +37,7 @@ init python: # TODO: msgbox you're offline, quit return ERR_LOGIN_DEFAULT - print "get_inv(): "+str(pt) + print("get_inv(): "+str(pt)) return pt screen inventory(blank=False, filters="True"): @@ -69,7 +69,7 @@ screen inventory(blank=False, filters="True"): if item is not None: # Needed because eval :rolling_eyes: #$ ir=copy.copy(item["rare"]) - #$ print str(locals()) + #$ print(str(locals())) python: evl=False #print "---- repr" @@ -79,10 +79,10 @@ screen inventory(blank=False, filters="True"): alu={} stdout("ERROR, alu: not defined, index %d" % i) evl=eval(filters, globals(), locals()) - #print str(evl) - #print str(filters) - #print str(item) - #print str(alu) + #print(str(evl)) + #print(str(filters)) + #print(str(item)) + #print(str(alu)) if evl: $ btn = unitsquare(item["unit_id"], czoom_70) imagebutton: diff --git a/game/party.rpy b/game/party.rpy index 7fe8c47..4d7cdcc 100644 --- a/game/party.rpy +++ b/game/party.rpy @@ -70,7 +70,7 @@ init python: Party.append(une["inv_id"]) if debug: - print str(Party) + print(str(Party)) # Add unit, but only if no duplicates are found # Exception: If it is -1, then we can add @@ -85,7 +85,7 @@ init python: Party[pix]=newindex if debug: - print str(Party) + print(str(Party)) # Set party set_party(pid, Party) diff --git a/game/quest.rpy b/game/quest.rpy index 9a52c2a..c1d6759 100644 --- a/game/quest.rpy +++ b/game/quest.rpy @@ -133,7 +133,7 @@ label quest_selected: if (story != ERR_INVALID): hud_story() - print ".:: Story logs (%d) ::." % qid + print(".:: Story logs (%d) ::." % qid) if isinstance(story["pre_dialog"], str) or isinstance(story["pre_dialog"], unicode): print("Calling in new context: %s" % (story["pre_dialog"])) @@ -164,7 +164,7 @@ label quest_selected: # Okay, story-telling time is over: To arms! # $ TMP_MUSIC=get_sfx(quest["music"]) - #$ print "Stage music: "+str(TMP_MUSIC) + #$ print("Stage music: "+str(TMP_MUSIC)) play music TMP_MUSIC fadein 0.5 #play music MUSIC_BATTLE.id() fadein 0.5 $ renpy.free_memory() diff --git a/game/recruit.rpy b/game/recruit.rpy index 726d332..9580a9b 100644 --- a/game/recruit.rpy +++ b/game/recruit.rpy @@ -39,15 +39,15 @@ init python: for unit in rc["units"]: _window_hide(None) if (debug): - print str(unit) + print(str(unit)) idx=inventoryplace() unit["unit_id"]=int(unit["unit_id"]) if (debug): - print "Recruit index: %d" % idx - print "Player inventory: %s" % str(Player["inv"]) - print "Unit ID: %s" % str(unit["unit_id"]) - print "Unit Name: %s" % str(allunits[int(unit["unit_id"])]["name"]) - print "Unit Rarity: %d" % allunits[int(unit["unit_id"])]["rare"] + stdout("Recruit index: %d" % idx) + print("Player inventory: %s" % str(Player["inv"])) + print("Unit ID: %s" % str(unit["unit_id"])) + print("Unit Name: %s" % str(allunits[int(unit["unit_id"])]["name"])) + print("Unit Rarity: %d" % allunits[int(unit["unit_id"])]["rare"]) Player["inv"][idx]=unit txt=allunits[int(unit["unit_id"])]["name"] rar=allunits[int(unit["unit_id"])]["rare"] @@ -55,7 +55,10 @@ init python: sprite=str(unit["unit_id"]) show_img("unit_"+sprite, at_list=[truecenter]) renpy.pause(0.1) - renpy.call_screen("msgbox", "%s\n\nRecruited %d★ %s" % (star, rar, txt), autoclose=6.0) + try: + renpy.call_screen("msgbox", "%s\n\nRecruited %d★ %s" % (star, rar, txt), autoclose=6.0) + except: + pass renpy.hide("unit_"+sprite) _window_show(None) diff --git a/game/script.rpy b/game/script.rpy index 1a8e34a..4b4172b 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -57,7 +57,7 @@ label login: message=int(message) dlcode=copy.copy(message) except: - print "AN ERROR HAPPENED AT LOGIN TIME" + print("AN ERROR HAPPENED AT LOGIN TIME") stdout("Invalid: "+str(message)) message=-1 diff --git a/game/units.rpy b/game/units.rpy index 74c9bf0..82fc834 100644 --- a/game/units.rpy +++ b/game/units.rpy @@ -20,12 +20,12 @@ init python: def evocheck(level, unit): # Does an evolved form exist? - print "evocheck lv %d" % level + #print("evocheck lv %d" % level) try: nu=unit["unit_id"]+1 - #print "nu is: %d" % int(nu) + #print("nu is: %d" % int(nu)) next_name=allunits[nu]["name"] - #print "next name: %s" % next_name + #print("next name: %s" % next_name) except: return False -- cgit v1.2.3-70-g09d2