Hotspot Function problem

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
Rufus
Newbie
Posts: 11
Joined: Sat May 05, 2018 4:28 pm
Contact:

Hotspot Function problem

#1 Post by Rufus »

I made few hotspots

Code: Select all

 hotspot (707, 276, 94, 78) clicked Jump("notfound")
 hotspot (121, 238, 265, 168) clicked Jump("notfound")
 if found == False:
     hotspot (453, 163, 92, 170) clicked Jump("found")
 hotspot (244, 145, 138, 107) clicked Jump("notfound")
 
And my goal is to show text "There is nothing" and one of them should show "You found xxx" and add item to inventory

Code: Select all

$inventory.append("item")
I figure out how to do it with labels... but I feel like its not good option.
example

Code: Select all

label notfound:
           player "There is nothing"
           call screen hotspots_example
         label found:
           player "Yea I found something"
           $inventory.append("item")
           $found = True
           call screen hotspots_example
        
I stuck with this problem tried to do Function(renpy.say(player,"text)), Function(text("something")) etc...

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Hotspot Function problem

#2 Post by gas »

Show another screen that receive parameters, not call a function.
Anyway using labels is not entirely wrong.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Hotspot Function problem

#3 Post by Milkymalk »

As long as it works, it works. Nothing wrong with using labels.

If you prefer the looks of a screen, you could do it like this:

Code: Select all

screen search(message):
    text "You found "+message+"." xalign 0.5 yalign 0.5
    if message == 'nothing':
        button /blahblahbuttonstuff/ action Hide('search') # I can't do buttons without looking them up ;)
    else:
        button /blahblahbuttonstuff/ action [Hide('search'), Jump('foundit')]
        
label foundit:
    $inventory.append("item")
    $found = True
    # do stuff
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Rufus
Newbie
Posts: 11
Joined: Sat May 05, 2018 4:28 pm
Contact:

Thank you

#4 Post by Rufus »

Thanks guys for quick respond.
I will use screen with parameter.

Rufus
Newbie
Posts: 11
Joined: Sat May 05, 2018 4:28 pm
Contact:

Re: Hotspot Function problem

#5 Post by Rufus »

I made it but I got 2 question

Code: Select all

screen search(message):
    text "You found "+message+"." xalign 0.5 yalign 0.5
is there any way to make looks like dialog box ?
and

Code: Select all

text "You found "+message+".
I saw three methods of connection variables with text and I'm curious which is the best or maybe which I have to use in a specific case.
Example of what I mean:

Code: Select all

"text %(var)s text"

Code: Select all

"text [var]" 
and now from your code

Code: Select all

"text" + var 

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Hotspot Function problem

#6 Post by kivik »

You're better off using a label as your originally intended instead of a screen if you want it to look like a dialogue box.

In terms of the variables, there's no one best way - it depends on your situation really.

The first one I didn't even know exists (not very experienced with python) looks really useful, but I think you'll have issues using list / dict indexes with it.
The third one overcomes the issue because you can do "text" + var["index"] without problems.


The second one ("text [var]") is Renpy specific, which has a very cool effect. It interpolates the variable at the point of displaying on screen, which means you can actually put variables into a string like that when the values aren't set yet - so long as they're set when Renpy renders them. An example is during image declarations.

However, the flip side is, if you put a string together like that expecting to output said value, then change the variable before / whilst displaying it, Renpy will update it to the latest value. It's a problem in very specific situations and someone had encountered it in their code on this forum before - so just bear that in mind.

Rufus
Newbie
Posts: 11
Joined: Sat May 05, 2018 4:28 pm
Contact:

Re: Hotspot Function problem

#7 Post by Rufus »

Thanks again mate.
Could you tell me one more thing if I do it on labels

Code: Select all

label notfound:
              *something*
              call screen hotspots
          label found:
           *something* 
           call screen hotspots
Should I end label with "call screen hotspots" or is there any other option to loop that.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]