Page 1 of 1

[Solved] config.speaking_attribute does not play nice with config.layers

Posted: Sun Jul 08, 2018 5:35 am
by kivik
I've just discovered a behaviour that I wasn't aware of till now, and I wonder if it's intended behaviour or not.

I've got a speaking attribute enabled with my images, and my character images are assigned to a "characters" layer, to allow me to clear out all visible characters without changing the background easily. To make life easier for myself, I used config.tag_layer to automatically assign them to specific layers by default.

I made the mistake of forgetting to add one of my character's tag_layer, but they still got placed onto the "characters" layer by my code. However, as a result - the speaking attribute doesn't get triggered when they're speaking.

This is resolved by adding them to config.tag_layer, but I don't see why this should be the case at all. The character in either cases are automatically placed onto the "characters" layer, but by missing the config.tag_layer out for one character, their speaking attribute no longer triggers.

Re: config.speaking_attribute does not play nice with config.layers

Posted: Sun Jul 08, 2018 10:15 pm
by PyTom
You shouldn't be manually specifying a layer if you give a tag_layer - that's just redundancy. Other than that, the layers are independent of each other, so Ren'Py doesn't know which one to use if it's not told.

Re: config.speaking_attribute does not play nice with config.layers

Posted: Tue Jul 10, 2018 4:48 am
by kivik
PyTom wrote:
Sun Jul 08, 2018 10:15 pm
You shouldn't be manually specifying a layer if you give a tag_layer - that's just redundancy. Other than that, the layers are independent of each other, so Ren'Py doesn't know which one to use if it's not told.
Agreed on removing the redundancy - it was written before I was aware of tag_layer.

However, the problem itself here is that if I assign layer on show (instead of using tag_layer), the speaking attribute doesn't work.

Sample code to show this problem:

Code: Select all

define config.speaking_attribute = "speaking"
define config.layers = [ 'master', 'characters', 'transient', 'screens', 'overlay' ]

image catherine speaking:
    "layered/catherine_speaking.png"
image catherine:
    "layered/catherine.png"
image karen speaking:
    "layered/karen_speaking.png"
image karen:
    "layered/karen.png"
image anna speaking:
    "layered/anna_speaking.png"
image anna:
    "layered/anna.png"

define c = Character("Catherine", image="catherine")
define k = Character("Karen", image="karen")
define a = Character("Anna", image="anna")

label main_menu:
    return

label start:
    scene black
    show catherine onlayer characters at left
    show karen onlayer characters
    show anna onlayer characters at right
    "Hi"
    c "hi"
    a "hi"
    k "Hi"

Re: config.speaking_attribute does not play nice with config.layers

Posted: Tue Jul 10, 2018 11:48 am
by PyTom
If you assign it correctly - using your tag_layer - it will work. If not, it will not. I don't consider this to be a problem.

Re: config.speaking_attribute does not play nice with config.layers

Posted: Tue Jul 10, 2018 4:38 pm
by kivik
PyTom wrote:
Tue Jul 10, 2018 11:48 am
If you assign it correctly - using your tag_layer - it will work. If not, it will not. I don't consider this to be a problem.
So you're saying that config.speaking_attribute only works with images on non-standarded layers if config.tag_layer is used in the first place? As this is the current behaviour, but I don't believe it's documented that it only works in this specific conditions?

I understood config.tag_layer as an additional tool that auto assigns images to layers, and I don't understand why it should affect whether config.speaking_attribute would work on an image or not.

Hope that makes more sense?

Re: config.speaking_attribute does not play nice with config.layers

Posted: Tue Jul 10, 2018 4:52 pm
by kivik
Just done a couple of tests.

Without default config.layers setup:

- If I show the images on the screens layer (transient and overlay leads to images fading away quickly), speaking attribute doesn't work.
- If I show the images on the master layer manually, speaking attribute works as intended.
- If I use config.tag_layer and assign an image to the screens layer, then show it on the master layer manually, speaking attribute doesn't work.
- If I use config.tag_layer and assign an image to the master layer and show it on the master, speaking attribute works as intended.
- If I use config.tag_layer and assign an image to the screens layer and show it on the screens, speaking attribute works as intended.

So this makes me think there's some internal dictionary that sets the "default layer" for all images on init, and speaking attribute only works for images shown on their default layer. config.tag_layer seems to add to this dictionary for anything that aren't on master layers.

Re: config.speaking_attribute does not play nice with config.layers

Posted: Wed Jul 11, 2018 2:14 am
by PyTom
That's correct. config.tag_layer is used to find the layer with the image on it, with the master layer being used if one is not found. You're allowed to have different images with the same tag on different layers - for example, you can have a screen with the same name as a sprite tag. (I don't recommend putting anything but a screen on the screens layer.)

Re: config.speaking_attribute does not play nice with config.layers

Posted: Wed Jul 11, 2018 8:20 am
by kivik
PyTom wrote:
Wed Jul 11, 2018 2:14 am
That's correct. config.tag_layer is used to find the layer with the image on it, with the master layer being used if one is not found. You're allowed to have different images with the same tag on different layers - for example, you can have a screen with the same name as a sprite tag. (I don't recommend putting anything but a screen on the screens layer.)
Ah I think I see now:you're saying the speaking_attribute only triggers the relevant image on the default layer, because you can have the same image on different layers - so only the default layer one is affected. That makes more sense for sure :)

I was only using screens layer to demonstrate the problem without adding a new layer to expand the possible reasons behind the "bug".

Thanks for the explanation. I know it's quite specific that I end up being affected by this, but would it be worth mentioning on the config.speaking_attribute documentation the default layer behaviour?