User:Cow Taurog/Exchange rate

From Second Life Wiki
< User:Cow Taurog
Revision as of 01:16, 17 August 2011 by Cow Taurog (talk | contribs) (create new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This script will say the current L$ exchange rate over public chat when touched. <lsl> // This text is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License. // http://creativecommons.org/licenses/by-nc-sa/3.0/ // Resale, or other commercial use is prohibited. // Modification and/or distribution is allowed, as long as attribution for each revision is given, and the same license is used. // // Cow Taurog's L$ exchange rate finder, v1.0 // // This script will say the current exchange rate of L$ per USD over public chat when touched by anyone // There are no options to change, but feel free to change the code, as long as you abide by the license // string gsURL="http://secondlife.com/httprequest/homepage.php"; // URL of LL's data feed list glRaw; // Storage of the entire data feed key gkReq; // Handler for the HTTP request default{

   on_rez(integer param){llResetScript();} // reset when rezzed
   changed(integer change){if(change&CHANGED_OWNER){llResetScript();}} // reset when owner changes
   touch_start(integer num){ // when touched by anybody...
       gkReq=llHTTPRequest(gsURL,[],""); // load the URL
   }
   http_response(key req,integer status,list meta,string mess){if(req==gkReq){ // when the URL is loaded...
       glRaw=llParseString2List(mess,["\n"],[]); // store the entire contents into a list
       integer iL=(llListFindList(glRaw,["exchange_rate"]))+1; // find the entry named 'exchange_rate', the actual rate is next in the list
       llSay(0,"Current exchange rate: L$"+(string)llRound(llList2Float(glRaw,iL))+" per $1 USD."); // round off the data to the nearest L$, and say it over public chat
   }}

} </lsl>