AlbinoRhino
Active member
I kind of suspect there are many CHiT users who don't monitor this thread and WOULD need a migration script. I probably should have voted THREE.
vprop uses split_string() to divide sets/lists on "delimiter". That means "delimiter" is actually a regex. If you use "|", ",", ";", etc., it looks like a simple string, but you can be more complicated. (And since "|" is a regexp character, if you use exactly "|" as your "delimiter", we convert it into "\\|" for use by split_string()).I'd like mention that I'm going to be using a rather stripped down and customized version of the vProp code. Thanx to Veracity for the inspiration, but since I have control over how it is used I don't need to account for every variation. Also, I need to use multiple delimiters in a single property whereas vProp is only able to handle one at a time.
See above. But your technique is fine.In case anyone is curious -- mostly for Veracity's curiosity -- I present my intended code. Note that normalize_prop() has a functional improvement over vProp's equivalent to allow me to mix comma and bar in a single property.
Yeah, that's fair. You can still use vprops's to_list_of_string(), etc, functions on built-in properties without needing to pass them through define_property or normalize first.define_property() is merely a stripped down version since it doesn't have to survive in someone else's environment. (I feel safe in believing that I won't attempt to override a default mafia property.)
Glad you like it! I thought for a long time about how I wanted it to behave and implemented a handful of new property functions for ASH's runtime library in order to make it possible, and it ended up being quite simple, actually.Despite my changes I owe much gratitude to Veracity for envisioning the concept and designing the original, astonishingly robust, code for me to work with.
string normalize(string value, string type) {
if(value == "string")
return value;
string func = "to_" + type;
return call string func(value);
}
string normalize_prop(string value, string type) {
matcher list = create_matcher("(^|[,|])([^,|]*)", value);
buffer newlist;
while(list.find())
list.append_replacement(newlist, list.group(1) + normalize(list.group(2), type));
return newlist;
}
string define_property(string name, string type, string def) {
// All "built-in" properties exist. A "custom" property that doesn't exist uses the (normalized) default.
string normalized_def = normalize_prop(def, type);
if(!property_exists(name))
return normalized_def;
// The property exists and (potentially) overrides the default
string raw_value = get_property(name);
string value = normalize_prop(raw_value, type);
if(value == normalized_def)
remove_property(name);
else if(raw_value != value)
set_property(name, value);
return value;
}
vprop uses split_string() to divide sets/lists on "delimiter". That means "delimiter" is actually a regex. If you use "|", ",", ";", etc., it looks like a simple string, but you can be more complicated. (And since "|" is a regexp character, if you use exactly "|" as your "delimiter", we convert it into "\\|" for use by split_string()).
// This script converts zlib vars for ChIT. It creates new mafia properties with the same names as the old vars.
// Two vars have been removed from the configuration.
import "zlib.ash";
foreach prop,val in vars
if(prop.contains_text("chit.") && prop!= "chit.gear.display.aftercore.defaults" && prop!= "chit.gear.display.in-run.defaults")
set_property(prop, val);
ashq import "zlib.ash"; foreach prop,val in vars if(prop.contains_text("chit.") && prop!= "chit.gear.display.aftercore.defaults" && prop!= "chit.gear.display.in-run.defaults") set_property(prop, val);
I did it. zlib vars are no longer being used in this script. To copy some of your zlib vars to vProps type zlib chit. in the CLI and choose the ones you need. Then just copy/paste the relevant line, changing the world "zlib" to "set" to create the vProp.
If you want to copy over ALL your vars, then simply copy/paste the following line into the CLI
Code:ashq import "zlib.ash"; foreach prop,val in vars if(prop.contains_text("chit.") && prop!= "chit.gear.display.aftercore.defaults" && prop!= "chit.gear.display.in-run.defaults") set_property(prop, val);
Note that after the first run of chit, it will compare your properties to the default values for those options and if they are the same, it will remove the unnecessary property, leaving only the properties which are necessary. So don't panic when you see only a few chit properties in preferences file.
chit.autoscroll => true
chit.character.avatar => true
chit.character.title => true
chit.checkversion => false
chit.clan.display => off
chit.clan.home => El Chupacabra
chit.currencies => source essence,BACON
chit.currencies.showmany => false
chit.disable => false
chit.effects.classicons => none
chit.effects.describe => true
chit.effects.layout => songs,buffs,intrinsics
chit.effects.modicons => true
chit.effects.showicons => true
chit.effects.usermap => false
chit.familiar.anti-gollywog => true
chit.familiar.hats => spangly sombrero,sugar chapeau
chit.familiar.pants => spangly mariachi pants,double-ice britches,BRICKO pants,pin-stripe slacks,Studded leather boxer shorts,Monster pants,Sugar shorts
chit.familiar.protect => false
chit.familiar.showlock => false
chit.familiar.terrariumlinklarge => false
chit.familiar.weapons => time sword
chit.floor.layout => update, familiar
chit.gear.display.aftercore => favorites:amount=all, quest:amount=all, charter:amount=all, today:amount=all:create=false, rollover, DRUNK:amount=all
chit.gear.display.in-run => favorites:amount=all:pull=true:create=true, astral:amount=all, item, -combat, +combat, quest:amount=all:pull=true:create=true, today:amount=all:create=false, ML, initiative, path:amount=all, prismatic, res, meat, charter:amount=all, rollover, DRUNK:amount=all, Wow:amount=all
chit.gear.favorites => droll monocle,stinky cheese eye,Hand in Glove,Half a Purse,A Light that Never Goes Out,smiths,hobo code binder,buddy bjorn,The Crown of Ed the Undying,crumpled felt fedora,Hairpiece on Fire,Pantsgiving,Vicar's Tutu,Astral Shirt,duct tape shirt,Stephen's lab coat
chit.gear.layout => default
chit.gear.pull => true
chit.gear.recommend => in-run
chit.helpers.dancecard => true
chit.helpers.semirare => true
chit.helpers.spookyraven => true
chit.helpers.wormwood => stats,spleen
chit.helpers.xiblaxian => true
chit.kol.coolimages => true
chit.quests.hide => false
chit.recommendgear => in-run
chit.roof.layout => character,stats,gear
chit.size.wide => false
chit.stats.layout => muscle,myst,moxie|hp,mp,axel|mcd|trail,florist
chit.stats.showbars => true
chit.thrall.showname => false
chit.toolbar.layout => trail,quests,modifiers,elements,organs
chit.toolbar.moods => true
chit.walls.layout => helpers,thrall,vykea,effects
chit.currencies => BACON|Source essence
chit.familiar.hats => sugar chapeau|spangly sombrero
chit.gear.favorites => duct tape shirt|hobo code binder|crumpled felt fedora|stinky cheese eye|astral shirt|Pantsgiving|The Smith's Tome|A Light that Never Goes Out|Half a Purse|Hairpiece On Fire|Vicar's Tutu|Hand in Glove|Buddy Bjorn|Stephen's lab coat|droll monocle|The Crown of Ed the Undying
Prefref chit doesn't give any return values doesn't return any settings for me. Do I need to do something before the default values show in the settings?
I guess that means I'll have to find the defaults somewhere in the script?