The documentation for llCloud
specifies that the function returns values between .0
and 2.0
where the values between 1.0
and 2.0
are an indication of precipitation. Also, the documentation specifies that a simulator is divided into 16x16
tiles, each of them capable of their own variations.
Using that, we can build a weather system by generating a 16x16
grid using the Planar Tile Generator. Since a simulator is 256m in length and width, we will need 16
tiles measuring 16m
by 16m
on both the x
and y
axes.
The simulator will be thus filled with the tiles, set to invisible and phantom and placed at any convenient height in order to not interfere with the simulator.
After that, we add two scripts in each tile that will be responsible for creating either snow or rain particles depending on the month.
The first script is responsible for checking the weather every second and sending a message to the second script:
/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// default { state_entry() { llSetTimerEvent(1); } timer() { float w = llCloud(ZERO_VECTOR); if(w > 1) { llMessageLinked(LINK_THIS, 1, "", NULL_KEY); return; } llMessageLinked(LINK_THIS, 0, "", NULL_KEY); } }
The second script is responsible for generating particles, either snow or rain depending on the time of month:
/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// default { state_entry() { llParticleSystem([]); } link_message(integer sender_num, integer num, string str, key id) { if(!num) return; integer m = llList2Integer(llParseString2List(llGetDate(), ["-"], []), 1); if(m > 2 && m < 10) state rain; state snow; } } state rain { state_entry() { list rain = [ // start of particle settings // Texture Parameters: PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0), PSYS_PART_START_SCALE, <.4,.4, FALSE>, PSYS_PART_END_SCALE, <.2,.2, FALSE>, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <1,1,1>, PSYS_PART_START_ALPHA, (float).9, PSYS_PART_END_ALPHA, (float).1, // Production Parameters: PSYS_SRC_BURST_PART_COUNT, (integer)(900*llCloud(ZERO_VECTOR)), PSYS_SRC_BURST_RATE, (float) .1, PSYS_PART_MAX_AGE, (float)105.0, PSYS_SRC_MAX_AGE,(float) .0, // Placement Parameters: PSYS_SRC_PATTERN, (integer)8, // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE, // Placement Parameters (for any non-DROP pattern): PSYS_SRC_BURST_SPEED_MIN, (float).0, PSYS_SRC_BURST_SPEED_MAX, (float).2, PSYS_SRC_BURST_RADIUS, 20.0, // Placement Parameters (only for ANGLE & CONE patterns): PSYS_SRC_ANGLE_BEGIN, (float) .33*PI, PSYS_SRC_ANGLE_END, (float)2*PI, // PSYS_SRC_OMEGA, <0,0,0>, // After-Effect & Influence Parameters: PSYS_SRC_ACCEL, <.0,.0,-.2>, // PSYS_SRC_TARGET_KEY, llGetLinkKey(llGetLinkNumber() + 1), PSYS_PART_FLAGS, (integer)( 0 // Texture Options: | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_EMISSIVE_MASK // | PSYS_PART_FOLLOW_VELOCITY_MASK // After-effect & Influence Options: // | PSYS_PART_WIND_MASK // | PSYS_PART_BOUNCE_MASK // | PSYS_PART_FOLLOW_SRC_MASK // | PSYS_PART_TARGET_POS_MASK // | PSYS_PART_TARGET_LINEAR_MASK ) //end of particle settings ]; llParticleSystem(rain); } link_message(integer sender_num, integer num, string str, key id) { if(!num) state default; } } state snow { state_entry() { list snow = [ // start of particle settings // Texture Parameters: PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0), PSYS_PART_START_SCALE, <.4,.4, FALSE>, PSYS_PART_END_SCALE, <.2,.2, FALSE>, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <1,1,1>, PSYS_PART_START_ALPHA, (float).9, PSYS_PART_END_ALPHA, (float).1, // Production Parameters: PSYS_SRC_BURST_PART_COUNT, (integer)(900*llCloud(ZERO_VECTOR)), PSYS_SRC_BURST_RATE, (float) .1, PSYS_PART_MAX_AGE, (float)105.0, PSYS_SRC_MAX_AGE,(float) .0, // Placement Parameters: PSYS_SRC_PATTERN, (integer)8, // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE, // Placement Parameters (for any non-DROP pattern): PSYS_SRC_BURST_SPEED_MIN, (float).0, PSYS_SRC_BURST_SPEED_MAX, (float).2, PSYS_SRC_BURST_RADIUS, 20.0, // Placement Parameters (only for ANGLE & CONE patterns): PSYS_SRC_ANGLE_BEGIN, (float) .33*PI, PSYS_SRC_ANGLE_END, (float)2*PI, // PSYS_SRC_OMEGA, <0,0,0>, // After-Effect & Influence Parameters: PSYS_SRC_ACCEL, <.0,.0,-.2>, // PSYS_SRC_TARGET_KEY, llGetLinkKey(llGetLinkNumber() + 1), PSYS_PART_FLAGS, (integer)( 0 // Texture Options: | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_EMISSIVE_MASK // | PSYS_PART_FOLLOW_VELOCITY_MASK // After-effect & Influence Options: // | PSYS_PART_WIND_MASK // | PSYS_PART_BOUNCE_MASK // | PSYS_PART_FOLLOW_SRC_MASK // | PSYS_PART_TARGET_POS_MASK // | PSYS_PART_TARGET_LINEAR_MASK ) //end of particle settings ]; llParticleSystem(snow); } link_message(integer sender_num, integer num, string str, key id) { if(!num) state default; } }
The script considers any precipitation after February and before October to be rain. Between October and February the titles will generate snow instead. This can be adjusted to your needs by modifying the particle generator code:
if(m > 2 && m < 10) state rain; state snow;
where 2
and 10
represent months. For example, to make the tile generate rain between April and July and otherwise snow, one would modify the code as follows:
if(m > 4 && m < 7) state rain; state snow;