realm wrapper #128
Aliases: realm wrapper
5 verbs · 45 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
generate_weather | this none this | rxd | #128 | 14 |
set_weather | this none this | rxd | #128 | 1 |
weather_msg | this none this | rxd | #128 | 19 |
time_of_day | this none this | rxd | #128 | 16 |
init_for_core | this none this | rxd | #128 | 18 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
weather_today | #128 | rc | #36 | 1 |
dawn_msgs | #128 | rc | #36 | {"The sun is rising.", "The cloudy sky begins to lighten in the east.", "A gray drizzle masks the dawn."} |
day_msgs | #128 | rc | #36 | {"The sun is shining.", "Fluffy clouds obscure the sun.", "It is a rainy day."} |
dusk_msgs | #128 | rc | #36 | {"The sun is setting.", "As the sun sets, the cloudy sky begins to darken in the east.", "The light begins to fade as you stand in the pouring rain."} |
night_msgs | #128 | rc | #36 | {"It is a starry night.", "Clouds obscure the moon and stars tonight, making it very difficult to see.", "It's dark and rainy."} |
hours_in_day | #128 | rc | #36 | 24 |
zone | #128 | rc | #36 | 1 |
oclose_msg | #8 | rc | #36 | <clear> |
close_msg | #8 | rc | #36 | <clear> |
oopen_msg | #8 | rc | #36 | <clear> |
open_msg | #8 | rc | #36 | <clear> |
oput_fail_msg | #8 | rc | #36 | <clear> |
put_fail_msg | #8 | rc | #36 | <clear> |
opaque | #8 | r | #2 | <clear> |
dark | #8 | r | #2 | <clear> |
oremove_fail_msg | #8 | rc | #36 | <clear> |
oremove_msg | #8 | rc | #36 | <clear> |
remove_fail_msg | #8 | rc | #36 | <clear> |
remove_msg | #8 | rc | #36 | <clear> |
oput_msg | #8 | rc | #36 | <clear> |
put_msg | #8 | rc | #36 | <clear> |
oopen_fail_msg | #8 | rc | #36 | <clear> |
open_fail_msg | #8 | rc | #36 | <clear> |
empty_msg | #8 | rc | #36 | <clear> |
opened | #8 | r | #2 | 1 |
open_key | #8 | c | #36 | <clear> |
drop_failed_msg | #5 | rc | #36 | <clear> |
drop_succeeded_msg | #5 | rc | #36 | <clear> |
odrop_failed_msg | #5 | rc | #36 | <clear> |
odrop_succeeded_msg | #5 | rc | #36 | <clear> |
otake_succeeded_msg | #5 | rc | #36 | <clear> |
otake_failed_msg | #5 | rc | #36 | <clear> |
take_succeeded_msg | #5 | rc | #36 | <clear> |
take_failed_msg | #5 | rc | #36 | <clear> |
value_base | #102 | r | #2 | <clear> |
damage_base | #102 | r | #2 | <clear> |
x_loc | #102 | r | #36 | <clear> |
y_loc | #102 | r | #36 | <clear> |
ansi_title | #102 | r | #36 | <clear> |
obvious | #102 | r | #36 | <clear> |
build_help | #102 | rc | #36 | list of 19{"This is a container that serves time-of-day and weather messages.", "", "Verbs to call:", " :weather_msg() returns a single string of text to the caller.", " :set_weather() sets the weather with a random number generator.", " Weather remains the same until this verb is called again.", "", "Properties to @edit:", " .day_msgs - A list of strings, each describing the current weather for", " this time of day. The most common is first, the most rare last.", " The properties below must contain the same number of lines as", " this one, or an error message will be returned from :weather_msg()", " .dawn_msgs", " .dusk_msgs", " .night_msgs", " ", "Properties to @set:", " .hours_in_day - How many earth hours constitute this planet's day.", " .zone - an integer from 1 to .hours_in_day, indicating the time zone."} |
key | #1 | c | #36 | 0 |
aliases | #1 | rc | #36 | {"realm wrapper"} |
description | #1 | rc | #36 | <clear> |
object_size | #1 | r | #36 | {7230, -1090650497} |
Ancestry
Ancestors (nearest first): #8 generic container → #5 generic thing → #102 subthing → #1 Root Class
Children: none
Call graph
Source
generate_weather
Referenced by
- #128:set_weather line 1:
this:generate_weather
Source
1"Returns a random number between 1 and length(this.day_msgs)"; 2"1 is the most likely number to be returned, and length(this.day_msgs) the least likely."; 3NUM = length(this.day_msgs); 4prob = $math_utils:sum(@$list_utils:range(1, NUM)); 5forecast = random(prob); 6z = prob - NUM; 7x = NUM; 8for n in [1..NUM] 9if (forecast > z) 10return n; 11endif 12x = x - 1; 13z = z - x; 14endfor
set_weather
Referenced by
none
Source
1return this.weather_today = this:generate_weather();
weather_msg
Referenced by
none
Source
1"Zones are from 1 - hours_in_day"; 2"hours_in_day must be at least 10"; 3if (((length(this.night_msgs) != length(this.day_msgs)) || (length(this.dawn_msgs) != length(this.dusk_msgs))) || (length(this.dusk_msgs) != length(this.day_msgs))) 4return "The weather messages on this planet need to all be the same number of lines. Order them from the most likely on the first line, to the least likely on the last line."; 5endif 6daylength = this.hours_in_day * 3600; 7zoneadjust = this.zone * 3600; 8abstime = $math_utils:mod(time(), daylength); 9sun = $math_utils:mod(abstime + zoneadjust, daylength); 10portion = tofloat(sun) / tofloat(daylength); 11if (portion < 0.4) 12return this.night_msgs[this.weather_today]; 13elseif (portion < 0.5) 14return this.dawn_msgs[this.weather_today]; 15elseif (portion < 0.9) 16return this.day_msgs[this.weather_today]; 17else 18return this.dusk_msgs[this.weather_today]; 19endif
time_of_day
Referenced by
none
Source
1"Zones are from 1 - hours_in_day"; 2"hours_in_day must be at least 10"; 3daylength = this.hours_in_day * 3600; 4zoneadjust = this.zone * 3600; 5abstime = $math_utils:mod(time(), daylength); 6sun = $math_utils:mod(abstime + zoneadjust, daylength); 7portion = tofloat(sun) / tofloat(daylength); 8if (portion < 0.4) 9return "night"; 10elseif (portion < 0.5) 11return "dawn"; 12elseif (portion < 0.9) 13return "day"; 14else 15return "dusk"; 16endif
init_for_core
Referenced by
none
Source
1if (caller_perms().wizard) 2if (this == $realm) 3this.weather_today = 1; 4this.dawn_msgs = {"The sun is rising.", "The cloudy sky begins to lighten in the east.", "A gray drizzle masks the dawn."}; 5this.day_msgs = {"The sun is shining.", "Fluffy clouds obscure the sun.", "It is a rainy day."}; 6this.dusk_msgs = {"The sun is setting.", "As the sun sets, the cloudy sky begins to darken in the east.", "The light begins to fade as you stand in the pouring rain."}; 7this.night_msgs = {"It is a starry night.", "Clouds obscure the moon and stars tonight, making it very difficult to see.", "It's dark and rainy."}; 8this.hours_in_day = 24; 9this.zone = 1; 10else 11for p in (properties($realm)) 12if ((!p) in {"build_help", "help_msg"}) 13clear_property(this, p); 14endif 15endfor 16endif 17return pass(@args); 18endif