Jump to content

Cage Door Scripting - Touch Detection


agentronin
 Share

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

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

Recommended Posts

33 minutes ago, agentronin said:

Suppose I have a cage with a door. What is the best way for the door script to know whether the door has been touched by an avatar inside the cage, or outside it?

Get the position of the toucher with llDetectedPos(). and get the position of the door with llGetPos(), use the two vectors to determine the relative positions.

Depending on the alignment of the cage door, either or both the X and Y components of the door position are then compared with the corresponding components of the touchier  position.

Example, if the cage door is across the X axis and inside the cage is in the direction of increasing X, then a touchier outside the cage will a;always have an X value less than the cage door, and inside always greater.

  • Like 2
Link to comment
Share on other sites

48 minutes ago, agentronin said:

Suppose I have a cage with a door. What is the best way for the door script to know whether the door has been touched by an avatar inside the cage, or outside it?

key owner_id;

default
{
	state_entry()
	{
		owner_id = llGetOwner();
	}
	touch_start(integer num_detected)
	{
		key avatar_key = llDetectedKey(0);
		string avatar_name = llDetectedName(0);
		if(avatar_key != owner_id)
		{
			llInstantMessage(owner_id, "I was touched by " + avatar_name );
		}
		else
		{

		}
	}
}

 

Edited by steph Arnott
  • Confused 1
Link to comment
Share on other sites

1 hour ago, agentronin said:

Suppose I have a cage with a door. What is the best way for the door script to know whether the door has been touched by an avatar inside the cage, or outside it?

Or this.

key owner_id;
integer a = 3;//or whatever the face is
integer b = 1;

default
{
	state_entry()
	{
		owner_id = llGetOwner();
	}
	touch_start(integer num_detected)
	{
		key avatar_key = llDetectedKey(0);
		string avatar_name = llDetectedName(0);
		integer face = llDetectedTouchFace(0);
		if(avatar_key != owner_id)
		{
			if(face == a)
			{
				llInstantMessage(owner_id, "I was touched by " + avatar_name + " inside" );
			}
			if(face == b)
			{
				llInstantMessage(owner_id, "I was touched by " + avatar_name + " outside" );
			}
		}
		else return;
	}
}

 

  • Like 2
Link to comment
Share on other sites

I need to be absolutely sure. So knowing which of the door's faces was touched alone will not be useful.

The method must be generalized for a cage having an arbitrary global rotation. So if it is to be done with vectors it looks to me like it would have to be done by using a cross product with a vector representing the door's orientation, and a vector representing the direction to the avatar.

A dot product with the llDetectedTouchNormal() output should also do it. Then whether or not the touch was from within the cage would be determined by  both which face was touched, and whether the dot product result is positive or negative.

Edited by agentronin
Link to comment
Share on other sites

I was going to make a similar comment about the possible loopholes for just testing what face was clicked. If you wanted to be sure the avatar was truly in the cage, one approach could be to test if their position was within the bounding box of the cage. One way to find this is by using the function llGetBoundingBox. The wiki page has a few examples you might be able to incorporate. The user defined function isInPrim in particular my be helpful to you.

Edited by Fenix Eldritch
Link to comment
Share on other sites

1 hour ago, Profaitchikenz Haiku said:

Ah Steff, but a cunning person inside the cell cam cam out and touch on the outer face :)

 

You do need to determine the relative positions of toucher and door to be absolutely sure.

It was a concept script. It would only take a few lines to ignore the agents touch on the outside face while they are inside by using their key. You do not need the agents pos. Any how it would tell you if they cammed because it tell you which face was touched.

Edited by steph Arnott
Link to comment
Share on other sites

1 hour ago, agentronin said:

I need to be absolutely sure. So knowing which of the door's faces was touched will not be useful.

You do know it is consentual  RP and not a real cage? A person could simply open second veiwer using another account and swan off doing whatever while you think they are locked in your cage having a jolly good laugh at you. Consentual means  following agreed rules, totally pointless if an agent is not going to. The code i gave is a baseline starter which can be added to with stuff like the outside face ignoring the agent inside with a simple conditional. I gave you what you requested, the rest is upto you.

Edited by steph Arnott
Link to comment
Share on other sites

2 hours ago, steph Arnott said:

