Jump to content

RLV capture in MLPV menu


Gayngel
 Share

You are about to reply to a thread that has been inactive for 2679 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

// ~capture Script V1.01
// drop into a ball
//
// constants
integer DEBUG           = FALSE;
 
float TIMER_TIMEOUT     = 60.0;
float TIMER_LOCKED      = 900.0;
integer RANGE_CAPTURE   = 20;
 
integer RELAY_CHANNEL   = -1812221819;
 
// texts
string MSG_NO_SENSOR   = "No avatars in sensor range.";
string MSG_MENU_IN_USE = " is using the menu. Please try again in a while.";
string MSG_CHOOSE_AV   = "Choose avatar:";
string MSG_TIMEOUT     = "Dialog timeout. Please touch again to retry.";
 
// internal use
integer dialog_handle;
integer dialog_channel;
key avatar_victim = NULL_KEY;
integer channel;
 
list sensor_keys;
list sensor_names;
key avatar_menu;
 
// write a log message in DEBUG mode
log(string message)
{
	if (DEBUG) llOwnerSay("MENU: " + message);
}
 
// out a message to the user
out(string message)
{
	llSay(0, message);
}
 
capture(key avatar)
{
	relay(avatar, "@sit:" + (string)llGetKey() + "=force");
}
 
lock(key avatar)
{
	relay(avatar, "@unsit=n");
}
 
release(key avatar)
{
	relay(avatar, "@unsit=y");
	relay(avatar, "!release");
}
 
// write a message to the RLV Relay
relay(key avatar, string message)
{
	if (avatar != NULL_KEY)
	{
		llSay(RELAY_CHANNEL, llGetObjectName() + "," + (string) avatar + "," + message);
		log("RLV: " + llGetObjectName() + "," + (string) avatar + "," + message);
	}
}
 
init()
{
	dialog_channel= -(integer)(llFrand(100000 - 10000) + 10000);
	dialog_handle = llListen(dialog_channel, "", NULL_KEY, "");
	llListenControl(dialog_handle, FALSE);
	avatar_menu = NULL_KEY;
}
 
// default state
default
{
	// on state entry: show dialog
	state_entry()
	{
		init();
	}
 
	on_rez(integer start_param)
	{
		channel = start_param;
		init();
	}
 
	// av touched me
	touch_start(integer total_number)
	{
		key id = llDetectedKey(0);
 
		// check if menu is in use
		if (avatar_menu != NULL_KEY && id != avatar_menu)
		{
			out(llKey2Name(avatar_menu) + MSG_MENU_IN_USE);
			return;
		}
 
		avatar_menu = id;
		llSensor("", NULL_KEY, AGENT, RANGE_CAPTURE, PI);
	}
 
	// no av in sensor range
	no_sensor()
	{
		out(MSG_NO_SENSOR);
	}
 
	// some av in sensor range
	sensor(integer total_number)
	{
		sensor_keys = [];
		sensor_names = [];
		integer i;
		for(i=0; i < total_number; i++)
		{
			key id = llDetectedKey(i);
			string name = llKey2Name(id);
			if (llStringLength(name) > 24)
			{
				name = llGetSubString(name, 0, 23);
			}
			sensor_keys += [id];
			sensor_names += [name];
			log("found: " + name);
		}
 
		// show dialog if list contains names
		if (llGetListLength(sensor_names) > 0)
		{
			llListenControl(dialog_handle, TRUE);
			llSetTimerEvent(TIMER_TIMEOUT);
			llDialog(avatar_menu, MSG_CHOOSE_AV, sensor_names, dialog_channel);
		}
	}
 
	// menu selected
	listen(integer channel, string name, key id, string message)
	{
		llListenControl(dialog_handle, FALSE);
		integer index = llListFindList(sensor_names, [message]);
		if (index != -1)
		{
			key selected = llList2Key(sensor_keys, index);
			log ("capture " + llKey2Name(selected));
			capture(selected);
		}
		avatar_menu = NULL_KEY;
	}
 
	// dialog timeout
	timer()
	{
		if (avatar_menu != NULL_KEY)
		{
			out(MSG_TIMEOUT);
			avatar_menu = NULL_KEY;
			llListenControl(dialog_handle, FALSE);
		}
 
		llSetTimerEvent(0);
	}
 
	changed(integer change) {
		if(change & CHANGED_LINK)
		{
			key id = llAvatarOnSitTarget();
			if (id != NULL_KEY)
			{
				avatar_victim = id;
				lock(avatar_victim);
				log ("sitting: " + llKey2Name(avatar_victim));
				state locked;
			}
		}
	}
}
 
