RE: The old Brian Wolven weather script
"Hale, Paul" <paul.hale-X7qyDxFx8/lR5dUNPGT/[email protected]> Thu, 1 Oct 2009 09:11:39 -0500
| Newsgroups | gmane.comp.windows.shells.litestep |
|---|---|
| Message-ID | <41F1CDD445082F4C86B767CDC1FF6E250F7C152E@brexc50p> |
> I wrote a script in Lua that fetches the data from Yahoo! Weather. It
> requires luasocket, http://luaforge.net/projects/luasocket/
> It's pretty simple and shot actually, the code is here:
> http://bitbucket.org/THC4k/litestep-
> ots3/src/tip/Data/luaext/Lua/yahoo/weather.lua
>
> The Script only loads the data, it doesnt display anything. You have to
> write a script that displays them on a label.
> In my Blank Theme i do this to show data, in `weatherdata:load()`:
> http://bitbucket.org/THC4k/litestep-
> ots3/src/df4cb3b5b1e2/Data/defaulttheme/Neu/scripts/buttons/Weather.lua
>
> Here is the basic idea, completely untested and written in my mail client
> ;-)
>
> ----
> --[[ needs xlabel and timer litestep modules loaded ]]--
> require "lsmodule"
> require "yahoo.weather"
>
> local weather_label = lsmodule.xlabel.weather_label -- some xlabel to
> display stuff
> location = "GMXX0087" -- my hometown ;-)
> unit = "C"
>
> lsmodule.every( "10m", function() -- every 10 minutes
> local ok, data = pcall(weather.fetch, location, unit) -- try to
> load
> the forecast
> if ok then
> local str = ('Condition: %s<br>Temperature: %s
> °%s'):format(data.condition.text, data.condition.temp,
> data.units.temperature) -- data holds the forecast
> weather_label:settext( str ) -- set it as text on the xlabel
> else
> -- errors happen, inet connection down, server busy or whatever
> lslua.message_box( 'Loading weather failed with', data )
> end
> end ):start()
> ----
>
> Dunno if you're using Lua at all, but i can never resist the opportunity
> for a shameless plug ;-)
>
No, I have never used lua, and honestly I have no idea what you have up there. Scripting has always been my weakest point.
You say you use this in your theme, is it up somewhere for download? I might be able to use it to learn from. Gues I'll have to update to OTS3 though. Man, it has been forever since I changed themes. Been using this one Since August of 2007!
---------------------------------------------------------------------
Can't Unsubscribe? Check http://desktopian.org/listunsub.html
LS List Homepage: http://wuzzle.org/list/litestep.php
Get the LS FAQ: http://lsfaq.shellfront.org