Basic Topics (regarding drags, and child), big help needed

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
HumanOS
Newbie
Posts: 1
Joined: Sat Jul 21, 2018 12:56 am
Contact:

Basic Topics (regarding drags, and child), big help needed

#1 Post by HumanOS »

Hi there, thanks for such a great effort and really proud of this community efforts.

I have some basic issues with some of my code knowledges:

Editing file -> screens.rpy created the next stuff:

Code: Select all

init python:

    def apm_dragged(drags, drop):
        drags[0].set_child("tri_inner.png")
        if not drop:
            return
        return True
        
screen mechs():
    tag menu
    modal False
    draggroup:
            id "apm"
            drag:
                align (0.5,0.97)
                drag_name "apm_1"
                child "apm_space_test"
                droppable False
                dragged apm_dragged
            drag:
                align (0.3,0.5)
                drag_name "bed"
                child "tri_border.png"
                draggable False
When function "apm_dragged" is called via "dragged" event, i want to change and render on the fly the draggable displayable child / sprite / etc.
I thought i could this by calling "set_child" drag's (function/statement/action/whatever...). I'm not sure if this will actually change the displayble's sprite as i intend to but i am posting this here because i just cant seem to understand how these statements should be called...
According to documentation:

Code: Select all

set_child(d)
Changes the child of this drag to d.
My average code knowledge (which maybe its actually really low, since i feel horrible asking this kind of things here) let me figure out that this "statements" actually work as functions from a class defined in ren'py so i should call it after it class base element like this: drags[0].set_child ,also find it in the github that set_child needs to target self, which makes even more sense to call it that way.

the big problem now its that i can't figure out what "d" should be...

calling drags[0].set_child("tri_inner.png") returns basicly: AttributeError: 'unicode' object has no attribute 'per_interact'

My guess is that when you create a "displayable" in this case a "drag" and declare child "IMAGE/path" this "child" attribute its not actually simply storing sprite source path, but its actually loading an object of some sort or "styles".... i don't know... i'm very frustrated... :cry:

QUESTIONS:

1) could someone give an example of proper usage of "set_child statement"
2) set_child will do the job of changing a draggable (or displayable) 's sprite?
3) if number 2 is False, any suggestion how to approach it?
4) am i just too stupid to learn this engine, or the documentation its actually not very helpful?

Thanks in advance...

Post Reply

Who is online

Users browsing this forum: Google [Bot], trailsiderice