Page 194 of 208 FirstFirst ... 94 144 184 192 193 194 195 196 204 ... LastLast
Results 1,931 to 1,940 of 2075

Thread: Character Info Toolbox

  1. #1931
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    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.

    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. 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.) 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.

    Code:
    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;
    }
    Last edited by Bale; 03-16-2017 at 11:27 PM.

  2. #1932
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,458

    Default

    It's completely fine with me if you want to take my code and adopt it and modify it and customize it to your taste.
    Open source, and all that.

    And I will consider your code as potential inspiration for my own.

    As I mentioned elsewhere, my attention has been elsewhere all day, so I'll look closer tomorrow.

    Thank you for telling me that I fixed all the deficiencies in the original set of "property" functions. I made the changes because I wanted something closer to how _I_ wanted them to behave - and I am sure that zarqon could/would have used them had they existed - but, having commit access to the KoLmafia source, it was easier to simply Make It So for my desired changes.

    I believe that my public comment thread which existed at least a week before I started coding allowed sufficient user input into my thinking.

    I"ll look at and opine, by and by, on your three proposed options - although actual Chit users' opinions count for more.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  3. #1933
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    844

    Default

    I like option 'TWO' myself. I wanted my chit settings to be "global" to begin with and didn't like that, when I decided to change something, I had to do it separately for each character.
    Last edited by AlbinoRhino; 03-17-2017 at 03:20 AM.

  4. #1934
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    It's completely fine with me if you want to take my code and adopt it and modify it and customize it to your taste.
    Open source, and all that.
    Originally Posted by Veracity View Post
    I am very glad you feel that way. (Knowing your feelings towards open code I'm not surprised, just glad.) You did some amazing work which I hadn't even thought I wanted until I saw it.

    Thank you for telling me that I fixed all the deficiencies in the original set of "property" functions. I made the changes because I wanted something closer to how _I_ wanted them to behave - and I am sure that zarqon could/would have used them had they existed - but, having commit access to the KoLmafia source, it was easier to simply Make It So for my desired changes.
    I adore your changes. One of the reasons I hated the idea of using properties for configuration settings is that it is too easy for them to get lost in the preferences file and then I'd end up with a bajillion settings for programs that I tried out once and don't use anymore. Your changes made it possible to winnow out the preferences that aren't part of mafia. Lack of structure for scripts to organize or remove preferences is one of the reasons that zarqon created the variable system that he built into zlib. Though your idea that scripts would contain global preferences so that modification by the user is helpful was entirely new.

    I really, really hope that everyone who uses preferences to configure programs thinks to make sure that the name of their program is in the name of the preference. I'd hate to have to guess at their purpose the next time I winnow through the prefs.


    I like option 'TWO' myself. I wanted my chit settings to be "global" to begin with and didn't like that, when I decided to change something, I had to do it separately for each character.
    Originally Posted by AlbinoRhino View Post
    I'm a little surprised that the first vote was for option TWO. It is certainly the option that makes the least work for me.
    Last edited by Bale; 03-17-2017 at 04:34 AM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  5. #1935
    Senior Member
    Join Date
    Feb 2010
    Posts
    982

    Default

    I vote for option three.

  6. #1936
    Developer
    Join Date
    Apr 2010
    Posts
    4,892

    Default

    I'm running with defaults, so vote for two as easiest for Bale, but with low care.

  7. #1937
    Senior Member
    Join Date
    Jan 2012
    Location
    Texas
    Posts
    422

    Default

    I vote for Option two

  8. #1938
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,821

    Default


    [INDENT]ONE: ... If I do this, how long should I keep the migration code in place? I
    Originally Posted by Bale View Post
    Immediate reaction: one year. Err on the side of caution, then multiply by 3, then round up to something with a short name. A month sounds like it should be enough, which means it wouldn't.

    That being said, this is the worst option, because it just hands-off obsoletes the zlib variables, which will then keep stinking up my files.

    Two is good, though at "Some people will want to edit the default values" I can't keep myself from thinking about how to make sure svn can merge any changes without conflict when you also change the ... *default* default ...
    like
    Code:
    var propDefault = 'original setting from bale';
    // propDefault = 'change this and uncomment the line if you want a different default for all your characters';
    define_property('prop','string',propDefault);
    ?

    Three is best for me. Especially if the script also handles removing lines from vars_xKiv.txt.
    (I don't need to keep them for backups, I already make *several* off-PC backups every year! which is good, because when my power source died yesterday, I had a month "young" data to work with on another computer)

  9. #1939
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    824

    Default

    I like option TWO.

    That said, I would probably just end up writing a small script to port over my settings from zlib vars to ChIT preferences anyway, so it would end up being THREE (with less work for Bale).

  10. #1940
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    I like option TWO.

    That said, I would probably just end up writing a small script to port over my settings from zlib vars to ChIT preferences anyway, so it would end up being THREE (with less work for Bale).
    Originally Posted by ckb View Post
    Then maybe I'll keep you to that. I can handle TWO, which honestly is quite a bit of work. Meanwhile you can write a script that would port the zlib settings to identically named preferences. Slightly less work for me!

    I'm reassured by how many people are comfortable with the last two options. Everyone seems to think it is fine to have a separate script for migrating your old ChIT settings to the new system. And many don't even need that much.
    Last edited by Bale; 03-17-2017 at 09:18 PM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


Similar Threads

  1. Bug - Fixed Bad Spoiler Info
    By Bale in forum Bug Reports
    Replies: 1
    Last Post: 05-30-2014, 08:39 AM
  2. Daily Info
    By icon315 in forum Relay Override Scripts
    Replies: 66
    Last Post: 06-19-2013, 01:42 PM
  3. Feature More monster info
    By ckb in forum Bug Reports
    Replies: 19
    Last Post: 05-06-2013, 10:07 PM
  4. Replies: 0
    Last Post: 02-08-2011, 03:30 PM
  5. MMG toolbox
    By Veracity in forum Scripting Discussion
    Replies: 12
    Last Post: 08-10-2009, 03:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •