[Solved] Using image manipulators on displayables ?

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
ZianRiyone
Newbie
Posts: 11
Joined: Mon Jun 14, 2021 3:25 pm
Contact:

[Solved] Using image manipulators on displayables ?

#1 Post by ZianRiyone »

So, the question is that, I just wanted to write a general composite image code with variables to use that for many characters while changing variables and assigning them in order to prevent code pollution(i just didnt want to write a composite image code for each character). I got this issue but i couldnt find any solution to use image manipulaters on them cause they are general displayables.

Code: Select all

##### definition for image #####
    def equip_rand_img(m_img):
        m_img.img = Composite(
            (600, 1000),
            (0, 0), "chr_design/player.png",
            (0, 0), "chr_design/p_body_{}.png".format(m_img.p_b),
            (0, 0), "chr_design/p_pants_{}.png".format(m_img.p_p),
            (0, 0), "chr_design/p_gloves_{}.png".format(m_img.p_h),
            (0, 0), "chr_design/p_shoes_{}.png".format(m_img.p_f),
            (0, 0), "chr_design/p_main_hand_{}.png".format(m_img.p_mh),
            (0, 0), "chr_design/p_off_hand_{}.png".format(m_img.p_oh),
        )
##### Screen #####
    ......
        for m in monster_slot[1:2]:
            fixed:
                if not m.dead:
                    imagebutton at m.anim:
                        focus_mask True
                        hover im.MatrixColor(m.img, im.matrix.brightness(0.1))
                        idle m.img anchor (0.5,1.0)
                        ...
                        
                       

#### traceback ####

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 49, in script call
    call battle
  File "game/game_engine/battle_engine/battle.rpy", line 35, in script
    show screen display_monsters with diss
  File "renpy/common/000statements.rpy", line 551, in execute_show_screen
    renpy.with_statement(eval(transition_expr))
  File "game/game_engine/battle_engine/battle.rpy", line 118, in execute
    screen display_monsters():
  File "game/game_engine/battle_engine/battle.rpy", line 118, in execute
    screen display_monsters():
  File "game/game_engine/battle_engine/battle.rpy", line 119, in execute
    fixed:
  File "game/game_engine/battle_engine/battle.rpy", line 121, in execute
    for m in monster_slot[0:1]:
  File "game/game_engine/battle_engine/battle.rpy", line 122, in execute
    fixed:
  File "game/game_engine/battle_engine/battle.rpy", line 123, in execute
    if not m.dead:
  File "game/game_engine/battle_engine/battle.rpy", line 124, in execute
    imagebutton at m.anim:
  File "game/game_engine/battle_engine/battle.rpy", line 124, in keywords
    imagebutton at m.anim:
  File "game/game_engine/battle_engine/battle.rpy", line 126, in <module>
    hover im.MatrixColor(m.img, im.matrix.brightness(0.1))
Exception: Expected an image, but got a general displayable.


So how can i use image manuplators, or should i just use a condition switch to make image hovered like adding a black layer on it at 0.5 opacity.
Last edited by ZianRiyone on Tue Jan 18, 2022 6:34 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Using image manipulators on displayables ?

#2 Post by Ocelot »

image manipulators were unsupported for a few years. They should not be used in new projects. One problem with them: they only work on Image. And Image can only be defined during init phase, not during general gameplay.
Use Transform() displayable to set matrixcolor property instead:

Code: Select all

hover Transform(child=m.img, matrixcolor=BrightnessMatrix(0.1))
https://www.renpy.org/doc/html/trans_tr ... #Transform
https://www.renpy.org/doc/html/matrixcolor.html
< < insert Rick Cook quote here > >

Gouvernathor
Newbie
Posts: 23
Joined: Thu Aug 06, 2020 9:27 am
Github: Gouvernathor
Discord: Armise#6515
Contact:

Re: Using image manipulators on displayables ?

#3 Post by Gouvernathor »

You can actually find how to migrate from image manipulators to up-to-date renpy in the image manipulators page itself : https://www.renpy.org/doc/html/im.html

User avatar
ZianRiyone
Newbie
Posts: 11
Joined: Mon Jun 14, 2021 3:25 pm
Contact:

Re: Using image manipulators on displayables ?

#4 Post by ZianRiyone »

Ocelot wrote: Mon Jan 17, 2022 5:15 pm image manipulators were unsupported for a few years. They should not be used in new projects. One problem with them: they only work on Image. And Image can only be defined during init phase, not during general gameplay.
Use Transform() displayable to set matrixcolor property instead:

Code: Select all

hover Transform(child=m.img, matrixcolor=BrightnessMatrix(0.1))
https://www.renpy.org/doc/html/trans_tr ... #Transform
https://www.renpy.org/doc/html/matrixcolor.html
Thanks a lot for your help.
Gouvernathor wrote: Mon Jan 17, 2022 6:06 pm You can actually find how to migrate from image manipulators to up-to-date renpy in the image manipulators page itself : https://www.renpy.org/doc/html/im.html
thanks, i will look on it.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]