Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

modification of open script I got - online status

Rylee Lorefield
Registered User
Join date: 10 Dec 2008
Posts: 3
05-05-2009 16:22
Hi, I got this online hud from slx. It scans a website for uuid of user and detects when they are online or not. I use it sometimes in case the status is messed up (list messed) or for the owner of the land so know when they are on instead of random msg to clog their boxes. I was using a text based viewer called metabolt but I can't see the hud obviously. I was wondering if instead of buying a new one someone could post a modification to it to announce in chat when they are online as well as showing in hud. (eg. rylee lorefield showing in my hud and when detected will private msg me, or whisper "Rylee Lorefield is online or Rylee lorefield has gone offline (for ones who were on list previously)"

I'm posting the code here. I want to say I don't own the code, worked on code or know HOW to code but the code there was full perm.


If anybody can help I'd appreciate
Thanks
Rylee










// todo:
// notecard config
// text color
// help

string URL = "http://w-hat.com/name2key"; // name2key url
integer DefaultChan = 1;
float ScanTimer = 10.0;

string Name;
key HttpReqId; // http request id

integer Chan;
integer Index;
list Names;
list Keys;
list CardNames;
key QueryId;
string Text;
vector Color; // for floating text


// Static parameters for reading card config %%%
integer ConfigRequired = FALSE; // whether to fail if no config cards
string ConfigNotecardSuffix = ".cfg"; // string identifying config notecards
float ConfigTimeout = 60.0; // seconds per card to wait for slow server

// Globals for reading card config
integer ConfigLineIndex;
key ConfigRequestID;
list ConfigCards; // list of names of config cards
string ConfigCardName; // name of card being read
integer ConfigCardIndex; // index of next card to read

integer Debug; // Whether to print debug text


config_init()
{
Chan = DefaultChan;

// remove any card-configured items from the main lists
integer cx; // index into card-configured names
integer ix; // index into runtime lists
for (; cx < llGetListLength(CardNames); ++cx) {
string name = llList2String(CardNames, cx);
ix = llListFindList(Names, (list)name);
if (ix != -1) {
debug("removing " + name);
Names = llDeleteSubList(Names, ix, ix);
Keys = llDeleteSubList(Keys, ix, ix);
}
}
CardNames = [];
Debug = 0;
}

// print the configuration -- primarily for debugging.

config_dump()
{
say("Configured Names: " + llList2CSV(CardNames));
}


// Example notecard line parser.
//
// Comments lines begin with a slash
// Each line begins with a command followed by optional arguments
// Equals-sign ("=";) separates command and arguments (and args from each other)
// Unrecognized commands are ignored -- good for forwards-backwards notecard compatibility
// cardName and lineNum are in case you want to print error messages.

config_parse(string str, string cardName, integer lineNum)
{
str = llStringTrim(str, STRING_TRIM_HEAD); // delete leading spaces

// lines beginning with slash are comments -- ignore them
if (llGetSubString(str,0,0) == "/";) {
return;
}

list ldata = llParseString2List(str, ["="], [""]);
string cmd = llList2String(ldata,0);
string arg1 = llList2String(ldata,1);
string arg2 = llList2String(ldata,2);

// Example commands -- replace this code with meaningful stuff! %%%

if (cmd == "av";) {
CardNames = (CardNames=[]) + CardNames + llStringTrim(arg1, STRING_TRIM);
} else if (cmd == "channel";) {
Chan = (integer) arg1;
} else if (cmd == "color";) {
Color = (vector) arg1;
} else if (cmd == "timer";) {
ScanTimer = (float) arg1;
}

// this one is a good one to keep
else if (cmd == "debug";) {
Debug = (integer) arg1;
}
}


// Post-process any config, if necessary
config_done() {
if (Debug) {
config_dump();
}
say("Config done";);
}


// ==== Utilities ====

// Say something, to owner (%%% modify to whisper or whatever)

say(string str)
{
llOwnerSay(str);
}

debug(string str)
{
if (Debug) {
llWhisper(0, llGetScriptName() + ": " + str);
}
}

// return TRUE if there is a config card

