diff --git a/Nanite Systems/avatarperms.lsl b/Nanite Systems/avatarperms.lsl new file mode 100644 index 0000000..e68b9f9 --- /dev/null +++ b/Nanite Systems/avatarperms.lsl @@ -0,0 +1,138 @@ +//this will eventually get worked into something larger + +integer masterLightBus; +integer slaveLightBus; +key ownerKey; + +integer getChannel(key UUID) { + masterLightBus = -1 - (integer)("0x" + llGetSubString(UUID, -7, -1))+106; + return masterLightBus; +} + +init() { + ownerKey = llGetOwner(); + getChannel(ownerKey); + //llOwnerSay("Channel: " + (string)channelLightBus); + llListen(masterLightBus+1, "", NULL_KEY, ""); +} + +integer scanRange = 1000; +scan() { + llSensor("", NULL_KEY, AGENT, scanRange, PI); +} + +list avatarList = []; +list keyList = []; +selectMenu(list avatars) { + string text = "[" + (string)llGetListLength(avatars) + "] avatars detected."; + text += "\nScan range: " + (string)scanRange + "m"; + llDialog(ownerKey, text, avatars, masterLightBus+1); +} + +string unitName = ""; +key getUUID(string name) { + unitName = name; + integer x = llListFindList(avatarList, [name]); + return llList2String(keyList, x); +} + +permission(key UUID) { + llOwnerSay("Asking " + unitName + " for permission."); + slaveLightBus = -1 - (integer)("0x" + llGetSubString((string)UUID, -7, -1))+106; + llListen(slaveLightBus, "", NULL_KEY, ""); + llSay(slaveLightBus, "auth scanner " + (string)ownerKey); +} + +getPort(string UUID) { + if (UUID = "") { llSay(slaveLightBus, "port-connect data-1"); } + else { llSay(slaveLightBus, "port-connect " + UUID); } +} + +connect(string UUID) { + llOwnerSay("Port UUID: " + UUID); + particles(UUID); +} + +disconnect() { + llSay(slaveLightBus, "remove scanner"); + particles((string)ownerKey); +} + +list options = ["CONNECT","DISCONNECT"]; +optionsMenu() { + llDialog(ownerKey, "Options Menu", options, masterLightBus+1); +} + +particles(string UUID) { + llParticleSystem([ + PSYS_PART_FLAGS, 0 + | PSYS_PART_FOLLOW_VELOCITY_MASK + | PSYS_PART_INTERP_COLOR_MASK + | PSYS_PART_TARGET_POS_MASK + | PSYS_PART_RIBBON_MASK, + PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP, + PSYS_PART_START_COLOR, <1,1,1>, + PSYS_PART_END_COLOR, <1,1,1>, + PSYS_PART_START_ALPHA, 1.0, + PSYS_PART_END_ALPHA, 1.0, + PSYS_PART_START_SCALE, <0.04, 0.04, 0>, + PSYS_SRC_TEXTURE, TEXTURE_BLANK, + PSYS_SRC_TARGET_KEY, (key)UUID, + PSYS_SRC_MAX_AGE, 0.0, + PSYS_PART_MAX_AGE, 10.0, + PSYS_SRC_BURST_RATE, 0.0, + PSYS_SRC_BURST_PART_COUNT, 10 + ]); +} + +default +{ + state_entry() + { + init(); + scan(); + } + + listen(integer c, string n, key k, string m) { + if (c == masterLightBus+1) { + if (m == "DISCONNECT") { disconnect(); } + else { + key UUID = getUUID(m); + llOwnerSay("UUID: " + (string)UUID); + permission(UUID); + } + } + //04d7d605-a379-408a-ad81-1933a54af844 + if (c == slaveLightBus) { + llOwnerSay(m); + if (m == "accept " + (string)ownerKey) { llOwnerSay("Connection approved."); getPort(""); } + if (llGetSubString(m, 0, 8) == "port-real") { + string portUUID = llGetSubString(m, 10, -1); + llOwnerSay(portUUID); + connect(portUUID); + } + else if (llGetSubString(m, 0, 3) == "port") { + string UUID = llGetSubString(m, -36, -1); + llOwnerSay(UUID); + getPort(UUID); + } + } + } + + sensor(integer d) + { + integer x = 0; + while (x < d) { + avatarList += llDetectedName(x); + keyList += llDetectedKey(x); + x++; + } + selectMenu(avatarList); + } + + no_sensor() + { + list x = []; + selectMenu(x); + } +} diff --git a/Nanite Systems/charger.lsl b/Nanite Systems/charger.lsl index ea29328..6931512 100644 --- a/Nanite Systems/charger.lsl +++ b/Nanite Systems/charger.lsl @@ -138,7 +138,6 @@ default { state_entry() { turnOff("Initializing..."); - llOwnerSay((string)llGetKey()); ownerKey = llGetOwner(); channelLightBus = -1 - (integer)("0x" + llGetSubString( (string) ownerKey, -7, -1) ) + 106; handleLightBus = llListen(channelLightBus, "", NULL_KEY, ""); @@ -153,7 +152,7 @@ default if (m == "probe") { llSay(channelLightBus, "add charger"); } else if (m == "add-confirm") { llSay(channelLightBus, "add-command toggle"); } else if (m == "charge start" || m == "off" ) { turnOff("Charge disabled."); } - //else if (m == "poke " + (string)llGetOwner()) { llDialog(llDetectedKey(0), "The menu will be here soon.", ["OK", "NOT OK"], channelLightBus); } + else if (m == "poke " + (string)llGetOwner()) { llDialog(llGetOwner(), "Charger Menu", ["CABLE"], channelLightBus); } else if (llGetSubString(m,0,9) == "power 0.99") { turnOff("Charge complete!"); } else if (llGetSubString(m,0,8) == "power 0.2") { turnOn("Low power. Charge enabled..."); } else if (m == toggleMessage) { diff --git a/Nanite Systems/sniff.lsl b/Nanite Systems/sniff.lsl index f7ba31a..a29d93f 100644 --- a/Nanite Systems/sniff.lsl +++ b/Nanite Systems/sniff.lsl @@ -5,14 +5,12 @@ integer channelLightBus; integer listenLightBus; vector color; -integer running = FALSE; hoverText(string input) { llSetText(input, color, 1.0); } messageColor(string input) { - //from SitAnywhere Flicker list rgb = llParseString2List(input, [" "], []); color = ; //hoverText("New color: " + (string)color); @@ -22,7 +20,7 @@ messagePersona(string input) { if (input == "") { hoverText("Changing persona..."); } else { - hoverText("Current persona: " + input); + hoverText("New persona: " + input); } } @@ -33,7 +31,8 @@ messagePower(string input) { } messagePoke(string input) { - hoverText("Poked object: " + input); + hoverText("Poke: " + input); + llDialog((key)input, "Charger Menu", ["CABLE ", "CABLEOFF "], channelLightBus); } messageBolts(string input) { @@ -44,21 +43,83 @@ messageBolts(string input) { } } +messageCharge(string input) { + if (input == "start") { + hoverText("Charge: started"); + } else { + hoverText("Charge: ended"); + } +} + +getPort(string port) { + llSay(channelLightBus, "port-connect " + port); +} + +string cablePort; +string cableId; + +connectCable(string input) { + cablePort = llGetSubString(input, 0, llSubStringIndex(input, " ")-1); + //llOwnerSay("Port: " + cablePort); + cableId = llGetSubString(input, llSubStringIndex(input, " ")+1, -1); + //llOwnerSay("key: " + cableId); + particles(cableId); +} + +particles(string uuid) { + llParticleSystem([ + PSYS_PART_FLAGS, 0 + | PSYS_PART_FOLLOW_VELOCITY_MASK + | PSYS_PART_INTERP_COLOR_MASK + | PSYS_PART_TARGET_POS_MASK + | PSYS_PART_RIBBON_MASK, + PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP, + PSYS_PART_START_COLOR, color, + PSYS_PART_END_COLOR, color, + PSYS_PART_START_ALPHA, 1.0, + PSYS_PART_END_ALPHA, 1.0, + PSYS_PART_START_SCALE, <0.04, 0.04, 0>, + PSYS_SRC_TEXTURE, TEXTURE_BLANK, + PSYS_SRC_TARGET_KEY, (key)uuid, + PSYS_SRC_MAX_AGE, 0.0, + PSYS_PART_MAX_AGE, 10.0, + PSYS_SRC_BURST_RATE, 0.0, + PSYS_SRC_BURST_PART_COUNT, 10 + ]); +} + +disconnectCable(string input) { + llParticleSystem([]); + llSay(channelLightBus, "port-disconnect " + cablePort); +} + +messageWeather(string input) { + string weather = llGetSubString(input, 0, llSubStringIndex(input, " ")-1); + integer temp = (integer)llGetSubString(input, llSubStringIndex(input, " ")+1, -1); + hoverText("Weather: " + weather + "\nTemp: " + (string)temp + "C"); +} + processCommand(string input) { - string command = llGetSubString(input, 0, llSubStringIndex(input, " ") - 1); - string params = llGetSubString(input, llSubStringIndex(input, " ") + 1, -1); + string command = llGetSubString(input, 0, llSubStringIndex(input, " ")-1); + string params = llGetSubString(input, llSubStringIndex(input, " ")+1, -1); //hoverText("Heard: " + command); //hoverText("Heard: " + params); if (command == "color") { messageColor(params); } if (command == "power") { messagePower(params); } if (command == "persona") { messagePersona(params); } if (command == "persona-eject") { messagePersona(""); } - //if (command == "poke") { messagePoke(params); } + if (command == "poke") { messagePoke(params); } if (command == "bolts") { messageBolts(params); } + if (command == "charge") { messageCharge(params); } + if (command == "CABLE") { getPort("data-1"); } + if (command == "port-real") { connectCable(params); } + if (command == "CABLEOFF") { disconnectCable(params); } + if (command == "weather") { messageWeather(params); } } default { state_entry() { + llParticleSystem([]); key ownerKey = llGetOwner(); channelLightBus = -1 - (integer)("0x" + llGetSubString( (string) ownerKey, -7, -1) ) + 106; hoverText("Channel: " + (string)channelLightBus);