Changeset 1031


Ignore:
Timestamp:
09/11/09 05:40:45 (2 years ago)
Author:
james
Message:

Add revmixin and nomixin options to %VAR, to allow the gender-mixin stuff to be controlled

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/abstract.tcl

    r1026 r1031  
    6666# fileformat is simply one per line. 
    6767 
     68# default = mixin own gender 
     69# reverse = mixin opposite gender 
     70# none = don't mixin at all 
     71set BMOTION_MIXIN_DEFAULT 0 
     72set BMOTION_MIXIN_REVERSE 1 
     73set BMOTION_MIXIN_NONE 2 
     74 
    6875if { [bMotion_setting_get "abstractMaxAge"] != "" } { 
    6976  set bMotion_abstract_max_age [bMotion_setting_get "abstractMaxAge"] 
     
    340347 
    341348        set contents [bMotion_abstract_all $abstract] 
    342         putlog $contents 
    343349 
    344350        if {[llength $contents] == 0} { 
     
    366372} 
    367373 
    368 proc bMotion_abstract_get { abstract } { 
    369         bMotion_putloglev 5 * "bMotion_abstract_get ($abstract)" 
     374proc bMotion_abstract_get { abstract { mixin_type 0 } } { 
     375        bMotion_putloglev 5 * "bMotion_abstract_get ($abstract $mixin_type)" 
    370376  global bMotion_abstract_contents bMotion_abstract_timestamps bMotion_abstract_max_age bMotion_abstract_last_get bMotionInfo 
    371377 
     
    388394 
    389395        # look for male and female versions, and merge in if needed 
    390         if [bMotion_abstract_exists "${abstract}_$bMotionInfo(gender)"] { 
    391                 # mix-in the gender one with the vanilla one 
    392                 bMotion_putloglev 1 * "mixing in $bMotionInfo(gender) version of $abstract" 
    393                 set final_version [concat [bMotion_abstract_all $abstract] [bMotion_abstract_all "${abstract}_$bMotionInfo(gender)"]] 
    394         } else { 
    395                 set final_version [bMotion_abstract_all $abstract] 
    396         } 
    397  
     396        set final_version [bMotion_abstract_all $abstract] 
     397        switch $mixin_type { 
     398                0 { 
     399                        if [bMotion_abstract_exists "${abstract}_$bMotionInfo(gender)"] { 
     400                        # mix-in the gender one with the vanilla one 
     401                                bMotion_putloglev 1 * "mixing in $bMotionInfo(gender) version of $abstract" 
     402                                set final_version $final_version [bMotion_abstract_all "${abstract}_$bMotionInfo(gender)"]] 
     403                        } else { 
     404                                set final_version [bMotion_abstract_all $abstract] 
     405                        } 
     406                } 
     407                1 { 
     408                        if {[bMotion_setting_get "gender"] == "male"} { 
     409                                set gender "female" 
     410                        } else { 
     411                                set gender "male" 
     412                        } 
     413                        if [bMotion_abstract_exists "${abstract}_$gender"] { 
     414                        # mix-in the gender one with the vanilla one 
     415                                bMotion_putloglev 1 * "mixing in $gender version of $abstract" 
     416                                set final_version [concat $final_version [bMotion_abstract_all "${abstract}_$gender"]] 
     417                        } else { 
     418                                set final_version [bMotion_abstract_all $abstract] 
     419                        } 
     420                } 
     421                2 { 
     422                        # noop, we did it already before the switch 
     423                } 
     424                default { 
     425                        putlog "bMotion ERROR: unknown mixin type $mixin_type for abstract $abstract" 
     426                } 
     427        } 
    398428 
    399429        if {[llength $final_version] == 0} { 
     
    634664bMotion_abstract_revive_language 
    635665 
     666 
    636667bMotion_putloglev d * "abstract module loaded" 
  • trunk/modules/abstracts/en/randomstuff.tcl

    r1027 r1031  
    2424        "Check out my %VAR{bodypart:plural}" 
    2525        "I have expendable %VAR{bodypart:plural}" 
     26        "I have expandable %VAR{bodypart:plural}" 
    2627        "%BOT[The Ambassador's receptions are noted in society for their host's exquisite taste that captivates his guests.]%|Monsieur, with this %VAR{sillyThings:strip} you are really spoiling us!" 
    2728        "where there's a snack gap, a %VAR{PROM} fits" 
     
    207208 
    208209        "WHOOSH *DONG*" 
    209         "i'm awash with %VAR{bodypart}s" 
     210        "i'm awash with %VAR{bodypart:plural}" 
    210211        "I feel a great disatisfaction within my bowels." 
    211212        "Pardon me. Do you have any grey poupon?" 
     
    372373        "i'm giving up evil science and taking up even gardening instead" 
    373374        "noooo! enormous naked buttocks heading towards my head!%|i'm being simultaneously crushed and embarrassed to death" 
    374         "yay! %VAR{bodypart}s!" 
     375        "yay! %VAR{bodypart:plural}!" 
    375376} 
    376377 
     
    380381### Mixed in with list above 
    381382bMotion_abstract_register "randomStuff_male" { 
     383        "I always thought the most sensual part of a woman was the %VAR{bodypart:revmixin}" 
    382384        "Looks like the squirrel's been showing everyone where he keeps his nuts." 
    383385        "You wanna see some stuff I'm not supposed to show anyone?" 
  • trunk/plugins/en/output_VAR.tcl

    r1029 r1031  
    2424proc bMotion_plugin_output_VAR { channel line } { 
    2525        bMotion_putloglev 4 * "bMotion_plugin_output_VAR $channel $line" 
     26        global BMOTION_MIXIN_NONE BMOTION_MIXIN_REVERSE BMOTION_MIXIN_DEFAULT 
    2627 
    2728        set line [string map { "%noun" "%VAR{sillyThings}" } $line] 
     
    3031        regsub {%VAR\{([^\}]+)\}\{strip\}} $line "%VAR{\\1:strip}" line 
    3132 
    32         if {[regexp -nocase {(%VAR\{([^\}:]+)(:[^\}]+)?\}(\{strip\})?)} $line matches whole_thing abstract options clean]} { 
     33        if {[regexp -nocase {(%VAR\{([^\}:]+)(:([^\}]+))?\}(\{strip\})?)} $line matches whole_thing abstract 1 options clean]} { 
    3334                global $abstract 
     35 
     36                bMotion_putloglev 1 * "options for $abstract are $options" 
     37 
     38                # check options 
     39                if {$options != ""} { 
     40                        set options_list [split $options ","] 
     41                } else { 
     42                        set options_list [list] 
     43                } 
     44                bMotion_putloglev 1 * "options list is $options_list" 
     45 
     46                if {$clean == "{strip}"} { 
     47                        lappend options_list "clean" 
     48                } 
     49 
     50                set mixin_type $BMOTION_MIXIN_DEFAULT 
     51 
     52                if {[lsearch $options_list "revmixin"] > -1} { 
     53                        bMotion_putloglev 1 * "mixin type for $abstract is reverse" 
     54                        set mixin_type $BMOTION_MIXIN_REVERSE 
     55                } elseif {[lsearch $options_list "nomixin"] > -1} { 
     56                        bMotion_putloglev 1 * "mixin type for $abstract is none" 
     57                        set mixin_type $BMOTION_MIXIN_NONE 
     58                } 
     59 
    3460                #see if we have a new-style abstract available 
    35                 set newText [bMotion_abstract_get $abstract] 
     61                set newText [bMotion_abstract_get $abstract $mixin_type] 
    3662                set replacement "" 
    3763                if {$newText == ""} { 
     
    4975                } 
    5076 
    51                 # check options 
    52                 set options [string range $options 1 end] 
    53                 if {$options != ""} { 
    54                         set options_list [split $options ","] 
    55                 } else { 
    56                         set options_list [list] 
    57                 } 
    58  
    59                 if {$clean == "{strip}"} { 
    60                         lappend options_list "clean" 
    61                 } 
    6277 
    6378                if {[lsearch $options_list "strip"] == -1} { 
     
    131146} 
    132147 
     148 
    133149bMotion_plugin_add_output "VAR" bMotion_plugin_output_VAR 1 "en" 3 
Note: See TracChangeset for help on using the changeset viewer.