integer next_card()
{
if (ConfigCardIndex >= llGetListLength(ConfigCards)) {
return (FALSE);
}

ConfigLineIndex = 0;
ConfigCardName = llList2String(ConfigCards, ConfigCardIndex);
ConfigCardIndex++;
ConfigRequestID = llGetNotecardLine(ConfigCardName, ConfigLineIndex);
say("Reading " + ConfigCardName);
return (TRUE);
}

// return TRUE if done
integer cardNameKeyQuery() {
++Index;
if (Index >= llGetListLength(CardNames)) {
return TRUE;
}
Name = llList2String(CardNames, Index);
debug("cnq " + (string)Index + ": " + Name);
HttpReqId = llHTTPRequest(URL + "?terse=1&name=" + llEscapeURL(Name), [], "" );
llSetTimerEvent(120.0);

return FALSE;
}



httpResponse(integer status, string body) {
if ( status == 499 )
llOwnerSay("name2key request timed out";);
else if ( status != 200 )
llOwnerSay("the internet exploded!!";);
else if ((key)body == NULL_KEY)
llOwnerSay("No key found for " + Name);
else {
integer ix = llListFindList(Names, (list)Name);
if (ix == -1) {
Names = llListSort(Names + (list)Name, 1, 1);
ix = llListFindList(Names, (list)Name);
Keys = llListInsertList(Keys, (list)body, ix);
} else {
Keys = llListReplaceList(Keys, (list)body, ix, ix);
}
llOwnerSay(Name + " added. Free memory: " + (string)llGetFreeMemory());
Name = "";
}
}

onlineQuery() {
llSetTimerEvent(0.0);
integer count = llGetListLength(Names);
if (count == 0) {
llSetText("", Color, 1.0);
return;
}

++Index;
if (Index >= count) {
llSetText(Text, Color, 1.0);
Text = "";
Index = -1;
llSetTimerEvent(ScanTimer);
return;
}

string id = llList2Key(Keys, Index);
// llSay(0, "query for " + llList2String(Names, Index));
QueryId = llRequestAgentData(id, DATA_ONLINE);
}

// ========== STATES =============

// Default state can do any init you need that doesn't require configuration.

default
{
state_entry() {
Names = [];
Keys = [];
state s_config;
}
}


// This state is only used to get into s_config, because going from
// s_config to s_config won't redo it's state_entry. But we might
// not want to redo anything we might have put in default state entry.

state s_reconfig
{
state_entry() {
state s_config;
}
}

// Read card config
// Multiple notecard version - read all cards with the given extension

state s_config
{
state_entry() {
config_init();

string item;
ConfigCards = [];
integer n = llGetInventoryNumber(INVENTORY_NOTECARD);
while (n-- > 0) {
item = llGetInventoryName(INVENTORY_NOTECARD, n);
if (llSubStringIndex(item, ConfigNotecardSuffix) != -1) {
ConfigCards += [item];
}
}

ConfigCardIndex = 0;
if (next_card()) {
llSetTimerEvent(ConfigTimeout);
} else if (ConfigRequired) {
say("Configuration notecard missing.";);
state s_configRetry;
} else {
state s_configDone;
}
}

dataserver(key query_id, string data) {
if (query_id == ConfigRequestID) {
if (data == EOF) {
if (next_card()) {
llSetTimerEvent(ConfigTimeout);
} else {
config_done();
state s_configDone;
}
} else {
config_parse(data, ConfigCardName, ConfigLineIndex);
ConfigRequestID = llGetNotecardLine(ConfigCardName, ++ConfigLineIndex);
}
}
}


timer() {
say("Dataserver time out: touch to retry";);
state s_configRetry;
}

on_rez(integer num) { state s_reconfig; }

changed(integer change) {
if (change & CHANGED_OWNER) { llResetScript(); }
if (change & CHANGED_INVENTORY) { state s_reconfig; }
}

state_exit() {
llSetTimerEvent(0);
llOwnerSay("Channel " + (string)Chan);
}
}

