Best Practice way to create array of buttons?

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
octacon100
Regular
Posts: 163
Joined: Thu Sep 12, 2013 11:23 pm
Projects: Regeria Hope
Organization: Golden Game Barn
IRC Nick: Octacon100
Location: Boston, MA
Contact:

Best Practice way to create array of buttons?

#1 Post by octacon100 »

Hi All,

I've been wrestling over the weekend with creating a screen that moves or does actions based on buttons pressed, and I'm getting close to having it done, but in rare cases I'm seeing that more than one button reacts to a button being pushed. I'm trying to figure out why this could be the case. I've tried several ways to change the "action" part of the button code, but nothing seems to make a difference. Is there anything glaringly obviously wrong with this code?

screen lineButtonTest:

Code: Select all

    

def handleScreenClick():
        selectedButton.handleClick()

screen lineButtonTest:
    modal True
    zorder 10
    frame:
        style_group "evidenceOverloadStyle"
        xsize 3000
        ysize 2000

        #text str(testButton.buttonPos[0]) + "\n" + str(startPos[0])
        #text str(testButton.lineEndPos[0]) + "\n" + str(endPos[0])  xpos 100
        #text "[selectedAnswer]"

        add screenLineRender
        for item in buttonArray:
            if item.type == "Answer" and item.selected == True and item.animationShown == False:
                textbutton item.buttonText anchor (0.5, 0.5) style_group "evidenceOverloadStyleSelected" pos item.buttonPos action NullAction at movingDissolveButton(item.buttonPos, item.lineEndPos, item)
            textbutton item.buttonText anchor (0.5, 0.5) pos item.buttonPos action [SetVariable("selectedButton", item), handleScreenClick] at None

        at moveScreenAround(startPos, endPos)
I've tried a few different ways of doing the handleScreenClick method, like putting it inside a "Function" screen action, putting a hide(lineButtonTest) before the function and show("lineButtonTest") after the function, but I'm still seeing other buttons react like they were selected, and some code is running even though it shouldn't. Any advice on what I'm doing wrong would be much appreciated.
Image
Current Digital Projects -
Image
Regiera Hope Completed Game Forum Post

Post Reply

Who is online

Users browsing this forum: Bing [Bot], MisterPinetree