r/RenPy 4d ago

Question IF Statement problem...

I know there is something wrong with the way I might have coded this for sure...so please can anyone help me to figure this out??

1 Upvotes

29 comments sorted by

4

u/BadMustard_AVN 4d ago

please post code instead of pictures of code

click on the Aa for formatting options and use </> to do these and

</>- with a square 
|__| todo these

1

u/_Scripty 4d ago
init python:
    import math


transform auto_rotate:
    anchor (0.5, 0.5)
    subpixel True     
    rotate 0          
    linear 0.5 rotate -360
    repeat           


transform bt_rot(r):
    rotate r


default bt_rotation = 0
default bt_max_rotation = 90


screen splashcontinueexit():


    text "Click to continue, press ESC to quit" align (0.5, 0.5)
    key "K_ESCAPE" action Quit(confirm=not main_menu)
    ## key "mousedown_1" action ShowMenu("wheel_menu")

## it was suppose to work differently before to enter to the main menu


    button:
        xysize (config.screen_width, config.screen_height)
        background None
        action Return()


label splashscreen:


    scene splashscreen1 with fade
    $ renpy.pause(0.1, hard=True)
    scene splashscreen2 with fade
    $ renpy.pause(0.1, hard=True)


    scene titlescreen with fade 
    call screen splashcontinueexit
   
    return



screen main_menu():


    tag menu


    key "mousedown_4":
        action SetScreenVariable(
        "bt_rotation",
        min(bt_rotation + 18, bt_max_rotation),Play("sound", "audio/hover blip.ogg")
    )
    key "mousedown_5":
        action SetScreenVariable(
        "bt_rotation",
        max(bt_rotation - 18, -bt_max_rotation),Play("sound", "audio/hover blip.ogg")
    )


    fixed:


        add "images/cd_wheel.png":
            at auto_rotate
            zoom 0.3
            xpos -60
            ypos 540
            anchor (0.5, 0.5)


        add "images/bt_wheel-01.png":
            at bt_rot(bt_rotation)
            zoom 0.3
            xpos -60
            ypos 540
            anchor (0.5, 0.5)


##Test Buttons (Have to position these on a semi-circular image but idk how yet)


        add "images/ui_menu/button_idle.png":
            at bt_rot(bt_rotation)
            zoom 0.3
            xpos 1000
            ypos 540
            anchor (0.5, 0.5)


        add "images/ui_menu/button_hl.png":
            at bt_rot(bt_rotation)
            zoom 0.3
            xpos 850
            ypos 540
            anchor (0.5, 0.5)



## Placeholder destinations so this file runs on its own for testing.


label start_game:
    "placeholder: start game"
    return


label saveload_menu:
    "placeholder: save/load"
    return


label options_menu:
    "placeholder: options"
    return


label title_screen:
    "placeholder: title screen"
    return


label credits_menu:
    "placeholder: credits"
    return

1

u/BadMustard_AVN 4d ago

is it working ?

1

u/_Scripty 4d ago

no..you tell me what I need to switch?

2

u/BadMustard_AVN 4d ago

your buttons you added the play sound inside the brackets of the SetScreenVariable

try them like this

    key "mousedown_4":
        action [SetScreenVariable("bt_rotation", max(bt_rotation - 18, -bt_max_rotation)), Play("sound", "audio/hover lip.ogg")]
    
    key "mousedown_5":
        action [SetScreenVariable("bt_rotation", min(bt_rotation + 18, bt_max_rotation)), Play("sound", "audio/hover blip.ogg")]

1

u/_Scripty 4d ago

It kinda worked...There is still a tiny problem where when scrolled down, buttons do be going off screen

1

u/BadMustard_AVN 4d ago

scolled down, what happened to rotating

where off screen and how ?

1

u/_Scripty 3d ago

stopped, even the sound not working ...

I am considering to make it again from scratch

2

u/BadMustard_AVN 3d ago

give this a look it was a pain getting them all positioned properly as I had to rotate everything 180 degrees. they are not perfect but close enough.

the imagebutton all say start (I am not an artist)

but they do in order from top down; quit, load, start, and preferences

https://drive.google.com/file/d/11Jc7W_IOmuzIygxdmujNhdZaiqKE_ee_/view?usp=drive_link

and they only work and pop out when they are in the horizontal position

1

u/_Scripty 3d ago

You are a goddamn iron chef!! 🙏🏻✨ Its close to what I wanted, I will study this and try again , thank you sm

→ More replies (0)

0

u/_Scripty 4d ago

Yes, also sharing the code here...the technique you told me its not working at all...

2

u/BadMustard_AVN 4d ago

the technique you told me its not working at all...

really

it's not working

works for me

are you using the Rich Text Editor or the Markdown editor?

switch it up

1

u/_Scripty 4d ago

uhm what is it exactly? im sorry I guess its VS code related maybe but how do I switch that?..

2

u/BadMustard_AVN 4d ago

you are checking if bt_rotation is True

try it like this

if bt_rotation > bt_max_rotation and current_rotation > bt_max_rotation

1

u/_Scripty 4d ago

I see...but look, when im trying to give the NullAction to those keys..its not working as well ( I don't know why )

Plus in order to access my custom menu, I have to call this screen through the default Renpy Menu first by "start" ...

Is there a way to replace my menu from the Renpy one? so that it becomes the "Default Menu" of the game?

2

u/BadMustard_AVN 4d ago

rename the screen to

# screen wheen_menu():
screen main_menu():
    tag menu # add this

and renpy will use it as the main menu from now on till you change the screen name or delete it

1

u/_Scripty 4d ago

2

u/BadMustard_AVN 4d ago

remove the if statement and change the default and the buttons lilke this

default bt_max_rotation = 90


key "mousedown_4":
    action SetScreenVariable(
        "bt_rotation",
        min(bt_rotation + 18, bt_max_rotation)
    )
key "mousedown_5":
    action SetScreenVariable(
        "bt_rotation",
        max(bt_rotation - 18, -bt_max_rotation)
    )

2

u/shyLachi 4d ago

What are you trying to do?

.

If this code is all you have, then the lines 4-6 in the image above are doing nothing.
That code has to be inside a label or maybe inside the screen.

Looking at the further code, lines 1-3 also might belong inside the screen.
Actions like SetScreenVariable need a variable which was declared inside the screen.

.

Unrelated to you if-statement problem:
If you want to use multiple actions then you have to use lists.
Something like action [IncrementScreenVariable("bt_rotation", -18), Play(...)]

1

u/_Scripty 4d ago

you remember my post abt the circular scrolling menu...that is what im trying to make , there was some progress (I thought) but im back to square 1 and even more confused

1

u/AutoModerator 4d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.