state locked
{
	state_entry()
	{
		llListen(channel, "", NULL_KEY, "DIE");
		llSetTimerEvent(TIMER_LOCKED);
	}
 
	listen(integer channel, string name, key id, string message)
	{
		if (message == "DIE")
		{
			log ("DIE");
			release(avatar_victim);
		}
	}
 
	changed(integer change) {
		if(change & CHANGED_LINK)
		{
			key id = llAvatarOnSitTarget();
			if (id == NULL_KEY)
			{
				log ("unsitting " + llKey2Name(avatar_victim));
				release(avatar_victim);
				avatar_victim = id;
				state default;
			}
		}
	}
 
	timer()
	{
		release(avatar_victim);
	}
}

 

 

The MLPV RLV Capture add-on script above requires dropping into the poseballs. I would like to instead amend the script OR have a new capture by sensor script drafted so there is a capture button in the RLV menu of the object. The script needs the touch event omitted, link message added and some re-arranging. Tried converting the touch_event and the if (llGetListLength(sensor_names) > 0) to link_message but neither atempt worked. Please could assist?

Link message needed in script:

 

 link_message(integer sender, integer num, string str, key id) {
 if (num == 1820 && str == "CATCH")
        {
            llDialog(avatar_menu, MSG_CHOOSE_AV, sensor_names, dialog_channel);
            llListenControl(dialog_handle, TRUE);
            llSetTimerEvent(TIMER_TIMEOUT);
        }
}

 

LINKMsg in .MENUITEMS.RLV:

MENU Capture | ALL
LINKMSG CATCH | 1,-4,1820,CATCH

 

 

 

Link to comment
Share on other sites

You might want to provide a little more detail on exactly what you are hoping to accomplish, sequence-wise.  RLV Relay scripting work is very sequence oriented.

 

I'm guessing you want the main object to scan for active relays in a given radius, provide a dialog of targets, and attempt to RLV force-sit the target on the poseball.

 

If you are attempting to prevent them standing up afterward, the poseball(s) will still need a script to prevent that, but that's pretty simple.  It'll need a message system of some sort to be told to release the captive, or a timer system of some sort as well.

 

For any force-sit, you'll need the keys of the poseball(s), as that has to be passed in as part of the RLV Relay command.

 

Can you clarify exactly what you want to happen here?  Also, are the poseballs rezzed, or linked prims?

 

Link to comment
Share on other sites

Yes I want the object to scan for active relays and force sit a target on a rezzed poseball with catch and release buttons in the object dialog menu.  Capture should prevent standing. Choice of poseballs should be by name, UUID or colour.

 

The above script actually isn't sufficient enough because once the avatar is caught they can't be released or stand unless the animation sequence is stopped.

 

Link to comment
Share on other sites

Okay.  In order:

 

Scan for Active Relays:

    llSensor() to get the avatars in range, save in a list.

    llSay() on RLVRS channel a #Version request to everyone in that list (to their relays, technically)

    llSetTimerEvent() to create a timeout for those who don't have relays.

    Listen() handler listening to the RLVRS channel (or specified channel)  for responses.

    Record relay answers until timer expires.

    Display list of targets as a llDialog() to the one who instigated the scan.

 

Force-Sit:

    Rez poseball in calculated location (since more than one could be active?), save key of new object rezzed.

    Send Relay command to target to force sit on Poseball.

 

Poseball should have a script inside that when link changes occur, executes a prevent stand relay command, requests animation permissions, and in the permissions event, animates the avatar on the sit-target.  Poseball script should also have a llListen() listener set up to allow the main object to send it a command to 'release' a target (stop animation, allow standing, delay, and llUnSit().)

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2679 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...