Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //フローティングテキストに現在のログインユーザー数を表示する
- //
- key request_id;
- string NumberFormat(string numberString){
- string output;
- integer x = 0;
- integer numberStringLength = llStringLength(numberString);
- integer z = (numberStringLength + 2) % 3;
- for(;x < numberStringLength; ++x)
- {
- output += llGetSubString(numberString, x, x);
- if ((x % 3) == z && x != (numberStringLength - 1))
- output += ",";
- }
- return output;
- }
- get_HTTP(){
- //HTTPでデータ取得(何故だかhttps指定だとエラーになる)
- request_id = llHTTPRequest("http://secondlife.com/httprequest/homepage.php",[],"");
- }
- default{
- on_rez(integer i){
- llResetScript();
- }
- state_entry(){
- llSetText("", <1.0, 1.0, 1.0>, 1.0);
- get_HTTP();
- llSetTimerEvent(180.0);//feed更新が3分間隔なので180秒で回す
- }
- timer(){
- get_HTTP();
- }
- http_response(key id, integer status, list metadata, string body){
- if(id == request_id){
- if(status == 200){
- //正常だったら改行コードで分離してLISTに格納(ascii文字のみのためエンコード不要)
- list feed_LIST = llParseString2List(body,["\n"],[]);
- //データがあれば取得
- integer idx;
- string text;
- //全ユーザー数
- idx = llListFindList(feed_LIST, ["signups"]);
- if(~idx) text += "Total Users : " + NumberFormat(llList2String(feed_LIST,idx + 1)) + "\n";
- //現在のログインユーザー数
- idx = llListFindList(feed_LIST, ["inworld"]);
- if(~idx) text += "Online Users : " + NumberFormat(llList2String(feed_LIST,idx + 1)) + "\n";
- //現在の1US$ と L$の為替レート(小数付きの数字をそのまま出力)
- idx = llListFindList(feed_LIST, ["exchange_rate"]);
- if(~idx) text += "1 US$ = " + llList2String(feed_LIST,idx + 1) + " L$\n";
- llSetText(text, <1.0,1.0,1.0>, 1.0);
- }else{
- // llSay(0,"error code = " + (string)status);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement