Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Lindens to US Dollars and back again...

Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-26-2007 07:55
Is there a constant that portrays the ratio between the US dollar and the Linden amounts?

I know about the "Lindex" (not that I can easily find that...) but is there a constant (a variable name that holds a value) that reflects that ratio?

Thanks, just by the way, I did look at the titles of the posts here. I am now off to the WIKI to see if they have such a list of LSL constant variables.

And YES, I do realize that it would be ironic for something that is ANYTHING but constant to be a constant.

Samhain Broom
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
03-26-2007 11:16
From: Samhain Broom


And YES, I do realize that it would be ironic for something that is ANYTHING but constant to be a constant.


I would think that would answer your own question.
Since the exchange rates fluctuate daily there can not be a true constant. Maybe the question isn’t if you need a constant but if you can take the daily exchange rate from a data base and somehow use that in your script.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
A Rose by any other name
03-26-2007 12:53
What Samhain is actually talking about is a system variable rather than a constant.
LINK_SET and INVENTORY_NOTECARD are examples of system constants, they are defined for us by SL/LL and have fixed constant values.
I think Samhain was hoping for CURRENT_DOLLAR_RATE or something similar that would supply the L$/US$ rate at that point in time. Unfortunately I'm not aware of any such variable.

With the way that LSL is designed, or at least written :), it would more likely be supplied as a function calll that returns a value via the dataserver i.e.
CODE
llRequestSystemInfo(DATA_SYS_EXCHANGE_RATE);


As Max suggested this could probably be obtained with from an external source via http / rpc / xml or even good old email.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-26-2007 15:38
If you scrape the URL http://secondlife.com/httprequest/lindex.php using llHTTPRequest you get an enormous body of lindex data returned using the string \n as a separator. Depending on which exchange rate you want you'll have to use the right bit... easiest way is to parse to a list using \n as the separator and then llList2Integer to grab the right bit.

Although my scripts are in php and do other things too, the scripts at eloisepasteur.net use this scrape and slice solution and replace the lsl ones I used to use before the cron job was up and running properly.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-26-2007 21:18
*Runs off and creates his own cronjob*

I've just been runnin' the lsl HTTPRequest every 24 hrs...dunno why I didn't figure on a cron... *kicks self*
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-27-2007 08:40
Thanks,

I did mean the system constant type, and yes that was why I also pre-agreed that the term seemed like an oxymoron. (Jumbo Shrimp/Military Intelligence...)

I'm good from here. I will of course make this available to people on request when I have a version. Maybe I will put it in a body attachable unobtrusive prim.

Thanks everybody for the information.

Sam
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Little Gray
Registered User
Join date: 16 Oct 2006
Posts: 48
03-27-2007 22:01
i've spent a few good hours searchign for a key or description of the values in httprequest/lindex.php, mentioned above, without any luck.

For example, whats the difference between ll_1h_max_rate 0 ll_1h_min_rate 0 and mb_1h_min_rate 266 mb_1h_max_rate 267?

What value correspondends to the total hourly/daily volumes?

Is there a daily average exhange rate? can any of the values be used to calculate a daily average exchange rate?
Seidr Giha
Registered User
Join date: 21 Mar 2007
Posts: 8
03-28-2007 03:32
I'm not sure if this information is of any help, but it does describe a formula for calculating the daily average exchange rate at the bottom of the post.

http://blog.secondlife.com/2006/10/03/new-data-feeds-1/

From: someone
For example, to calculate today’s average exchange rate you can use this formula:

(limit_buy_to_limit_sell:today:l$_volume + market_buy:today:l$_volume + market_sell:today:l$_volume) / (limit_buy_to_limit_sell:today:us$_volume + market_buy:today:us$_volume + market_sell:today:us$_volume)


Edit: On the second entry of this blog the poster provides an SLURL to a location to their office which contains in game script examples for retrieving the appropriate data.

http://blog.secondlife.com/2006/10/03/new-data-feeds-2/

http://slurl.com/secondlife/whitlock/82/133/83/?title=Lawrence%20Linden's%20Office
Seidr Giha
Registered User
Join date: 21 Mar 2007
Posts: 8
03-28-2007 04:20
I've retrieved the script mentioned above, if you would like to take a look without having to jump into SL.

