Jump to content

Door script 2


MadsCook
 Share

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

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

Recommended Posts

Hello 

I need a little help, i don't know if what i am thinking actually is possible:

The door must be able to do the following: (access in parentheses)
- Close/Open (everyone )
- Lock (Group only)
    - When door is locked a timer can be set when the door will open again, visible countdown (Group only)

Thanks in advance for any tips

Link to comment
Share on other sites

Hi, don't know if this is possible, can anyone help?

I would like a door that can:
- The door  should have a scedule: open between 8:00 AM and 4:00 PM every day. (Second life time) And closed/locked between 4:00 PM and 8 AM.
- The set group can override the schedule and open and close the door whenever they want.

Link to comment
Share on other sites

No doubt you'll have a whole bunch of people telling you how easy that is very soon.  (Because it is.)

You do realise though (not everyone does), doors can be skipped by various methods, like just sitting on something on the other side.  And you need the door to clearly indicate whether it's open or not, or people are inclined to just assume it's broken, and bypass it.  Or have an LM on the inside.  Or assume that every door is annoying — because most of them are — and just generally not bother with them anyhow.  Personally, I find it's better just to leave the door open, and put up a sign instead.  It'll probably work better.

Also, you can't have a "group only visible countdown".  If it's on the door, it's either visible to everyone, or not.  There is no group only.  That'd require something like a HUD, or spamming group members with messages (not going to be appreciated).   Better would probably be a single message if the door is clicked on out of hours, or something.

If you still want to go with the door idea, might help to also describe how you imagine setting the lock/unlock and timer configuration.

  • Like 1
Link to comment
Share on other sites

Yes, very possible.

Use a timer event to continually check the actual time with something like llWallclock. The llWallclock's wiki page gives an example on how to do this: checking the time every 60 seconds, which is sufficient for something operating across a daily schedule. Once you have the current time, perform some checks to determine if it falls within the 8 am to 4 pm range to be open, otherwise assume it's not and lock it. Since llWallclock returns the time in seconds since midnight, that actually makes the logic to check the time very easy - you just need to remember to work exclusively in seconds (for example: 4:00 am would be 14400 seconds since midnight).

Locking can be accomplished by maintaining a global integer variable and setting the value TRUE or FALSE as appropriate. Then in the part of your code that reacts to user input (I would guess a touch_start event), first check the status of the global variable. If the value indicates the door is unlocked, proceed with the door action, else do nothing.

Group overrides would be similar to the above. Assuming the object will be set to a group and you expect the overriding agents to have that same group active, then you can use llDetectedGroup to verify if they're the same. Then modify your lock checking logic to account for that as well.

[Post redacted for clarity after thread merge]

Edited by Dyna Mole
Merged threads
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

10 hours ago, Bleuhazenfurfle said:

Also, you can't have a "group only visible countdown".  If it's on the door, it's either visible to everyone, or not.

Actually, you could technically make an in-world sign different for different observers using shared media, but it would be a lot of effort for the effect. (and not everyone has shared media on auto)

  • Like 2
Link to comment
Share on other sites

Hi

Thanks for good input. I see i made a mistake in the description of what i want, thanks for pointing it out.

First door:

The door should be in a prison. So that the prisoners can have access to food, the gym and outside area at certain times. So it is used as a role play and not something that everyone who visits the place will use.

So the group (Staff members) must be able to open the door at any time. For all others it will auto open and auto closes to a certain time. I think i need help to the following.

Create a slide door script
Create the open /closed door timer script
Create the bypass for the set group on the door.

 

Second door:

" - When door is locked a timer can be set when the door will open again, visible countdown (Group only)"

The countdown can be visible for everyone. It was a mistake to set group only there. Here it is corrected:

The door must be able to do the following: (access in parentheses)
- Close/Open (everyone )
- Lock (Group only)
    - When door is locked a timer can be set when the door will open again, visible countdown  (everyone)

Edited by MadsCook
Link to comment
Share on other sites

You don't need three separate scripts. A single script could support all needed functionality (and it would be easier to maintain and coordinate).

Sliding the door open/closed can be done many ways. Among the simplest would be to use llSetRegionPos and alternate between a defined open and closed position. This assumes the door object is self contained and not linked to anything. This also effectively snaps the door open/closed and doesn't really do that much of a smooth transition. It is possible to make this work with a door that is linked to other parts, and to make it move more smoothly - but that's a little more advanced and it sounds like you're just starting out. So I think it would be a good idea to start simple first and work your way up to more complex stuff as you learn more. Try getting a simple version working first.

The stuff I said about the schedule in my previous post should still apply: a repeating timer event to grab the value of llGetWallclock and then check if that value is within the desired range for the door to be open or closed.

Regarding overrides, if this is for an RP group and group roles/titles are being used, then you can use llDetectedGroup(0) within the touch_start event to determine if the avatar that clicked the door has the same active group as whatever the door's group is set to. Additionally, you can further check what the avatar's current role tag is via llGetObjectDetails and the OBJECT_GROUP_TAG constant. If the detected group returns TRUE and the avatar's group tag matches a predefined value of your choosing, then you can assume the avatar is a guard and open the door on the spot. Here is a quick demo:

//DEMO. Assumes host object will be set to a group

string allowedRole = ""; //fill in the gaurd's group role title here

default
{
    touch_start(integer total_number)
    {           
        //get the group role/tag of the avatr who just clicked us.
        string currRole = (string)llGetObjectDetails(llDetectedKey(0),[OBJECT_GROUP_TAG]);
        
        if(llDetectedGroup(0) && currRole == allowedRole)
        {
            llOwnerSay("Agent has same active group as the object AND has the allowed role/title");
            //do door overrride stuff here.
        }
        else
        {
            llOwnerSay("access denied");
        }
    }
}

 

As for your second door, the above access demo can also be applied to it: enabling the lock when a person with the correct active group and role click the object. A time can similarly be employed to fire off every 60 seconds to check the current wallclock time and automatically unlock it at a certain time. You can also make use of the same timer to update a some hovertext over the door that could display a decrementing variable of how much time remains before the door auto unlocks.

You've been given a fair amount of starting material to work with, so try reading through the linked wiki pages and examples to see what you can come up with. We can answer questions you have along the way. Try starting with just getting your door to open and close on a click. Then try incorporating a time into it to open/close on a schedule. Then try adding the above access demo into it.

Just to make sure we're all on the same page here: if you're intending to try writing the script(s) yourself, we can offer guidance/suggestions/etc. But we generally don't write entire scripts for people. If you're looking to have someone write the script for you, then you would have better luck posting in the Inworld Employment forum, where you can commission a custom job.

Edited by Fenix Eldritch
  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Fenix Eldritch said:

You don't need three separate scripts. A single script could support all needed functionality (and it would be easier to maintain and coordinate).

Sliding the door open/closed can be done many ways. Among the simplest would be to use llSetRegionPos and alternate between a defined open and closed position. This assumes the door object is self contained and not linked to anything. This also effectively snaps the door open/closed and doesn't really do that much of a smooth transition. It is possible to make this work with a door that is linked to other parts, and to make it move more smoothly - but that's a little more advanced and it sounds like you're just starting out. So I think it would be a good idea to start simple first and work your way up to more complex stuff as you learn more. Try getting a simple version working first.

The stuff I said about the schedule in my previous post should still apply: a repeating timer event to grab the value of llGetWallclock and then check if that value is within the desired range for the door to be open or closed.

Regarding overrides, if this is for an RP group and group roles/titles are being used, then you can use llDetectedGroup(0) within the touch_start event to determine if the avatar that clicked the door has the same active group as whatever the door's group is set to. Additionally, you can further check what the avatar's current role tag is via llGetObjectDetails and the OBJECT_GROUP_TAG constant. If the detected group returns TRUE and the avatar's group tag matches a predefined value of your choosing, then you can assume the avatar is a guard and open the door on the spot. Here is a quick demo:

//DEMO. Assumes host object will be set to a group

string allowedRole = ""; //fill in the gaurd's group role title here

default
{
    touch_start(integer total_number)
    {           
        //get the group role/tag of the avatr who just clicked us.
        string currRole = (string)llGetObjectDetails(llDetectedKey(0),[OBJECT_GROUP_TAG]);
        
        if(llDetectedGroup(0) && currRole == allowedRole)
        {
            llOwnerSay("Agent has same active group as the object AND has the allowed role/title");
            //do door overrride stuff here.
        }
        else
        {
            llOwnerSay("access denied");
        }
    }
}

 

As for your second door, the above access demo can also be applied to it: enabling the lock when a person with the correct active group and role click the object. A time can similarly be employed to fire off every 60 seconds to check the current wallclock time and automatically unlock it at a certain time. You can also make use of the same timer to update a some hovertext over the door that could display a decrementing variable of how much time remains before the door auto unlocks.

You've been given a fair amount of starting material to work with, so try reading through the linked wiki pages and examples to see what you can come up with. We can answer questions you have along the way. Try starting with just getting your door to open and close on a click. Then try incorporating a time into it to open/close on a schedule. Then try adding the above access demo into it.

Just to make sure we're all on the same page here: if you're intending to try writing the script(s) yourself, we can offer guidance/suggestions/etc. But we generally don't write entire scripts for people. If you're looking to have someone write the script for you, then you would have better luck posting in the Inworld Employment forum, where you can commission a custom job.

Thank you i will try to use yours and read thw wiki pages. Is there like a book or a good place to have a course in LSL scripting?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 223 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...