Page 1 of 1

Button with my own function

Posted: Thu Aug 27, 2015 2:29 pm
by sashaaero
I have following code block

Code: Select all

python:
        load = 1
        
        def set_load(l):
            load = l
        
        def get_load():
            return load

 for i in range(10):
    button:
        action FileAction(i)
        #action set_load(i)
With 'FileAction(i)' button are working. If i set my own function there - buttons not even clicking or hovering.
What's wrong here?

Re: Button with my own function

Posted: Thu Aug 27, 2015 2:55 pm
by trooper6
Are you coming from Java? You don't need set and get functions. You can just access the variable directly in Python.

In this case you'd want to use the SetVariable screen action for your button. It is noted here:
http://www.renpy.org/doc/html/screen_actions.html

I can't give you an example in code because I am in a cafe and don't have access to my computer.

Re: Button with my own function

Posted: Thu Aug 27, 2015 4:07 pm
by sashaaero
trooper6 wrote:Are you coming from Java? You don't need set and get functions. You can just access the variable directly in Python.

In this case you'd want to use the SetVariable screen action for your button. It is noted here:
http://www.renpy.org/doc/html/screen_actions.html

I can't give you an example in code because I am in a cafe and don't have access to my computer.
That

Code: Select all

$ store.load = 1  

for i in range(10):
                button:
                    #action FileAction(i)
                    action SetVariable("load", i)
does nothing :(


Okay. Actually, maybe i'm doing it wrong.
I just want to have a list of saving, when you click on it, screenshot of saving is appearing in right side of screen and there is a button "Load".

Re: Button with my own function

Posted: Thu Aug 27, 2015 6:34 pm
by orz
An action on a button should only take a ScreenAction object.

http://www.renpy.org/doc/html/screen_actions.html

If you want it to just run your python function, use the Function() action:
http://www.renpy.org/doc/html/screen_ac ... l#Function

Re: Button with my own function

Posted: Thu Aug 27, 2015 11:02 pm
by synedraacus
If you want it to just run your python function, use the Function() action:
Or, better yet, define the custom Action. You'll get checks for sensitive/insensitive state for your buttons.

Re: Button with my own function

Posted: Fri Aug 28, 2015 2:03 am
by sashaaero
Okay. I change my question to...
Did anyone have source code of this screen?
http://www.renpy.org/wiki/layout.scrolling_load_save

Re: Button with my own function

Posted: Fri Aug 28, 2015 3:46 am
by trooper6
That is from the wiki and it is out of date (that page is 7 years old!), you should use the current documentation.

I can't help you much with load/save stuff as that is not anything I've experimented with yet...but I'd look in the screens.rpy file and really study what is there. Also look at the screen language documentation more generally.
Also, you might want to do a search here in the forum Question Board for save and image or save and screenshot or save and thumbnail because I know people have asked questions like that before.

For example, here are a few threads that might be useful for you to look over:
http://lemmasoft.renai.us/forums/viewto ... +thumbnail
http://lemmasoft.renai.us/forums/viewto ... 51&t=14237
http://fuckyeahrenpy.tumblr.com/post/91 ... eload-menu

Otherwise, you'll probably need one of the more advanced programmers to stop by this thread and help you out.

Re: Button with my own function

Posted: Fri Aug 28, 2015 7:14 am
by SinnyROM
I agree with trooper6, avoid the wiki like the plague. There are more outdated articles than updated so you're better off looking at the current documentation or asking.

If you're looking for how to have a selectable save/load screen that displays the screenshot of the currently selected save, then I have this snippet from when I helped another person to achieve the same thing. https://bitbucket.org/snippets/sinnysta ... matic-save This has the automatically generated file description function which is optional.

If it's the scrolling save list, then it's a case of wrapping the elements in a scrollable viewport: http://www.renpy.org/doc/html/screens.html#viewport

I can help you with implementing it later on as I have to go to work now, but feel free to explain more on what you want to achieve.

Re: Button with my own function

Posted: Fri Aug 28, 2015 9:44 am
by DragoonHP
I don't have the source code of that layout but here is a screen version of it: http://pastebin.com/qCbSwK8j

Re: Button with my own function

Posted: Fri Aug 28, 2015 1:54 pm
by sashaaero
DragoonHP wrote:I don't have the source code of that layout but here is a screen version of it: http://pastebin.com/qCbSwK8j
This is it!
But last question, how can I set size for

Code: Select all

add screenshot_image
?
Cause it's very small.

Re: Button with my own function

Posted: Fri Aug 28, 2015 7:30 pm
by orz
Make a fixed: or something like it that contains it.

Or you could try manipulating the displayable/image directly. Probably something with an image manipulator, if you go that route.

Re: Button with my own function

Posted: Fri Aug 28, 2015 11:43 pm
by DragoonHP
Change these values

Code: Select all

    config.thumbnail_height = 180
    config.thumbnail_width = 320

Re: Button with my own function

Posted: Sat Aug 29, 2015 5:12 am
by sashaaero
Thanks everyone for help! I did all I want :)
Image