state s_configRetry
{
touch_start(integer tot) {
if (llDetectedKey(0) == llGetOwner()) {
state s_config;
}
}

changed(integer change) {
if (change & CHANGED_OWNER) { llResetScript(); }
if (change & CHANGED_INVENTORY) { state s_config; }
}
}

state s_configDone {
state_entry() {
Index = -1;
if (cardNameKeyQuery()) {
state s_active;
}
}

http_response(key id, integer status, list meta, string body) {
if (id != HttpReqId) {
return;
}
httpResponse(status, body);
if (cardNameKeyQuery()) {
state s_active;
}
}

changed(integer change) {
if (change & CHANGED_OWNER) { llResetScript(); }
if (change & CHANGED_INVENTORY) { state s_config; }
}

state_exit() {
llSetTimerEvent(0.0);
}
}


state s_active {
state_entry() {
llListen(Chan, "", llGetOwner(), "";);
Index = -1;
Text = "";
llSetText(Text, Color, 1.0);
onlineQuery();
}

listen(integer chan, string name, key id, string msg) {
list ldata = llParseString2List(msg, [" "], []);
string cmd = llList2String(ldata, 0);

if (cmd == "add";) {
Name = llList2String(ldata, 1) + " " + llList2String(ldata, 2);
HttpReqId = llHTTPRequest(URL + "?terse=1&name=" + llEscapeURL(Name), [], "" );
state s_w_hat;
return;
}

if (cmd == "delete";) {
string name = llList2String(ldata, 1) + " " + llList2String(ldata, 2);
integer ix = llListFindList(Names, (list)name);
if (ix == -1) {
llOwnerSay(name + " is not being tracked";);
return;
}

Names = llDeleteSubList(Names, ix, ix);
Keys = llDeleteSubList(Keys, ix, ix);
llOwnerSay(name + " removed";);
if (llListFindList(CardNames, (list)name) != -1) {
llOwnerSay("Note: " + name + " is card-configured. "
+ "You must delete them from the card for this to be permanent";);
}
Index = -1;
onlineQuery();
return;
}

if (cmd == "list";) {
llOwnerSay("All avs: " + llList2CSV(Names));
return;
}

if (cmd == "reset";) {
llOwnerSay("resetting";);
llResetScript();
}
}

dataserver(key queryid, string data) {

if (queryid != QueryId) {
return;
}

integer online = (integer) data;
if (online) {
Text += "\n" + llList2String(Names, Index);
}

onlineQuery();
}

touch_end(integer count) {
if (llDetectedKey(0) != llGetOwner()) {
return;
}
llOwnerSay("Edit config card or chat on channel " + (string) Chan);
llOwnerSay("Commands:";);
llOwnerSay(" /" + (string)Chan + " add John Smith";);
llOwnerSay(" /" + (string)Chan + " delete John Smith";);
llOwnerSay(" /" + (string)Chan + " list";);
llOwnerSay(" /" + (string)Chan + " reset";);
llOwnerSay("To edit config card, right-click, edit, "
+ "click 'More>>' if you see it, Content, and "
+ "double-click the notecard ending in '.cfg'.";);
}

timer() {
onlineQuery();
}

changed(integer change) {
if (change & CHANGED_OWNER) { llResetScript(); }
if (change & CHANGED_INVENTORY) { state s_reconfig; }
}

state_exit() {
llSetTimerEvent(0.0);
}
}

state s_w_hat {
state_entry() {
llSetTimerEvent(120.0);
}

http_response(key id, integer status, list meta, string body) {
if (id != HttpReqId) {
state s_active;
return;
}
httpResponse(status, body);
state s_active;
}

timer() {
state s_active;
}

changed(integer change) {
if (change & CHANGED_OWNER) { llResetScript(); }
if (change & CHANGED_INVENTORY) { state s_reconfig; }
}

state_exit() {
llSetTimerEvent(0.0);
}
}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-05-2009 18:52
since it doesn't store the online status in a variable, you'd have to have that first. and since it never tests for a difference between changing between online and off (because it's not stored) the best that can be done with this script is to make it spam the current status of people (by tweaking the onlineQuery(){ section).

anything else would be a rework of the script (and really the whole thing needs an overhaul).
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
05-05-2009 19:07
From: Rylee Lorefield
Hi, I got this online hud from slx.
............

I'm posting the code here. I want to say I don't own the code, worked on code or know HOW to code but the code there was full perm.

And presumably when you bought the hud you received permission to distribute the code to all and sundry, or was it open source ?
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
05-05-2009 20:55
From: ab Vanmoer
And presumably when you bought the hud you received permission to distribute the code to all and sundry, or was it open source ?


In SL, you have to assume, that giving full perm scripts = Open Source... It is a lot easier to hide code in SL then it is to open source it, marking all those permission boxes. People may argue with me about that, but I feel, if you take the time to actually make it mod/copy/trans, then you are saying, I agree to let people see, and modify this code, even if you put a disclaimer in the comments (which can be edited out easily).
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-06-2009 12:27
nah I pretty much agree that if you post code in the open it's effectively open source.

yes that includes code that has license text, because you know some ass is going to snag it, strip the license and repost it elsewhere. I wouldn't, but plenty will.

if I know it was licensed code I won't mess with it, but I'm not going to hunt very hard to find out if it was... this is why I post open or with courtesy licenses (ie, please leave open and with credit intact if you use as is, please credit me if you modify it. credit is nice, credits are nicer)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rylee Lorefield
Registered User
Join date: 10 Dec 2008
Posts: 3
..
05-07-2009 19:34
there was no license file or special instructions or notes of being gpl/open source. However this is not a new item and it was given full permission on slx, and to that extent doesn't it stand to reason i'm allowed to modify the code? if not myself, someone I asked to or a friend?

If not the storing of information to show online, went offline.. how about simply saying when someone goes online?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-08-2009 04:14
From: Rylee Lorefield
there was no license file or special instructions or notes of being gpl/open source. However this is not a new item and it was given full permission on slx, and to that extent doesn't it stand to reason i'm allowed to modify the code? if not myself, someone I asked to or a friend?

If not the storing of information to show online, went offline.. how about simply saying when someone goes online?

unfortunately, to know that you have to know they were offline before... and it's just not being stored, so can't be checked... the only simple rework of that script would be to have it spam status every cycle, which you could limit to online... but still not something you are going to want...

plus the code jumps around unnecessarily and is a bit sloppy... best would be to buy or commission a new one. if I ever finish the code on my status object, it'll be made public here. it basically does all that tracking black box style with several commands you can reference it with from other scripts.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
05-08-2009 06:12
That's my code, and it's intentionally open.

BTW, Void's code jumps around and is sloppy. You can quote me on that. :)
Rylee Lorefield
Registered User
Join date: 10 Dec 2008
Posts: 3
buy commission
05-08-2009 11:54
eh. no money to buy or commission nothing. besides this might be a bit different in coding than other people but it actually does 99.999999% of what I want it todo without buying anything else. I contacted the author, he says the distribution allows for 3rd party to modify the code but the resulting object should be owned by the new coder.

Besides all this, I'm never going to be crazy enough to commission any coder to make something for me. Its way to much $$ for something so little in value to me, if I were to sell afterwards thats another but again - it's been my experience - the coder wants yet more money to allow this.

If you ever do finish that code void, keep me in mind or please offer this on slx or here in script library.

p.s. blablabla value of this or that... again "I'm not crazy enough", "no money" and "little value to me" so I'm not trying to make this an arguement to coders
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-08-2009 15:21
From: Lear Cale
That's my code, and it's intentionally open.

BTW, Void's code jumps around and is sloppy. You can quote me on that. :)

=P

if you want to know my reasoning all you had to do was ask.
(no point in subbing out code that is only used in one place, and relies on other calculations to be useful elsewhere. either inline it, or encapsulate it where it can be used as is in other projects)
/end dissection reasoning.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
05-08-2009 16:09
Just messin with you. I believe that's an older version, and it was something I tossed together quickly, not a polished piece of work. Note the todo comments at the top?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-08-2009 22:33
busted =)

ya got me.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -