Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MH+ presents, Light on off automatically by day cycle
- //join us! => https://discord.me/SLguru
- //visit my blog => https://sl-memo.blogspot.com/
- //地域に設定された日周期から昼夜判別をして自動で照明のOn/Offを行うサンプルです
- //
- integer ONOFF;
- vector color = <1,1,1>;
- float intensity = 1.0;
- float radius = 5.0;
- float falloff = 0.75;
- integer face = 1;
- float glow = 0.5;
- float check_sec = 30.0;
- SW(){
- llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_POINT_LIGHT, ONOFF, color, intensity, radius, falloff
- ,PRIM_FULLBRIGHT, face, ONOFF
- ,PRIM_GLOW, face, ((float)ONOFF)*glow]);
- }
- default{
- state_entry(){
- SW();
- llSetTimerEvent(check_sec);
- }
- touch_start(integer total_number){
- ONOFF = !ONOFF;
- SW();
- llSetTimerEvent(3600.0);//1時間後に再始動
- }
- timer(){
- //現在時刻の計算
- float timeOfDay = (llGetUnixTime() + llGetDayOffset()) % llGetDayLength() * 1.0 / llGetDayLength();
- integer hours = (integer)(timeOfDay * 24);
- integer minutes = (integer)(timeOfDay * 24 * 60) % 60;
- integer now_time = (integer)((string)hours + llGetSubString((string)(100+minutes), 1, 2));
- //日周期からの時刻で昼夜判別
- integer NightMode = !((now_time >= 0300) && (now_time < 2100));
- if(NightMode != ONOFF){
- ONOFF = NightMode;
- SW();
- }
- llSetTimerEvent(check_sec);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement