[Solved] Function being executed regardless of click.

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
curry nochi rice
Miko-Class Veteran
Posts: 746
Joined: Sat Mar 27, 2010 3:12 am
Projects: Delicatessen, Whom to Notice, Start of Something, Love Sorcery
Organization: Circle Cosine
IRC Nick: Curry
Skype: after.curry.rice
itch: project-rothera
Contact:

[Solved] Function being executed regardless of click.

#1 Post by curry nochi rice »

Related code:

Code: Select all

screen home_actions:
    default tt = Tooltip("No button selected.")

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5
        vbox:
            style "menu"
            spacing 2
            button style "menu_choice_button":
                text "Read"style "menu_choice"
                action Return(actionStudy())#actionStudy()
                hovered tt.Action("Read something for enjoyment.")
            button style "menu_choice_button":
                text "Sleep"style "menu_choice"
                action NullAction()#actionStudy()
                hovered tt.Action("Sleep and give not a fuck to the outside world.")
                

Code: Select all

label elisa_home_1_1600:
    $ renpy.block_rollback()
    scene bg elisa_room with fade
    "Anyone home?"
    ea "GAAAAHHHH"
    "It feels colder than usual."
    $ renpy.block_rollback()
    call screen home_actions
label elisa_home_1_1700:
    $ renpy.block_rollback()
    scene bg elisa_room with fade
    "Ughh Francesca's running late again."
    "Am I smarter now? I mean my intelligence is [Elisa.intelligence]"

Code: Select all

init python:
        def actionStudy():
            character.stress -= int(20*(character.charisma/10))
            character.intelligence += int(10+((character.intelligence*(character.charisma/10))) - (character.stress/10))
            character.mana -=int(10+(character.mana *(character.charisma/10))- (character.stress/10)) 
            character.health -=int(20+(character.mana *(character.charisma/10))- (character.stress/10))  
            normalize_stats()
            #hour +=100
            #renpy.jump(initiator+"_"+viewing_places+"_"+str(day)+"_"+str(hour))
            



What's happening:
The function "actionStudy()" is being executed when I just alternately hover (not clicking) on the buttons currently present on screen "home_actions". It adds more value to the stats (up to 10 digits high depending on how many times you hover it.) instead of the calculated value.

Is this a supposed bug on my code, or a Ren'py bug? :oops:

Addendum:
Welp even bugging the button to be purposely inactive doesn't work against it. It still adds value.
Heck it doesn't matter what button I hover over. Welp it even happens when I hover over the quick menu.
It also happened when I tried to use imagebuttons.

Edit:
Heck it's a code error on my part.
Last edited by curry nochi rice on Sun Aug 24, 2014 12:36 am, edited 1 time in total.
Personal (R-13) | Now at IndieDB | Circle Cosine's itch.io
I wanna be done.

User avatar
saguaro
Miko-Class Veteran
Posts: 560
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Organization: Lucky Special Games
itch: saguarofoo
Location: USA
Contact:

Re: Function being executed when button is being hovered upo

#2 Post by saguaro »

I think it's the Return. Just use

Code: Select all

action actionStudy

User avatar
curry nochi rice
Miko-Class Veteran
Posts: 746
Joined: Sat Mar 27, 2010 3:12 am
Projects: Delicatessen, Whom to Notice, Start of Something, Love Sorcery
Organization: Circle Cosine
IRC Nick: Curry
Skype: after.curry.rice
itch: project-rothera
Contact:

Re: Function being executed when button is being hovered upo

#3 Post by curry nochi rice »

saguaro wrote:I think it's the Return. Just use

Code: Select all

action actionStudy
Well it doesn't close the screen and resume running the script, but it did work.

Anyway,
I used

Code: Select all

action Return(actionStudy)
and it started working wonders. So It's fixed (for now) Heck the problem was the (). I feel rather embarrassed about this error on my part. :lol:
Personal (R-13) | Now at IndieDB | Circle Cosine's itch.io
I wanna be done.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: [Solved] Function being executed regardless of click.

#4 Post by Asceai »

You say it's working, but I don't see how 'Return(actionStudy)' would result in actionStudy ever being called, unless you $_return() or something like that somewhere that doesn't appear in this code.

anyway, action [actionStudy, Return()]

User avatar
curry nochi rice
Miko-Class Veteran
Posts: 746
Joined: Sat Mar 27, 2010 3:12 am
Projects: Delicatessen, Whom to Notice, Start of Something, Love Sorcery
Organization: Circle Cosine
IRC Nick: Curry
Skype: after.curry.rice
itch: project-rothera
Contact:

Re: [Solved] Function being executed regardless of click.

#5 Post by curry nochi rice »

Asceai wrote:You say it's working, but I don't see how 'Return(actionStudy)' would result in actionStudy ever being called, unless you $_return() or something like that somewhere that doesn't appear in this code.

anyway, action [actionStudy, Return()]
For some reason it actually executes it. Anyway will use your suggestion for correctness.
Personal (R-13) | Now at IndieDB | Circle Cosine's itch.io
I wanna be done.

Post Reply

Who is online

Users browsing this forum: Andredron, Majestic-12 [Bot]