kaigou: this is what I do, darling (Default)
锴 angry fishtrap 狗 ([personal profile] kaigou) wrote in [community profile] style_system2009-11-17 11:37 am

style system variables

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?
zvi: self-portrait: short, fat, black dyke in bunny slippers (Default)

[personal profile] zvi 2009-11-17 08:29 pm (UTC)(link)
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.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2009-11-18 02:36 am (UTC)(link)
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
    }
}