Dhalgren_utils (#1000)

(an instance of generic thing made by Calkins)

     An icosahedral crystal containing a number of userful local verbs.
     
     :third_person(string,verb)      => substitute kick and kicks in string
     :weather_daytime(string,object) => substitute it and raining
     :audience(object)               => is object with a connected player?

Go to location of this object, Steamer Trunk.



VERB SOURCE CODE:

third_person:
" third_person(, ) substitutes the verb for %v in the string.  %vs 
is substituted by the third-person form of the verb, with some intelligence.";
s = args[1];
v = args[2];
lv = length(v);
if (v[lv] in {"s", "x", "o", "u", "i"})
    vs = v + "es";
elseif ((lv >= 2) && (v[lv - 1..lv] in {"ch", "sh"}))
    vs = v + "es";
elseif ((lv >= 2) && (v[lv - 1..lv] in {"ay", "ey", "oy", "uy"}))
    vs = v + "s";
elseif (v[lv] == "y")
    vs = v[1..lv - 1] + "ies";
elseif (i = v in {"be", "have"})
    vs = {"is", "has"}[i];
else
    vs = v + "s";
endif
s = strsub(s, "%vs", vs);
return strsub(s, "%v", v);
.


weather_daytime:
" weather_daytime(, ) looks for weather and daytime messages on  
and substitutes %daytime and %weather in the string accordingly.  Weather is computed 
as a pseudorandom function of time.";
s = args[1];
what = args[2];
hour = tonum(ctime(clock = time())[12..13]);
if ((hour < 6) || (hour > 20))
    daytime = what.night_msg;
elseif (hour < 9)
    daytime = what.morning_msg;
elseif (hour < 18)
    daytime = what.day_msg;
else
    daytime = what.evening_msg;
endif
noise = abs((((clock / 3600) / 8) * 1103515245) + 12345) % 3;
climate = abs(((clock / 3600) / 24) + noise) % 11;
if (climate == 2)
    weather = what.raining_msg;
elseif (climate < 6)
    weather = what.warm_msg;
elseif (climate == 8)
    weather = what.snowing_msg;
else
    weather = what.cool_msg;
endif
s = strsub(s, "%weather", weather);
s = strsub(s, "%daytime", daytime);
return s;
.



audience:
" audience() indicate if a listening player (not self) is in the room with 
the object.";
what = args[1];
if ($object_utils:connected(what.location))
    return 1;
else
    for c in (what.location.contents)
        if ((c != what) && $object_utils:connected(c))
            return 1;
        endif
    endfor
endif
return 0;
.




PROPERTY DATA: