[Solved] Using a Call Statement Without Advancing The Script

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
haydengames3
Newbie
Posts: 13
Joined: Wed Mar 17, 2021 9:56 am
Contact:

[Solved] Using a Call Statement Without Advancing The Script

#1 Post by haydengames3 » Mon Mar 22, 2021 9:43 pm

I'm having an issue where I want to switch an image out temporary through a hotspot action in a imagemap screen. I tried calling another screen to achieve this, but had layering issues with the textbox. So I tried calling the new image as a label instead, which works fine expect every time I use call(), it advances the script by one line once the call statement completes.

So here is my question, is there anyway of stopping call() from advancing the script? If not, would I be able to create my own function that could, and if so, where would I find the original script for it?
Last edited by haydengames3 on Tue Mar 23, 2021 4:36 pm, edited 1 time in total.

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: [Question] Using a Call Statement Without Advancing The Script

#2 Post by _ticlock_ » Tue Mar 23, 2021 12:19 am

Hi, haydengames3,

You should provide a piece of code to explain what exactly you are trying to do.

I am not sure if I understood you right, but if you call a screen and you want to do an action and stay at this script line you can:

1) use an action that won't return from the screen For example:

Code: Select all

screen test():
    default img = False
    if img:
        add "image_1.png" # image that should be switched
    else:
        add "image_2.png" # switch to this image
    imagemap:
        auto ...

        hotspot (100, 100, 100, 100) action ToggleScreenVariable("img")
        
label start:
    # show image 1 or 2 with condition
    call screen test()
PS: You can also use Function action and return None to avoid returning from the screen.

2) You can also call lopped label with condition to return from label. For example:

Code: Select all

label test:
    call screen imagemap_screen()
    if _return == "exit":
        return
    jump test

label start:
    call test

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: [Question] Using a Call Statement Without Advancing The Script

#3 Post by Remix » Tue Mar 23, 2021 2:01 pm

Call() supports a from_current attribute which when set to True should return to the current rather than next statement.
Frameworks & Scriptlets:

User avatar
haydengames3
Newbie
Posts: 13
Joined: Wed Mar 17, 2021 9:56 am
Contact:

Re: [Question] Using a Call Statement Without Advancing The Script

#4 Post by haydengames3 » Tue Mar 23, 2021 4:35 pm

That works perfectly, thank you.

Post Reply

Who is online

Users browsing this forum: No registered users