realm wrapper #128

Parent #8Owner #36Flags read, fertileSource RPG Core/rpgcore-patched.db

Aliases: realm wrapper

5 verbs · 46 properties · 1 children

Verbs

VerbSpecFlagsDefinerLines
generate_weatherthis none thisrxd#12814
set_weatherthis none thisrxd#1281
weather_msgthis none thisrxd#12819
time_of_daythis none thisrxd#12816
init_for_corethis none thisrxd#12818

Properties

PropertyDefinerFlagsOwnerValue
weather_today#128rc#361
dawn_msgs#128rc#36{"The sun is rising.", "The cloudy sky begins to lighten in the east.", "A gray drizzle masks the dawn."}
day_msgs#128rc#36{"The sun is shining.", "Fluffy clouds obscure the sun.", "It is a rainy day."}
dusk_msgs#128rc#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#128rc#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#128rc#3624
zone#128rc#361
oclose_msg#8rc#36<clear>
close_msg#8rc#36<clear>
oopen_msg#8rc#36<clear>
open_msg#8rc#36<clear>
oput_fail_msg#8rc#36<clear>
put_fail_msg#8rc#36<clear>
opaque#8r#2<clear>
dark#8r#2<clear>
oremove_fail_msg#8rc#36<clear>
oremove_msg#8rc#36<clear>
remove_fail_msg#8rc#36<clear>
remove_msg#8rc#36<clear>
oput_msg#8rc#36<clear>
put_msg#8rc#36<clear>
oopen_fail_msg#8rc#36<clear>
open_fail_msg#8rc#36<clear>
empty_msg#8rc#36<clear>
opened#8r#21
open_key#8c#36<clear>
drop_failed_msg#5rc#36<clear>
drop_succeeded_msg#5rc#36<clear>
odrop_failed_msg#5rc#36<clear>
odrop_succeeded_msg#5rc#36<clear>
otake_succeeded_msg#5rc#36<clear>
otake_failed_msg#5rc#36<clear>
take_succeeded_msg#5rc#36<clear>
take_failed_msg#5rc#36<clear>
value_base#102r#2<clear>
damage_base#102r#2<clear>
x_loc#102r#36<clear>
y_loc#102r#36<clear>
ansi_title#102r#36<clear>
obvious#102r#36<clear>
build_help#102rc#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#1c#360
aliases#1rc#36{"realm wrapper"}
description#1rc#36<clear>
object_size#1r#36{7230, -1090650497}
html#1rc#36<clear>

Ancestry

Ancestors (nearest first): #8 generic container#5 generic thing#102 subthing#1 Root Class

Children: #150 Land of Demo

Call graph

calls n128_0 #128:generate_weather n26_29 #26:sum n128_0->n26_29 n55_1 #55:range n128_0->n55_1 n128_1 #128:set_weather n128_1->n128_0 n128_2 #128:weather_msg n26_13 #26:mod n128_2->n26_13 n128_3 #128:time_of_day n128_3->n26_13 n128_4 #128:init_for_core n102_1 #102:init_for_core n128_4->n102_1

Source

generate_weather

Spec this none thisFlags rxdOwner #36Definer #128

Referenced by

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

Spec this none thisFlags rxdOwner #36Definer #128

Referenced by

none

Source

1return this.weather_today = this:generate_weather();

weather_msg

Spec this none thisFlags rxdOwner #36Definer #128

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

Spec this none thisFlags rxdOwner #2Definer #128

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

Spec this none thisFlags rxdOwner #2Definer #128

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