Help Creating Files that appear at specific parts of the game.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Tagumonman55
Newbie
Posts: 20
Joined: Thu Nov 13, 2014 12:56 am
Projects: Legend Of Quadopolia
Deviantart: Tagumonman55
Contact:

Help Creating Files that appear at specific parts of the game.

#1 Post by Tagumonman55 »

So, similar to that in One Shot and DDLC, I want to be able to have the game reveal or create a Text file or image file in the game's folder ONLY DURING a certain part of the game....

I'm not sure how to do this exactly. Does anyone know?

User avatar
ChocolateMilk555
Newbie
Posts: 2
Joined: Thu Jul 13, 2017 5:48 pm
Contact:

Re: Help Creating Files that appear at specific parts of the game.

#2 Post by ChocolateMilk555 »

Grettings! I am not a frequenter on replying to people, but I think I might be-able to help some.

Since you mention DDLC, how about we use their code as an exact example. (Seeing how other people did things is such great reference!)

Code: Select all

$ chapter = 4
        call ch4_main

        python:
            try: renpy.file(config.basedir + "/hxppy thxughts.png")
            except: open(config.basedir + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())
        
I'm sure you know the hxppy thxughts.png that it creates, well this is how it is done. Now this is based on if ch4 is unlocked, and if you don't know DDLC structure it's quite intense, I suggest giving it a look.
Here is an example of how I used it

Code: Select all

python:
    open(config.basedir + "/stolenrunez.png", "wb").write(renpy.file("stolenrunez.png").read())
        persistent.hasrune == 1:
        #temp jump so I don't have to actuall get trigger
        jump ch1-main:
Basically it will create a stolenrunez.png on an image from the directory you put, and I have a persistent there for later use, which is also how they make un-changeable actions. So I could set persistent on if you said no to something and use it later as a lock etc. In the DDLC code there they also check for it, which is good practice.

Sorry that I didn't explain it too well, have never been good at that, however I think you can figure it out from that, if not you can wait for someone more skilled and better at explaining to reply, or send a direct message and I can go into more detail if you need.

:edit: I forgot to mention, renpy has a "File Access" post that is really useful for this stuff as well, give it a read! https://www.renpy.org/doc/html/file_python.html

Tagumonman55
Newbie
Posts: 20
Joined: Thu Nov 13, 2014 12:56 am
Projects: Legend Of Quadopolia
Deviantart: Tagumonman55
Contact:

Re: Help Creating Files that appear at specific parts of the game.

#3 Post by Tagumonman55 »

Thank you for the help! It makes a lot more sense now!

But, Is there a way to remove the newly-revealed image after the player progresses past a certain point...? (ie: The same way DDLC makes the "hxppy thxughts.png" disappear from the directory AFTER that specific Sayori scene ends; regardless of whether the player viewed it or not.)

I'm sorry if these questions can easily be answered by looking in DDLC's Script... I'm not sure how to translate the script of DDLC to look at it myself.

User avatar
ChocolateMilk555
Newbie
Posts: 2
Joined: Thu Jul 13, 2017 5:48 pm
Contact:

Re: Help Creating Files that appear at specific parts of the game.

#4 Post by ChocolateMilk555 »

Tagumonman55 wrote: Thu Feb 01, 2018 5:07 pm Thank you for the help! It makes a lot more sense now!

But, Is there a way to remove the newly-revealed image after the player progresses past a certain point...? (ie: The same way DDLC makes the "hxppy thxughts.png" disappear from the directory AFTER that specific Sayori scene ends; regardless of whether the player viewed it or not.)

I'm sorry if these questions can easily be answered by looking in DDLC's Script... I'm not sure how to translate the script of DDLC to look at it myself.
Sorry for my very late reply!

Should have checked up again on this, there are many ways to do that. In DDLC they do a check.

Code: Select all

    try: os.remove(config.basedir + "/hxppy thxughts.png") 
Then you can specify an action after that line.
There are also many ways to delete said thing differently, I honestly suggest you take a quick python course, a free one, it will help tremendously! Would love to see your game one day.
I won't give an exact line of code to delete it since it wouldn't work in that situation unless you are doing exactly what they are doing, however seeing that you should get what it is doing, and if you take that free python course, your bounds will be released.

017Bluefield
Regular
Posts: 93
Joined: Mon Dec 30, 2013 1:55 am
Projects: Project Bluefield - Origins
Organization: Autumn Rain
Deviantart: playerzero17
itch: autumn-rain
Contact:

Re: Help Creating Files that appear at specific parts of the game.

#5 Post by 017Bluefield »

Code: Select all

    try: os.remove(config.basedir + "/hxppy thxughts.png")
Where the heck do you put this line, though? When I tried it, I got an error.

User avatar
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

Re: Help Creating Files that appear at specific parts of the game.

#6 Post by TsukiWorks »

017Bluefield wrote: Tue Sep 04, 2018 12:10 am

Code: Select all

    try: os.remove(config.basedir + "/hxppy thxughts.png")
Where the heck do you put this line, though? When I tried it, I got an error.
You should add "python":

Code: Select all

python:
    try: os.remove(config.basedir + "/hxppy thxughts.png")

EternalVoid
Newbie
Posts: 13
Joined: Thu Oct 15, 2020 9:59 am
Soundcloud: DivinePlane
Contact:

Re: Help Creating Files that appear at specific parts of the game.

#7 Post by EternalVoid »

ChocolateMilk555 wrote: Thu Jan 25, 2018 10:17 pm

Code: Select all

$ chapter = 4
        call ch4_main

        python:
            try: renpy.file(config.basedir + "/hxppy thxughts.png")
            except: open(config.basedir + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())
        
I tried this and it works, but displays an error message, do you know why?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot]