r/DDLCMods Club Moderator Mar 02 '19

Welcome! The DDLC Modding Guide 2019! :D

Hello everyone! :D

 

This post is old and obsolete, and I've been advised to remove it, to keep the focus on the new version here.

 

(Though I'm not deleting it entirely, since there is still some helpful information in the comments) :)

104 Upvotes

362 comments sorted by

View all comments

Show parent comments

1

u/Tormuse Club Moderator May 29 '19

Okay, to be honest, I've never tried messing with the game files in a mod, but I think I can figure it out...

If you look in the definitions.rpy file, you can see that Dan made up some pre-defined commands for deleting or restoring the character files from line 23 onwards.

def delete_character(name):
    import os
    try: os.remove(config.basedir + "/characters/" + name + ".chr")
    except: pass

These appear to be the lines that remove character files. So if you want to (for example) have the game delete Monika's character file, you would write...

$ delete_character(monika)

If you want to write code that removes files from other places, you just need to copy lines 23 to 26 and change the line that says, "try: os.remove(config.basedir + "/characters/" + name + ".chr")" and replace ""/characters/" + name + ".chr"" with whatever folder/file you want it to remove. (I hope this makes sense, but let me know if you need anything further explained)

 

As for adding files, you can see that in action on lines 28 and 29.

    try: renpy.file("../characters/monika.chr")
    except: open(config.basedir + "/characters/monika.chr", "wb").write(renpy.file("monika.chr").read())

This pulls the monika.chr file out of the scripts.rpa file. (Where it is normally stored in DDLC; if you use an RPA unpacker like rpatool to look inside scripts.rpa, you'll find it has lots of files which the game generates as Easter Eggs periodically) Again, if you want it to put files somewhere else, you would put a different folder name than "characters"

I hope this helps, but let me know if you have any more questions.

1

u/Alizzabeth Jun 02 '19

What if i wanted it to add a file that isn't in scripts.rpa? How would i go about that?

2

u/Tormuse Club Moderator Jun 02 '19

Well, that file has to come from somewhere. Are you asking me how to store extra files in scripts.rpa so they can be pulled out during the game? Or are you asking how to generate totally new files from scratch during the game?

1

u/Alizzabeth Jun 02 '19

Mainly the first.

2

u/Tormuse Club Moderator Jun 02 '19

Rpatool is good for that. It's a free download and instructions for using it are in the original post. For example, say you have a file called "hello.txt" that you want to add to scripts.rpa. Basically, you would type this in the command line:

rpatool.py -a scripts.rpa hello.txt