CODE
key keySentRequest = NULL_KEY;
integer DEBUG = 0;

default
{
state_entry ()
{

}

touch_start (integer total_number)
{
if (keySentRequest == NULL_KEY)
{
keySentRequest = llHTTPRequest ("http://secondlife.com/httprequest/lindex.php", [], "");
}
}

http_response (key keyReceivedRequest, integer intStatus, list lstMeta, string strBody)
{
list lstData;
integer intDataLength;
integer intIndex;

if (keyReceivedRequest != keySentRequest)
{
if (DEBUG) llSay (DEBUG_CHANNEL, "key mismatch");
keySentRequest = NULL_KEY;
return;
}

lstData = llParseString2List (strBody, ["\n"], []);

// Dump all the data
if (DEBUG)
{
intDataLength = llGetListLength (lstData);

for (intIndex = 0; intIndex < intDataLength; intIndex += 2)
{
llSay (DEBUG_CHANNEL, "name = '" + llList2String (lstData, intIndex) + "', value = '" + llList2String (lstData, intIndex + 1) + "'");
}
}

integer intPos;

// The safe way to grab the data, probably should consider making a nice accessor instead of repeating this code for each value
intPos = llListFindList (lstData, ["updated_unix"]);

if (intPos == -1)
{
if (DEBUG) llSay (DEBUG_CHANNEL, "updated_unix not found");
keySentRequest = NULL_KEY;
return;
}

integer intUpdatedUnix = llList2Integer (lstData, intPos + 1);



intPos = llListFindList (lstData, ["updated_slt"]);

if (intPos == -1)
{
if (DEBUG) llSay (DEBUG_CHANNEL, "updated_slt not found");
keySentRequest = NULL_KEY;
return;
}

string strUpdatedSLT = llList2String (lstData, intPos + 1);


// Grabbing the data this way can and WILL fail in bad ways, doing it this way to keep the example short and readable
integer intLVolume =
llList2Integer (lstData, llListFindList (lstData, ["ll_1d_l$"]) + 1)
+
llList2Integer (lstData, llListFindList (lstData, ["mb_1d_l$"]) + 1)
+
llList2Integer (lstData, llListFindList (lstData, ["ms_1d_l$"]) + 1);

float fltUSVolume =
llList2Float (lstData, llListFindList (lstData, ["ll_1d_us$"]) + 1)
+
llList2Float (lstData, llListFindList (lstData, ["mb_1d_us$"]) + 1)
+
llList2Float (lstData, llListFindList (lstData, ["ms_1d_us$"]) + 1);

float fltRate = intLVolume / fltUSVolume;

llSay (0, "Volume for the past 24 hours: L$" + (string) intLVolume);
llSay (0, "Average rate for the past 24 hours: L$" + (string) fltRate + " / US$1.00");
llSay (0, "L$" + llList2String (lstData, llListFindList (lstData, ["ls_10%_l$_offer"]) + 1) + " for sale between L$"
+ llList2String (lstData, llListFindList (lstData, ["ls_10%_min_rate"]) + 1) + " / US$1.00 and L$"
+ llList2String (lstData, llListFindList (lstData, ["ls_10%_max_rate"]) + 1) + " / US$1.00");
llSay (0, "L$" + llList2String (lstData, llListFindList (lstData, ["lb_10%_l$_offer"]) + 1) + " wanted between L$"
+ llList2String (lstData, llListFindList (lstData, ["lb_10%_min_rate"]) + 1) + " / US$1.00 and L$"
+ llList2String (lstData, llListFindList (lstData, ["lb_10%_max_rate"]) + 1) + " / US$1.00");
llSay (0, "Data last updated " + strUpdatedSLT);

keySentRequest = NULL_KEY;
}
}
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-28-2007 06:42
This is GREAT response to my question. I'm going to try these scripts when I get home tonight (or maybe will be tomorrow) but this will greatly help me with a project!

Thanks to all who are helping. It's also good that people are looking around and asking questions. Thanks again!

Sam
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
03-30-2007 16:09
I just now had a chance to get in and play with that script.

Excellent!! Now I have all the tools to do what I need to do with that.

When I have something, I will post here, and you can all get a copy free!

haha!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts