Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Chart ThingSpeak Chart  

ThingSpeak Chart

An attempt at making Thingspeak charts in SL

Category: Chart
By : Ferd Frederix
Created: 2016-05-02 Edited: 2016-05-02
Worlds: Second Life

the Zip file

Download all files for ThingSpeak Chart
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 integer osIsNpc(key UUID) { return 0; }
3
4
5 string wAPIKey = "419JVLGPPTCM5TZ1";
6
7 string ChannelID = "47964";
8 string fieldID = "field1";
9
10 list exclude = [];
11 // You can add a list of name of people to exclude, such as your name.
12 // list exclude = ["Nara Malone","Ferd Frederix"];
13
14 integer debug = FALSE;
15 integer hovertext = TRUE; // shows visitor count, or not
16 integer ToDo;
17 integer timeGoneBy = 0;
18
19 DEBUG(string msg)
20 {
21 if(debug ) llOwnerSay(msg);
22 }
23
24 key http_request_id;
25 list ToDoURL;
26
27 default
28 {
29
31 {
32 llSetText("", <1,1,1>, 1);
33
34 string url = "https://api.thingspeak.com/update?api_key="
35 + wAPIKey
36 + "&"
37 + "title"
38 + "="
39 + "Visitors";
40
41 http_request_id = llHTTPRequest(llList2String(ToDoURL,0), [], "");
43 }
44
45 timer()
46 {
47 if(ToDo == 0 && timeGoneBy )
48 {
49 DEBUG((string) timeGoneBy);
50 timeGoneBy--;
51 return;
52 }
53
54 if(ToDo == 0 && !timeGoneBy )
55 {
56 timeGoneBy = 60;
57
58 ToDoURL = [];
59
60 list keys = llGetAgentList(AGENT_LIST_REGION,[]);
61
62 integer i;
63 for (i=0; i < llGetListLength(keys); ++i)
64 {
65 key UUID = llList2Key(keys,i);
66 if(!osIsNpc(UUID)) {
67 string name = llKey2Name(UUID); // name
68 DEBUG("Checking " + name);
69
70 if(hovertext) llSetText(name, <1,1,1>, 1);
71 if(llListFindList(exclude,[name]) == -1)
72 {
73 list details = llGetObjectDetails(UUID, [OBJECT_POS]) ; // pos
74 vector pos = llList2Vector(details,0);
75 string x = (string) pos.x;
76 string y = (string) pos.y;
77 string z = (string) pos.z;
78
79 // parcel
81 string parcel = llList2String(details,0);
82
83 string url = "https://api.thingspeak.com/update?api_key=" + wAPIKey
84 + "&field1=" + x;
85 + "&field2=" + y;
86
87 DEBUG(url);
88 ToDoURL += url;
89 }
90 }
91 }
92 ToDo = 1; // send them
93 }
94 else if(ToDo == 1)
95 {
96 if(llGetListLength(ToDoURL) == 0)
97 {
98 ToDo = 0;
99 return;
100 }
101
102 DEBUG(llList2String(ToDoURL,0));
103 http_request_id = llHTTPRequest(llList2String(ToDoURL,0), [], "");
104
105 ToDoURL = llDeleteSubList(ToDoURL,0,0);
106 }
107 }
108
109 http_response(key request_id, integer status, list metadata, string body)
110 {
111 if(request_id == http_request_id)
112 {
113 if(hovertext)
114 llSetText("Click for Stats", <0,0,1>, 1);
115
116 DEBUG(body);
117 }
118 }
119
121 {
123 {
124 llLoadURL(llGetOwner(), "Click to view vistors", "https://thingspeak.com/channels/"
125 + ChannelID
126 + "/"
127 + fieldID);
128 }
129 }
130
131 }

Back to the Best Free Tools in Second Life and OpenSim.