Skip to content

Instantly share code, notes, and snippets.

@DrBluefall
Created September 13, 2023 04:21
Show Gist options
  • Save DrBluefall/3226fa51d5baa39f498f1c5e89be3e27 to your computer and use it in GitHub Desktop.
Save DrBluefall/3226fa51d5baa39f498f1c5e89be3e27 to your computer and use it in GitHub Desktop.
mindchip variants
// This script is for the chip slot in its DISABLED STATE.
// On touch, it enables the MIND subsystem, deregisters itself from the controller,
// detaches itself, and attaches the ENABLED STATE chipslot.
integer channel_lights;
key owner;
string device_name = "mindchip"; // one word, no spaces
default {
state_entry() {
owner = llGetOwner();
channel_lights = -1 - (integer)("0x" + llGetSubString( (string) owner, -7, -1) ) + 106;
llListen(channel_lights, "", "", "");
llRegionSayTo(owner, channel_lights, "add " + device_name); // script reset; request registration
}
changed(integer n) {
if(n & CHANGED_OWNER)
llResetScript();
}
touch_end(integer num_detected) {
llRegionSayTo(owner, channel_lights, "internal " + device_name + " 0 " + (string) owner + " power mind on");
llRegionSayTo(owner, channel_lights, "remove " + device_name);
}
listen(integer c, string n, key id, string m) {
if(llGetOwnerKey(id) == owner) { // only respond to messages from objects owned by the robot
if(m == "probe") { // the controller is looking for devices; request registration
llRegionSayTo(owner, channel_lights, "add " + device_name);
} else if(m == "add-confirm") {
// register succeeded - now we can send other messages
// for creating commands, manipulating the controller, etc.
} else if(m == "add-fail") {
// register failed - a device by this name already exists
// for non-peripheral devices, this can also be produced if the unit doesn't trust you
} else if ("bolts" == llGetSubString(m, 0, 4)) {
if ("on" == llGetSubString(m, 6, 8)) {
llOwnerSay("@detach=n");
} else {
llOwnerSay("@detach=y");
}
} else if (m == "remove-confirm"){
llOwnerSay("@attachover:chipsocket/inserted=force,clear,detachme=force");
}
}
}
on_rez(integer n) {
llRegionSayTo(owner, channel_lights, "add " + device_name); // just attached; request registration
}
}
// This script is for the chip slot in its ENABLED STATE.
// On touch, it disables the MIND subsystem, deregisters itself from the controller,
// detaches itself, and attaches the DISABLED STATE chipslot.
integer channel_lights;
key owner;
string device_name = "mindchip"; // one word, no spaces
default {
state_entry() {
owner = llGetOwner();
channel_lights = -1 - (integer)("0x" + llGetSubString( (string) owner, -7, -1) ) + 106;
llListen(channel_lights, "", "", "");
llRegionSayTo(owner, channel_lights, "add " + device_name); // script reset; request registration
}
changed(integer n) {
if(n & CHANGED_OWNER)
llResetScript();
}
touch_end(integer num_detected) {
llRegionSayTo(owner, channel_lights, "internal " + device_name + " 0 " + (string) owner + " power mind off");
llRegionSayTo(owner, channel_lights, "remove " + device_name);
}
listen(integer c, string n, key id, string m) {
if(llGetOwnerKey(id) == owner) { // only respond to messages from objects owned by the robot
if(m == "probe") { // the controller is looking for devices; request registration
llRegionSayTo(owner, channel_lights, "add " + device_name);
} else if(m == "add-confirm") {
// register succeeded - now we can send other messages
// for creating commands, manipulating the controller, etc.
} else if ("bolts" == llGetSubString(m, 0, 4)) {
if ("on" == llGetSubString(m, 6, 8)) {
llOwnerSay("@detach=n");
} else {
llOwnerSay("@detach=y");
}
} else if (m == "remove-confirm") {
llOwnerSay("@attachover:chipsocket/empty=force,clear,detachme=force");
}
}
}
on_rez(integer n) {
llRegionSayTo(owner, channel_lights, "add " + device_name); // just attached; request registration
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment