Jump to content

Call button for elevator...


Tattooshop
 Share

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

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

Recommended Posts

Again a question about the elevator. I'm trying to add a call button from the opposite floor. at the same time, it is possible to start the elevator from the inside. the call buttons work, but it doesn’t start from the inside. why?..

So the elevator must listen to both - the commands sent by the call buttons and the commands sent by itself ... is this possible? o.O

or is it easier to make a separate little script for the internal buttons?..

this script is in both call buttons

// CALL BUTTON

integer iTouched = FALSE;

default
{
    touch_start(integer num)
    {
        if (!iTouched)
        {
            iTouched = TRUE;
            llSay(-1234567, "Call");
            llSleep(3);
            iTouched = FALSE;
        }
    }
}

and this one is in the elevator itself.

integer iTouched = FALSE;
integer toggle;

default
{
    state_entry()
    {
        llListen(-1234567, "", "", ""); // Listen to anybody saying anything on channel -1234567 
    }

    touch_start(integer num)
    {
        integer button = llDetectedLinkNumber(0);
        {

            if (button == 2 || button == 5)
            {
                llSay(-1234567, "Call");
                llSay(0, "Touched.");
            }
        }
    }

    listen(integer channel, string name, key id, string msg)
    {
        if (!iTouched)
        {
            if (msg == "Call") // That is, if the message from the SENDER was "Call"
            {
                toggle = !toggle;

                if (toggle)
                {
                    iTouched = TRUE;
                    llSetKeyframedMotion([ < 0, 0, 1 > , 1], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_FORWARD]);
                    llSleep(3);
                    iTouched = FALSE;
                }

                else
                {
                    iTouched = TRUE;
                    llSetKeyframedMotion([ < 0, 0, -1 > , 1], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_FORWARD]);
                    llSleep(3);
                    iTouched = FALSE;
                }
            }
        }
    }
}

 

Link to comment
Share on other sites

52 minutes ago, Rolig Loon said:

Why does the elevator need to listen to itself at all?  After all, it's already reacting to a touch.  Just go ahead and trigger the movement when someone touches the button.

Hi! Thanks! Well, everything works as it is (I used Call script for linked buttons too). But can a script just listen to its own commands in this format  llSay(...) >>> listen event, or do I need something else like linked message? I just don’t see another reason why it does not listen to itself and I had to use separate script for linked buttons too..

Edited by Tattooshop
Link to comment
Share on other sites

No, a script cannot listen to itself except in the special case of a message sent by llDialog.  You could go that route, of course, and you could also use a link message.  Either would work, but they are both less direct than simply triggering your action with the touch_start event itself.  After all, why bother telling the script that someone has just touched a button when the script already knows that?

There's no need for a script in the call button in the elevator, BTW.  Since it is part of the elevator's linkset and your main script is already grabbing llDetectedLinkNumber(0), it is getting all the information that it needs without having to listen for the button to say something.

  • Thanks 1
Link to comment
Share on other sites

29 minutes ago, Rolig Loon said:

No, a script cannot listen to itself except in the special case of a message sent by llDialog.  

Thank you so much! You have clarified a lot:)
So I need to duplicate what happens in the listen event to the touch event? But will these two toggles work that way if i just copy it?

Link to comment
Share on other sites

9 minutes ago, Tattooshop said:

So I need to duplicate what happens in the listen event to the touch event? But will these two toggles work that way if i just copy it?

Pretty much.  I'm not sure whether this helps, but try thinking more about the logic of what you  are trying to accomplish than about the mechanics of how to do it.  The mechanics will general sort themselves out once you have a clear path in your mind.

  • Thanks 1
Link to comment
Share on other sites

A few notes:

  • The way to detect the end of keyframed motion is with the moving_end event. Check there to see if your elevator is where you want it.
  • Keyframed motion is not precise, and is relative to the starting point. Each time you use this, you will have a small error, about 0.05m or so. This error will accumulate over multiple moves. You have to compute your keyframe motion based on your current position.
  • Doors?

It's a good project to make a proper elevator. There's a demo elevator setup here.

  • Thanks 1
Link to comment
Share on other sites

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