ebook img

Cute Demon Crashers! Documentation PDF

33 Pages·2016·0.17 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Cute Demon Crashers! Documentation

Cute Demon Crashers! Documentation Release 1.0.7 SugarScript June28,2016 Contents 1 CommonRen’Py/Pythonutilities 3 1.1 Ren’Pydefinitions/utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Pythonutilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 Customactions 9 2.1 Class: SetPersistent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3 Saving,Loading,andRollback 11 3.1 Class: StoreBackedObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 Class: StoreBackedSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.3 Class: SexChoiceSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 CustomDisplayables&Graphics 17 4.1 Class: StateMachineDisplayable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 Class: ComposedSprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 5 Indicesandtables 27 i ii CuteDemonCrashers! Documentation,Release1.0.7 Contents: Contents 1 CuteDemonCrashers! Documentation,Release1.0.7 2 Contents 1 CHAPTER Common Ren’Py/Python utilities ThisfilecontainscommonutilityfunctionsthatareusedthrougouttheCuteDemonCrashers! sourcecode. init -100 python: 1.1 Ren’Py definitions / utilities ThefunctionsinthiscategorydealwithprovidingsimplerandlessrepetitivewaysofdefiningsomestuffinRen’Py, aswellasgivingaccessforthingsforwhichRen’Pylacksbuilt-infunctionsfor,orthebuilt-inisawkwardtouse. 1.1.1 get_screen_var() get_screen_var() str -> None | object Returnsthevalueofascreenvariable,orNoneifcalledfromoutsideofascreen. Ren’Py allows one to define screen-scoped variables (which may even be assigned default values in common screen syntax), but doesn’t seem to provide any functionality for accessing them programmatically outside of inlineRen’Pycode. This is probably fine for most usages of Screens, but sometimes you want to mix some Python code in your Screenlanguagecodeinordertomakesomethingslessrepetitive. Thefollowingdefinitionistakenfromthe internalsofSetScreenVariable,whichmightnotbethebestoftheideas,butworks. Listing1.1: Example screen foo: 1 default x = "foo" 2 $ ui.text(get_screen_var("x") + "bar") 3 def get_screen_var(name): cs = renpy.current_screen() if cs is not None: return cs.scope[name] 3 CuteDemonCrashers! Documentation,Release1.0.7 1.1.2 naked() naked(path[,suffix=”_cen”]) str[, str] -> str Returns a displayable that correctly chooses between the censored and regular versions of an image, given a pathtosaidimage. Thesubstring{0}inthepathstandsfortheplacewherethesuffixwillbeinsertedifthegameisrunningin thecensoredmode. Forthistowork,imagesmustbestoredintheircensoredanduncensoredversions,andcensoredimagesmust have a common suffix. As an example, if one were to use this for CGs, the CG folder might look like the following: - akki_cg1.png - akki_cg1_censored.png - akki_cg2.png - akki_cg2_censored.png - ( ... ) Intheexampleabove, thesuffixchosenwas_censored(notethatitalsoincludestheunderscore). So, one wouldbeabletodefinetheCGsinRen’Pyinthefollowingway: Listing1.2: Example image akki_cg1 = naked("cgs/akki_cg1{0}.png") 1 image akki_cg2 = naked("cgs/akki_cg2{0}.png") 2 ( ... ) 3 def naked(path, suffix="_cen"): return ConditionSwitch( "persistent.censor_18", path.format(suffix), True, path.format("") ) 1.1.3 sprite() sprite(name,prefix,image) str, str, str -> str Constructsapathtoaparticularspriteimage. Sprites in Cute Demon Crashers! are organised into a [character]/[character abbrev]_[asset type]_[asset variation].pnghierarchy,andthisfunctionjustmakesbuildingthatsimpler. def sprite(name, prefix, image): return "assets/sprites/{0}/{1}{2}.png".format(name, prefix, image) 1.1.4 sprite_orias() sprite_orias(asset) 4 Chapter1. CommonRen’Py/Pythonutilities CuteDemonCrashers! Documentation,Release1.0.7 def sprite_orias(asset): return sprite("orias", "ori_", asset) 1.1.5 sprite_kael() sprite_kael(asset) def sprite_kael(asset): return sprite("kael", "ka_", asset) 1.1.6 sprite_akki() sprite_akki(asset) def sprite_akki(asset): return sprite("akki", "ak_", asset) 1.1.7 sprite_mirari() sprite_mirari(asset) def sprite_mirari(asset): return sprite("mirari", "mi_", asset) 1.1.8 sprite_claire() sprite_claire(asset) def sprite_claire(asset): return sprite("claire", "cl_", asset) 1.2 Python utilities Python’s built-in libraries lack some fairly useful functions. Functions here vary from “this part would be terser if I could write it like this,” to “if we had this, we could reduce the number of possible bugs/catch error earlier,” and everythinginbetween. Wedefinethemheresotheymaybeusedeverywhereelse. 1.2.1 flatten() flatten(xss) 1.2. Pythonutilities 5 CuteDemonCrashers! Documentation,Release1.0.7 list(list(a)) -> list(a) Takesalistoflistsandflattensitonelevel. So,ifyouhavealistxssthatlookslike[[1, 2], [3, 4]], flatten(xss)wouldgiveyou[1, 2, 3, 4]. def flatten(xss): return reduce(lambda: r, x: r + x, xss, []) 1.2.2 merge() merge(a,b) a, b -> { a | b } Returnsanewdictionarythatcontainsitemsfrombothgivenones. Python’s standard library only contains imperative methods for merging dictionaries, which means you can’t haveasingleexpressionupdatingadictionaryandreturningitsnewvalue. Sothisfixesthat,andgetsridofthat peskymutationbyexplicitly(shallow)copyingthedictionary. def merge(a, b): result = a.copy() result.update(b) return result 1.2.3 enum() enum(*items) str... -> Enum Python2.xlacksanenumerationtype(aweakerformofsumtypes)sothis,togetherwiththeprovidedcustom Enumclassmakeupforthat. AsfarasCuteDemonCrashers!’scodegoes,thisisusedfortheSexChoiceSetobject,sochoicesintheset (whichareexposedasattributesintheobject)areconstrainedbythepossiblechoicesandgettohaveaunique value. def enum(*items): return Enum(**dict(zip(items, range(len(items))))) 1.2.4 Class: Enum classEnum Aclassinwhichinstancesexposethegiveninitialisationdictionaryasattributes. Nottobeuseddirectly, butrather throughtheenumfunction,whichacceptsalistofnames. class Enum(object): 6 Chapter1. CommonRen’Py/Pythonutilities

Description:
Sprites in Cute Demon Crashers! are organised into a [character]/[character abbrev]_[ . those elements according to the value of the persistent field.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.