I understand the title is a bit of a mouthful, and a tad confusing, so let me explain further.
I’m working on a system that takes real weather API data and translates that into the lighting system in the game. I have a module that holds the different values for different lighting properties and a serverscript that grabs the API data and changes the different lighting properties based on what weather comes back from the API table. My problem is, I have no idea, as the title suggests, how to basically make my script get to see what the API is returning for the weather, and then find the corresponding weather type in my module and set the different properties to the properties defined in the different parts in my module. For now, my module only has thunderstorms, but it will have more to come.
Serverscript
local Api_Key = "apikeyhere"
local Api_City_Name = "New York"
local Api_Url = "https://api.openweathermap.org/data/2.5/weather?q="..Api_City_Name.."&appid="..Api_Key
local HS = game:GetService("HttpService")
local module = require (game.ReplicatedStorage.Modules.WeatherConditionHandler)
local Data
local s, e = pcall(function()
Data = HS:GetAsync(Api_Url)
end)
if Data ~= nil then
Data = HS:JSONDecode(Data)
if Data.weather then
local weather = tostring(Data.weather[1].main)
print("Current Weather : "..weather)
game.ReplicatedStorage:WaitForChild("weather"):FireAllClients(weather)
else
error()
end
end
for keyName, keyValue in pairs(module) do
end
ModuleScript
local WeatherInfo = {
["Thunderstorm"] = {
CloudSize = 1;
CloudColor = 1;
Brightness = 1;
AtmosphereDensity = 1;
AtmosphereOffset = 1;
SkyboxBk = 1;
SkyboxDn = 1;
SkyboxFt = 1;
SkyboxLf = 1;
SkyboxRt = 1;
SkyboxUp = 1
};
}
return WeatherInfo