But I've been searching for days and haven't been able to find docs on python functions that do this stuff.
Code: Select all
init python:
def add_button(img1, img2):
ui.imagebutton(img1, img2, clicked=click_function() , hovered=hover_function()) # using clicked=None, action = click_function() gives same problem described below
Still dunno how to add it to a 'fixed' block though. I think get_displayable(screen, id) can grab a 'fixed' block correctly, but idk how to add an imagebutton as its child.
Are there no built in functions for this? Would I be able to do this with creator-defined displayables?
I'm familiar with using classes, but i'm fairly new to renpy, and what I can't find is docs of python functions, methods, properties, etc. for renpy. (except the python equivalents https://www.renpy.org/doc/html/statemen ... lents.html which just gives an overview.)
What i basically want is:
Code: Select all
init python:
example_function(fixed_id, old_imgbutton_id, new_imgbutton_id):
#none of the below are actual functions, they're pseudo code for what I want to do.
#renpy.delete(old_imgbutton_id)
#fixed_to_add_img_to = renpy.get_by_id(fixed_id)
#fixed_to_add_img_to.children.append(renpy.imagebutton("idle_img", "hover_img", action=another_example_function(), hover=foo_bar(), id=new_imgbutton_id))
#I completely understand these changes aren't permanent to the script/screen. They're not meant to be. That's kind of the point of why i need to do them from a function.
The only part I'm having trouble with is "moving" the "chess pieces", by removing and adding imagebuttons from inside python functions.
Basically, this. But everything here is placeholder, i'm just getting the "move" functionality to work. I wanna move the placeholder sword icons, which are imagebuttons. The tiles are also imagebuttons, the odd one out is being hovered over.

even if not direct answers, just links to relevant docs, example codes, etc. would be extremely appreciated