Image Hint System Bool Error

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
bunnyvoid
Regular
Posts: 59
Joined: Tue Sep 22, 2015 2:37 am
Projects: Lots of BG Commissions
Tumblr: bunnyvoid
Deviantart: bunnyvoid
Skype: https://www.twitch.tv/bunnyvoid
Soundcloud: bunny-void
Contact:

Image Hint System Bool Error

#1 Post by bunnyvoid »

:shock: Hi everyone,

I've been trying to learn how to code in renpy using Emp's youtube tutorials and have encountered an error when trying out the hint system. https://www.youtube.com/watch?v=SDXG17W0cBA& I'm still very new to coding and rely mostly on copying examples in the video.

I keep getting 'bool' object has no attribute 'use_outline' despite copying word for word the functions. I did change the example name and the images.

Here's the traceback

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/Lesson04 - Screens.rpy", line 215, in script
    r "red and black chibis hints should also show"
  File "game/screens_custom.rpy", line 309, in execute
    screen scr_hint(hints=[]):
  File "game/screens_custom.rpy", line 309, in execute
    screen scr_hint(hints=[]):
  File "game/screens_custom.rpy", line 310, in execute
    for hint in hints:
  File "game/screens_custom.rpy", line 311, in execute
    if hint.use_outline():
AttributeError: 'bool' object has no attribute 'use_outline'
And here is the code from my screen_custom.rpy

Code: Select all

screen scr_hint(hints=[]):
    for hint in hints:
        if hint.use_outline():
            imagebutton idle hint.outline:
                focus_mask True
                action NullAction()
                hovered Function(hint.call_func)
                xalign hint.x
                yalign hint.y
                
        imagebutton idle hint.img:
            focus_mask True
            action NullAction()
            hovered Notify(hint.hint_text)
            xalign hint.x
            yalign hint.y
And here is line 43 to line 79 of the code in my Lesson04 - Screens.rpy

Code: Select all

init python:
    class Hint:
        def __init__(self, img, outline, x, y, var_check, func, hint_text):
            self.img = img
            self.outline = outline
            self.x = x
            self.y = y
            self.var_check = var_check
            self.func = func
            self.hint_text = hint_text

        def call_func(self):
            self.func()

        def use_outline(self):
            return self.var_check()

    def seen_red():
        store.red_seen = True

    def has_seen_red():
        return not red_seen

    def seen_black():
        store.black_seen = True

    def has_seen_black():
        return not black_seen

    red_hint = Hint("Chibi_red_idle.png", "Chibi_red_outline.png", 0.35, 0.50, has_seen_red, seen_red, "Hey have you seen Red?")

    black_hint = Hint("Chibi_black_idle.png", "Chibi_black_outline.png", 0.65, 0.50, has_seen_black, seen_black, "Hey have you seen Black?")



default red_seen = False
default black_seen = False
And here is line 212 to 215 in Lesson04 - Screens.rpy

Code: Select all

    r "Next screen shows an incorporated hint system. Here we created a python function Hint"
    show screen scr_hint([red_hint, black_hint])
    r "red and black chibis hints should also show"
Been trying to review and correct this by myself but cant figure it out with my current skill set.
Help would be very much appreciated!

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: Image Hint System Bool Error

#2 Post by Remix »

Have you put:
red_hint = True
anywhere?
Frameworks & Scriptlets:

User avatar
bunnyvoid
Regular
Posts: 59
Joined: Tue Sep 22, 2015 2:37 am
Projects: Lots of BG Commissions
Tumblr: bunnyvoid
Deviantart: bunnyvoid
Skype: https://www.twitch.tv/bunnyvoid
Soundcloud: bunny-void
Contact:

Re: Image Hint System Bool Error

#3 Post by bunnyvoid »

not anywhere... I'll try to put it in, thanks!

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: Image Hint System Bool Error

#4 Post by Remix »

bunnyvoid wrote: Mon Apr 30, 2018 11:18 am not anywhere... I'll try to put it in, thanks!
Umm, no... I asked because that is what you need to remove.

When the screen gets to -- if hint.use_outline(): -- it is reporting that the hint in question is a boolean rather than the object you want. That would imply that you have likely re-defined red_hint or black_hint somewhere...

Maybe try quickly changing your screen to:

Code: Select all

screen scr_hint(hints=[]):
    text ", ".join( [ str(type(h)) for h in hints ] )
It *should* say <class store.Hint> though likely says <type 'bool'> instead
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]