You do know it is consentual  RP and not a real cage? A person could simply open second veiwer using another account and swan off doing whatever while you think they are locked in your cage having a jolly good laugh at you. Consentual means you follow rules, totally pointless if the agent is not going to. The code i gave is a baseline starter which can be added to with the outside face ignoring the agent inside with a simple conditional. I gave you what you requested, the rest is upto you.

Too complicated. A simpler way would be for the person to simply TP out of the cage, or find something, or rez something, to sit on outside the cage.

The door could be made lockable with a key that can be taken.

If the avatar has an RLV relay attached the confinement can be made more real by RLV restricting TP, and sit. Logging off and relogging elsewhere can be defeated by using RLV regrab on relog. There is this real fancy script that does all this and more offered here:
https://marketplace.secondlife.com/p/CC-Genesis-Cell-Build-System-Personal/2582395

There are those that want restrictions as real as possible, and they are the ones that use RLV relays. RLV can be cheated by turning it off in the viewer, so ultimately there is not a way to really confine an avatar. Ultimately it is just all roleplay with the restriction means being self imposed, and always revocable.

I cannot use the above script offered in the MP because the need is for a cage script that can be used in an OpenSim gorean grid.

Edited by agentronin
Link to comment
Share on other sites

8 minutes ago, agentronin said:

If the avatar has an RLV relay attached the confinement can be made more real by RLV restricting TP, and sit. Logging off and relogging elsewhere can be defeated by using RLV regrab on relog. There is this real fancy script that does all this and more offered here:
https://marketplace.secondlife.com/p/CC-Genesis-Cell-Build-System-Personal/2582395

There are those that want restrictions as real as possible, and they are the ones that use RLV relays. RLV can be cheated by turning it off in the viewer, so ultimately there is not a way to really confine an avatar. Ultimately it is just all roleplay.

I cannot use the above script offered in the MP because the need is for a cage script that can be used in an OpenSim gorean grid.

Your RLV does not work if the person opens a second viewer using a second account. RLV commands are only active in one account and the agent can revoke perms at any time Any how you was give what you asked. We are not here to write scripts for you. Also this is LSL main not OS cludge code forum.

Edited by steph Arnott
Link to comment
Share on other sites

I added this because code block seperation with touch event never seems to get mentioned. Which is a shame as it is rather usefull.

key owner_id;
integer a = 3;//or whatever the face is
integer b = 1;

default
{
	state_entry()
	{
		owner_id = llGetOwner();
	}
	touch_start(integer num_detected)
	{
		key avatar_key = llDetectedKey(0);
		string avatar_name = llDetectedName(0);
		integer face = llDetectedTouchFace(0);
		if(avatar_key != owner_id)
		{
			if(face == a)
			{
				llInstantMessage(owner_id, "I was touched by " + avatar_name + " inside" );
			}
			if(face == b)
			{
				llInstantMessage(owner_id, "I was touched by " + avatar_name + " outside" );
			}
		}
		else return;
	}
	touch_end(integer total_number)
	{
		if(owner_id)
		{
			llOwnerSay("only for me this code block");
		}
	}
}

 

Edited by steph Arnott
Link to comment
Share on other sites

  • 2 weeks later...
On 3/20/2019 at 12:46 PM, steph Arnott said:

Your RLV does not work if the person opens a second viewer using a second account. RLV commands are only active in one account and the agent can revoke perms at any time Any how you was give what you asked. We are not here to write scripts for you. Also this is LSL main not OS cludge code forum.

I did not ask for, or expect, anyone to write code for me. I started this thread to hear about the best ways to know if a cage door toucher is in the door's cage in general terms. llGetBoundingBox() is what I needed to know.

Also I do not need to hear about ways a cage can be defeated. I know that SL is designed in way that ultimately user can escape anything, so what keeps an avatar confined are the rules of the game. Just as when two people sit down to play a game of chess. A game of chess is possible only because two people have agreed to be subject to the game's rules.

In CARP sims cages are everywhere, and are a very common sight. Anyone entering those sims knows what they are getting involved in. Anyone who turns on RLV in their viewer, and attaches an RLV relay, know, and want, the potential danger.

What I create has to work in both SL and OpenSim.

 

 

Link to comment
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...