PDA

View Full Version : Weather and Say plug-in



Treetop
April 14th, 2004, 11:48 AM
Im having a bit of a brain fart on this, and was wondering if someone could put me back on the right path.

Goal: To have the weather forecast (whether current or future, doesn't matter at this time), spoken over my speakers. I will be using the Speak plug-in as the trigger event. (ie. "computer, what is the weather?".. "Currently 70 degrees and clear" .. or however it parses the data)

The only thing for weather that I was able to locate, is the weather.js and weahtersettings.lua files included in the DVDSpy plug-in. As I don't have an LCD/VFD, would I still want to use this? I dont want to install something else on this machine if I dont have to, as I finally got it up and running smoothly and would really hate to have it get broken.

If I do use those files without the DVDSpy part, how do I implement them into girder? .js is javasript? I think I would use the .lua as a variable manipulation script.... am I getting close?

I know absolutely nothing about computer languages (other than they exist), so if I had to write something in LUA myself, it could easily take the better part of this year to get it working, but if that is the only way, I guess I would start in on it. Looked at LUA once.... all I can say is :o

Any pointers would be much appreciated, as Im not even sure where to start with this.

Here are some threads that I was able to pull up..
http://www.girder.nl/phpBB2/viewtopic.php?t=2340&highlight=weather
http://www.girder.nl/phpBB2/viewtopic.php?t=5985&highlight=weather
but both of these talk about using the LCD/VFD as the disp[lay for the info.

Treetop

Promixis
April 14th, 2004, 01:05 PM
The weather script in DVDSpy can be used to get the weather data - you do not have to display it on the vfd/lcd. But, to get this working, you will have to learn a little about lua. Lua is a great language and is easy to get started with.

Promixis
May 27th, 2004, 09:37 AM
--[[

Weather retrieval

original script in jscript by MMcM, converted by Mike C

requires Girder 3.3 or >

Weather = GetWeather (accid)

accid = ZIP code or location code. See weather.com.

returns a table containing the weather, run script to see possible indexes.

remarks: this retreives the with using a sychronous call. This means that Girder is blocked while
waiting for the weather. It is possible to do use an asynchronous call with this object.

ie Weather.Temp = temperature
--]]


function WeatherGet (accid)
local WeatherHTTPReq
local Math
local s
local weather

if not luacom then
UnloadLuaCom ()
end
LoadLuaCom ()

WeatherHTTPReq = luacom.CreateObject("WinHttp.WinHttpRequest.5.1")
if not WeatherHTTPReq then
return
end

WeatherHTTPReq:Open("GET", "http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=" .. accid, 0)
WeatherHTTPReq:Send();
if WeatherHTTPReq.Status ~= 200 then
return
end

s = WeatherHTTPReq.ResponseText
Math = {}
Math.round = function (x)
return round (x,1)
end

s= gsub (s,"}","return this end")
s =(gsub (s,"{","this = {}"))
s= gsub (s,"sw","")
dostring (s)

weather = makeWeatherObj ()

WeatherHTTPReq = nil
collectgarbage ()
return weather
end


function WeatherPrint (weather)
local x,y
for x,y in weather do
print (x,": ",y)
end
end


WeatherPrint (WeatherGet (55410))