Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
- Posts: 44
- Joined: Tue Dec 19, 2017 1:36 pm
I am trying to pass some data to the clicked event when I click on a drag item, but the event seems to fire constantly when I'm in console mode and when the game starts.
Here is the snippet I am playing around with:
Code: Select all
print "clicked on ", name
def detective_dragged(drags, drop):
if not drop:
store.detective = drags.drag_name
store.city = drop.drag_name
# A drag group ensures that the detectives and the cities can be
# dragged to each other.
# Our detectives.
xpos 100 ypos 100
xpos 150 ypos 100
# The cities they can go to.
xpos 450 ypos 140
xpos 500 ypos 280
"We need to investigate! Who should we send, and where should they go?"
call screen send_detective_screen
"Okay, we'll send [detective] to [city]."
When I start the game, immediately in console I see:
And if I press enter in the console, it prints the same thing.
If I'm not using the clicked event properly, what's a good way to call a function with parameters after the drag item has been clicked?
- Miko-Class Veteran
- Posts: 958
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I cannot draw very well)
- Projects: An un-named 3d anime based trainer game
You cannot pass an arbitrary parameter to any drag event, though you can use the activated attribute
Code: Select all
print( " and ".join( [ drag.name for drag in drags ] ) )
# some screen
That function (or list of functions) will be passed one argument, a list of drags that are being dragged
note: activated is a recent addition to Ren'Py, so use an up to date version
Mad Scientist Todo List:
- Finish Improved Event Handler
- Implement DragonBones animation as a Creator Defined Container
- Finish Catmull-Rom Spline pathing
- Finish Bitmask collision and rebound vector system
- Develop time based building mechanic
- *Find a superb artist and actually write a game*
- Eileen-Class Veteran
- Posts: 1443
- Joined: Wed Dec 04, 2013 12:33 pm
You can also curry the function so that it works with clicked -- technically, I think clicked fires on mouse-up, as opposed to mouse-down for activated.
Users browsing this forum: No registered users