Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Fun with On_Rez parematers and locking down communications.

Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
03-26-2006 21:57
Okay. I'm making a scripted turret that works like this:
1. Rez Stand. The stand serves as the master control and scanner for the turret.
2. Set Options. The turret's scanning functions are flexible for where you put it.
3. Give Command To Rez Turret.
- Rezzes Turret With start_param denoting channel
- Turret sets listen to passed channel for null_key
- Stand whispers "set_control_key" to passed channel
- Turret removes current null_key listen and sets a listen specifically to the stand's key.
- Stand and Turret are now reasonably secured from spoofing and don't confuse neighboring turrets
4. Non-Group agent enters scan range. Gets shot up.

Here's the problem.
On Step 3, I need help with the on_rez events and the listen command for this. If anyone has some similar on_rez code laying around, I'd appareciate it. This is pretty much the only real headache I'm having so far.

What I'll Pay For A Solution : L$500 + Full Perms Copy of the Turret :D

Thanks, Burke.
_____________________
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
03-26-2006 22:04
CODE

// Turret Script
key rezzorKey;
default {
on_rez(integer chan) {
if (chan != 0) { // I was rezzed from an object
llListen(chan, "", NULL_KEY, "");
}
}
listen(integer c, string n, key id, string m) {
if (m == "set_control_key") {
rezzorKey = id;
state ready;
}
}
}
state ready {
state_entry() {
llListen(llGetStartParameter(), "", rezzorKey, "");
}
listen(integer c, string n, key id, string m) {
// ...
}
}


When can I expect my L$500? ;)
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
03-27-2006 02:10
You just open sourced his "custom turret" :D
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
03-27-2006 05:40
Nah. The whole setup will either be open sourced or sold for a reasonable amount when the time comes. It's part of my desire for a "Safe-Ish" combat system. I have a modified hit counter that does stuff like count how many times you died, and lets an administrator set things like how long you stay 'dead', if you get back up automatically, etc. It also, and this is handy in fights... shouts when you die.

I'll try the code when I get back online. But it already looks like it'll work. :D
_____________________
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
03-27-2006 06:55
You might like the turret to speak up as well when it's ready for the command.

From another object that did a similar thing, I found that the object_rez event for the stand can happen well before the rezzed object even arrives in world, and certainly before its on_rez runs. That means that if the stand llSay()s a message in the object_rez event, the turret can miss it, because it wasn't listening yet.

So I'd add:

CODE

key rezzorKey;
default {
on_rez(integer chan) {
if (chan != 0) { // I was rezzed from an object
llListen(chan, "", NULL_KEY, "");
llSay(chan, "ready"); // Line added
}
}
listen(integer c, string n, key id, string m) {
if (m == "set_control_key") {
rezzorKey = id;
state ready;
}
}
}
state ready {
state_entry() {
llListen(llGetStartParameter(), "", rezzorKey, "");
}
listen(integer c, string n, key id, string m) {
// ...
}
}


Then the stand can listen for the "ready" message and send the setkey message when it hears it, knowing that the turret is ready and listening.
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
03-27-2006 08:16
makes more sense, yeah.

This is the first time I've tried something like this. My alpha version of the turret worked fine, but I found I wanted more flexibility, if I set them standing back to back or with overlapping feilds of fire they need random channels so they don't get confused. The extra key control is to prevent smartasses (like me) from trying.
_____________________
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
03-28-2006 09:11
Took a little bit, but it worked :D
It now gets the channel and locks to the turret's key :D

I'll pass both of you some funds when I get back in-world.
_____________________