Search the Community
Showing results for tags 'weather'.
-
This script will allow you to retrieve real world weather data for a location. Please note that this will require you to register at OpenWeatherMap.org (which is free and will allow a high number of free service calls per day) and obtain an API key, which will need to be pasted into gsApiKey for this to work. For readability, I have placed the city and country in global variables that are hard-coded, but you can, of course, expand this into something like a dialog or a menu. /* WEATHER CHECKER Created 2018-10-19 by Bugs Larnia ************* WARNING: This script requires that you register at OpenWeatherMap.org and append the API key to this script WARNING: DO NOT SHARE YOUR API KEY OR AN EDITABLE SCRIPT WITH YOUR API KEY IN IT!!! ************* Please keep annotations */ //USER SETTINGS string gsCity = "San Francisco"; //The city you want the weather for string gsCountry = "us"; //The country code (optional) string gsApiKey = "YOUR API_KEY HERE"; //The API key you receive from OpenWeatherMap.org //END USER SETTINGS string gsUrl = "https://api.openweathermap.org/data/2.5/weather?q="; //The base URL //Function to create the url + endpoint and send the request key SendCall() { string sUrl = gsUrl + llEscapeURL(gsCity) + "," + gsCountry + "&APPID=" + gsApiKey; key kRequest = llHTTPRequest(sUrl, [HTTP_METHOD, "GET", HTTP_BODY_MAXLENGTH, 16384], ""); return kRequest; } //Function to set/clear the floating text SetText(string psText) { if (psText != "") { psText += "\n \n \n \n"; } llSetText(psText, <1.0, 1.0, 0.0>, 1.0); } default { state_entry() { SetText(""); //Clear the text } touch_start(integer total_number) { SendCall(); //Send the request } http_response(key pkHttpReqId, integer piStatus, list plMetaData, string psBody) { if (piStatus == 200) //Check if the request is successful (200 == OK) { list lResponse = llJson2List(psBody); //Put the response in a list integer iIndex = llListFindList(lResponse, ["weather"]); //Get the weather item list lWeather = llJson2List(llList2String(lResponse, iIndex + 1)); //Parse the weather item data list lWeatherDetails = llJson2List(llList2String(lWeather, 0)); //Get the details integer iWeatherId = llList2Integer(lWeatherDetails, 1); //We need the weather ID //Morph the ID into a text //NOTE: A full list of weather ids can be found at: https://openweathermap.org/weather-conditions string sWeatherType = "having unknown weather"; if (iWeatherId < 300) { sWeatherType = "having thunderstorms"; } else if (iWeatherId < 400) { sWeatherType = "having some drizzle"; } else if (iWeatherId < 600) { sWeatherType = "having rain"; } else if (iWeatherId < 700) { sWeatherType = "having snow"; } else if (iWeatherId < 800) { sWeatherType = "under a bit of a haze"; } else if (iWeatherId == 800) { sWeatherType = "having a clear sky"; } else { sWeatherType = "having some clouds"; } //Set the floating text SetText(gsCity + " is " + sWeatherType + " at the moment."); } else //No 200, so error { SetText("Error " + (string)piStatus + "\n" + psBody); //Show the error } llSetTimerEvent(10.0); //Timer to clear the text } //Timer to clear the text timer() { llSetTimerEvent(0.0); SetText(""); } //Housekeeping on_rez(integer piParam) { llResetScript(); } }
-
Here's a crazy idea. What if it were possible to import NOAA weather data to an avatar's location? If you have rain in the default world, it would be raining in the sim you were visiting.
-
greetings, i am hiring a sim designer for a weather system. I have totally messed it up. Am NOT looking for a windlight setting, but a full day cycle for our sim
-
I don't really do scripting but I am a decorator. For personal use on my land I would like to use my audio stream to trigger prims to change from transparent to opaque and vice-versa through listening to the song name on an audio stream. For instance I will have animated rain textures that are placed all around that when the song says Storm or rain it will appear and when it says sunny it will disappear. Is there a way I can accomplish this? Thanks in advance for any help Note: This is something I would like to be just very simple as far as scripts go just doing the function I said. It doesn't need to do anything else