[personal profile] kaigou posting in [community profile] style_system
Is it possible to set a variable to be another variable?

That is, instead of:

set color_thing = "#333366";

doing:

set color_thing = $*some_other_thing;

such that the default value of $*color_thing is equal to the value of $*some_other_thing, but with option for user to override?

Date: 2009-11-17 08:29 pm (UTC)
zvi: self-portrait: short, fat, black dyke in bunny slippers (Default)
From: [personal profile] zvi
Yes, that's true.

The thing that I don't think you can do, which I think you want to do, is say set this_value=y and in a function, set user_controlled_value=this_value

And then have there be an effect when the user changes the user_controlled_value through the wizard. I could be wrong about that, though.

Date: 2009-11-18 02:36 am (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
You can set properties to other properties on prop_init, but I'm not sure about the particular scenario you're proposing, since usually what we do is check whether $*Y has been set; if it has, we use the user-defined value. If it hasn't, we use the fallback value. So something like this:

layout:
property Color X { des = "base value" }
property Color Y { des = "falls back on base value if not provided" }
set X = "blue"
set Y = ""


function prop_init() {
    if ( $*Y == "" or not defined $*Y ) {
        # Y has no value, let's fill it in 
        $*Y = $*X
    }
}

Profile

Dreamwidth style system discussion

June 2025

S M T W T F S
1234567
891011121314
15161718 1920 21
22232425262728
29 30     

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 30th, 2025 07:38 pm
Powered by Dreamwidth Studios