DSE and user-made variables? [SOLVED]

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
User avatar
InkyFrog
Newbie
Posts: 11
Joined: Thu Feb 19, 2015 10:30 pm
Contact:

DSE and user-made variables? [SOLVED]

#1 Post by InkyFrog »

Hello! I am brand new to Ren'py. So brand new, in fact, that I only started using it about 3 or 4 days ago! I'm very much a beginner at this, and am programming a somewhat simple game to learn (I learn best by doing).

I do have a problem, though. I am using DSE, (alongside this chunk of coding, if that affects it). What I'm trying to do is make events appear in certain areas based on self-made variables. In this case affection points.

Lemme see if I can explain it better. I'm horrid with words and explanations.

Let's say I have to events for my day planner's option 'office':

Code: Select all

        $ event("office1", "act == 'office'", event.choose_one('office'), priority=200)
        $ event("office2", "act == 'office'", event.choose_one('office'), priority=200)
Each time 'office1' happens, a character called 'gf' gains an affection point of 1.

I want an event to activate in 'office' only after gf has 5 affection points or more. In coding terms:

Code: Select all

$ gf >= 5
How can I go about this? I know it's possible to make menu options appear under the circumstances, but not entire events.

This is what I currently have for the event itself:

Code: Select all

init:

    $ event("gfNAME", "act == 'office'", event.once(), event.depends('GB'), priority=150)
    
    
label gfNAME:
    
    "DIALOGUE"

menu:
    "OPTION 1.":
         jump gfbad1

    "OPTION 2.":
         jump gfgood1
         
label gfbad1:
    "DIALOGUE"
    
    $ gf -= 2
    return
    
label gfgood1:
    "DIALOGUE"
    
    $ gf +=2
    return

Running this event on its own is fine in testing. It works with no problems. I just want it to ONLY work after gf's variable reaches 5 or higher, and only once. Whenever I try to add the variable as a condition, however, it never runs. No errors. It just won't run at all.

I can't figure out the proper code combination to make this possible. Can anyone help me out?
If you need more information, I'd be happy to try and provide it!
Last edited by InkyFrog on Fri Feb 20, 2015 1:28 am, edited 1 time in total.

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: DSE and user-made variables?

#2 Post by qirien »

Hey! Let's take a look at this. Here's what you have:

Code: Select all

 $ event("gfNAME", "act == 'office'", event.once(), event.depends('GB'), priority=150)
This means:
Go to event gfNAME if we are in the office part of the day. Only do it once, and only if you've already done the GB event.

I didn't see a GB event in your code anywhere - since it depends on that it will never get run. So I think you want something like this:

Code: Select all

 $ event("gfNAME", "act == 'office' and gf >= 5", event.once(), priority=150)
This means:
Run the gfNAME event during the office act if gf >= 5, but only do it once.

Does that work?

Also, I don't know if you have looked at the sample project included with the DSE, but in its events.rpy are defined lots of different types of events.
Finished games:
Image
Image
Image

User avatar
InkyFrog
Newbie
Posts: 11
Joined: Thu Feb 19, 2015 10:30 pm
Contact:

Re: DSE and user-made variables?

#3 Post by InkyFrog »

Thank you very much for the assistance!

the GB event was an introduction to the office part of the day, however if I get the variable to work, adding the event.depends for it most likely won't be necessary.

I've tried replacing my former line of code with the one you made. At first it wasn't working properly, but by altering the layout to match the one from the DSE sample, it managed to work (though I'm not sure why that made a difference there, but nowhere else)!

I'll label the problem solved for now; I should be able to code the rest of the events. Thank you very much for helping.

On that note, if I stumble across this problem again, should I remove SOLVED from the topic, or should I test this more before considering the problem solved? Either way, thank you again for your help! :)

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: DSE and user-made variables? [SOLVED]

#4 Post by qirien »

If you have more problems, go ahead an post on this thread, and that way I know I'll see it so I can help you. I've kind of adopted the DSE (in fact, I'm working on a new version - it should be backwards compatible, but it's a little easier to customize).
Finished games:
Image
Image
Image

User avatar
InkyFrog
Newbie
Posts: 11
Joined: Thu Feb 19, 2015 10:30 pm
Contact:

Re: DSE and user-made variables? [SOLVED]

#5 Post by InkyFrog »

Hi. I'm posting here again because I've run into a rather unusual problem!

For some reason, one of my events refuses to work, and I can't figure out why.

This event is meant to activate when a particular dayplanner option is chosen 20 times total. There's a variable for it:

Code: Select all

 $ piss = 0
(Please forgive the foul language.)

The variable is set to rise whenever the dayplanner event 'bathroom' or 'broom' is chosen:

Code: Select all

$ event("broom1", "act == 'broom'", event.choose_one('broom'), priority=200)
$ event("broom2", "act == 'broom'", event.choose_one('broom'), priority=200)
Both of these events will raise the variable by one point. There are two for the sake a variety.

Once the variable reaches 20, a scene is meant to play out when you click on 'broom':

Code: Select all

    $ event("pissEND", "act == 'broom' and piss >= 20",
         event.once(), event.only(), priority=150) 

label pissEND:
    "WORDS"
    "WORDS"
    return
So far, every event I have tested works successfully, but not this one. I can't for the life of me figure out why, since it's set up the same as the other events.

Could you give me any help with this? It's not absolutely vital for the purpose of the game, but it's meant to be in it. I'll remove it if the problem can not be rectified.

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: DSE and user-made variables? [SOLVED]

#6 Post by qirien »

Hmmm, I don't know; that looks right to me... what does it do instead? Does it call broom1 or broom2 instead of pissEND? Are there any other broom events? Can you use the developer console (shift + D while in game) and the Variable Viewer to verify the value of piss?
Finished games:
Image
Image
Image

User avatar
InkyFrog
Newbie
Posts: 11
Joined: Thu Feb 19, 2015 10:30 pm
Contact:

Re: DSE and user-made variables? [SOLVED]

#7 Post by InkyFrog »

I didn't think to use the variable viewer, but upon using it right now, it's at 20 and it's still not running.

The other two events are playing in its stead, yes.

I'm not sure why, though. The events set up similarly to this one all seem to be functioning well.

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: DSE and user-made variables? [SOLVED]

#8 Post by qirien »

Hmm, is this in the same init block as everything else? Is it really being added to the event list?
Try removing event.only().
If that doesn't work, you could try putting some debug code in event_dispatcher.rpy to make sure your event is added.
If you still can't figure it out, you could send me your code and I'll try and take a look at it.
Finished games:
Image
Image
Image

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: DSE and user-made variables? [SOLVED]

#9 Post by philat »

http://www.renpy.org/wiki/renpy/DSE#Events

I haven't thought this through very carefully, but is there a chance the choose_one() is messing up the priority here?

User avatar
InkyFrog
Newbie
Posts: 11
Joined: Thu Feb 19, 2015 10:30 pm
Contact:

Re: DSE and user-made variables? [SOLVED]

#10 Post by InkyFrog »

qirien wrote:Hmm, is this in the same init block as everything else? Is it really being added to the event list?
Try removing event.only().
If that doesn't work, you could try putting some debug code in event_dispatcher.rpy to make sure your event is added.
If you still can't figure it out, you could send me your code and I'll try and take a look at it.
Oh, silly me!
I forgot to place it in an init block. :oops: I feel absolutely silly right now.

Thank you both very much for trying to help. That solved the problem. :)

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: DSE and user-made variables? [SOLVED]

#11 Post by qirien »

Yay, glad it works now! :)
Finished games:
Image
Image
Image

Post Reply

Who is online

Users browsing this forum: No registered users