Jump to content

Elevator Finished!!


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

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

Recommended Posts

My Elevator is finally finished and all the bugs (hopefully) out of the code. I have posted the full code in the library if anyone is interested (HERE). Thanks a million to everyone that helped in my questions while I was working on it. And if you'd like to come by and give it a try please do! You can find my home HERE

  • Like 3
Link to post
Share on other sites

Congratulations!  I know you've worked quite a while to get it done.  If you're at all like me, you'll probably be tinkering with it for the next year or more, but it's very satisfying to get to a point where you can feel proud of having done what you set out to do.  Thanks.

  • Like 2
Link to post
Share on other sites
12 hours ago, Rolig Loon said:

Congratulations!  I know you've worked quite a while to get it done.  If you're at all like me, you'll probably be tinkering with it for the next year or more, but it's very satisfying to get to a point where you can feel proud of having done what you set out to do.  Thanks.

@Rolig Loon

You hit the nail on the head .. whilst on the tube this morning realised there was a better way to deal with the AV tracking, and generally avoid the user clicking to sit on the invisible detector prim. As well will allow me to move the move code into the main as the elevator will no longer need to listen for calls from the detector whilst in-motion.

Link to post
Share on other sites
//light settings
//off
list LGT_P_OFF = [PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 0.0, 0.0];
//full
list LGT_P_FULL = [PRIM_POINT_LIGHT, TRUE, LIGHT_COLOR, 1.0, 3.0, 0.75];
//dim
list LGT_P_DIM = [PRIM_POINT_LIGHT, TRUE, LIGHT_COLOR, 0.25, 2.5, 0.75];
//plus glows & brights
list LGT_GB_ON = [PRIM_FULLBRIGHT, BRIGHT_FACE, TRUE, PRIM_GLOW, IN_GLOW_FACE, IN_GLOW, PRIM_GLOW, OUT_GLOW_FACE, OUT_GLOW];
list LGT_GB_OFF = [PRIM_FULLBRIGHT, BRIGHT_FACE, FALSE, PRIM_GLOW, ALL_SIDES, 0.0];

Why this for example? It creates five lists when only one stride list is needed. And why lists when there is already an LL function i can not figure out.

(action == F_EXIT || action == F_STOOD)

This is double stated. It only needs 'action == blah || blab'  The script is so long for what it does that trying to read it is a headache. It is vastly overstated. You do not need all those channels either. The assigned string variables already test for true or false in the if statements.

Edited by steph Arnott
Link to post
Share on other sites

@steph Arnott

Regarding the lists ... if you'll look to where they are used (below) you'll see that a stride list would make things more complex. These are parameters passed to llSetLinkPrimitiveParamsFast, not clear what LL function you are referring to though. Given I could have just placed this directly in the code, but I set as constants for ease of adjustment, one easy place to go to adjust this type of thing rather than finding them in the code (one is reused as well).


set_doors(string action)
{
.....

        //if we are opening, and night .. set light to full
        if (action == DS_OPEN && sun == NIGHT)
        {
            llSetLinkPrimitiveParamsFast(LIGHT_SRC_LINK, LGT_P_FULL + [PRIM_LINK_TARGET, LIGHT_TUBE_LINK] + LGT_GB_ON);
        }

...
        //if we are closing set ligths
        if (action == DS_CLOSE)
        {
            //defult to off
            list params = LGT_P_OFF + [PRIM_LINK_TARGET, LIGHT_TUBE_LINK] + LGT_GB_OFF;
            //if night and someone is in set to dim
            if (sun == NIGHT && llGetListLength(gPaxList) != 0)
            {
                params = LGT_P_DIM + [PRIM_LINK_TARGET, LIGHT_TUBE_LINK] + LGT_GB_ON;
            }
            llSetLinkPrimitiveParamsFast(LIGHT_SRC_LINK, params);
        }
    }
}
33 minutes ago, steph Arnott said:

It only needs 'action == blah || blab'

I was not aware of that shorthand ... good to know and will use going forward ...

34 minutes ago, steph Arnott said:

You do not need all those channels either. The assigned string variables already test for true or false in the if statements.

In the case here I do tend to agree, this is just a practice I have fallen into from the situation where a same function code could come from different channels and needs to be acted upon differently.

36 minutes ago, steph Arnott said:

The script is so long for what it does that trying to read it is a headache.

Sorry to have caused a headache 😉 , was not my intention. Most of the complexity came from two sources ... first was how I tracked Pax entering/leaving etc ... as posted above am looking at doing that a different way that looks to simplify things. Second is all the code around the malfunctions and results of that. While not necessary for the elevator to work, it was something 'extra' that I wanted to add.

Agree that in many areas I might have simplified the code, but even in the simplest of scripts I try to follow the same guidelines. Back in the day had hammered into me that consistency in form when writing code was paramount as it ensures that code can be maintained and expanded. So I do tend to be a bit verbose I admit.

Link to post
Share on other sites
4 minutes ago, steph Arnott said:

The function you refer to is already a list. You are simply using one list to copy into another list which is odd.

You have me confused on this one still. What 'function' is already a list? These are lists of parameters, which are passed to llSetLinkPrimitiveParamsFast. As I said they could just be in the code but I made a conscious decision to have them in the header so it would be easier to find them to adjust.

1 minute ago, steph Arnott said:

Incedently you used '&&' (and) so am surpprised you did not know '||' (or).

What I did not know was that you could write: var = val1 || val2 .. had not come across that shorthand before.

Link to post
Share on other sites

@steph Arnott

While I accept that everyone can have their opinion, to my understanding this forum is for all of us to help each other when it comes to scripting in SL, by providing constructive feedback and guidance.

Although your initial comment ...

21 hours ago, steph Arnott said:

Read the code. It is over bloated and flawed.

... threw me for a bit of a loop, I was interested in understanding where it was coming from. Although I have been coding for over 20 years, I know I can always learn something new. yet when pressed for feedback, you never said why it was 'flawed' (and in fact does work perfectly in-world). As to the 'over-bloated' comment, you managed to come back with three examples:

(1)

7 hours ago, steph Arnott said:

You do not need all those channels either. The assigned string variables already test for true or false in the if statements.

As I explained . agreed I do not 'need' them, but explained that there is a method to the madness, and I have it ingrained in me to follow guidelines when coding.

(2)

6 hours ago, steph Arnott said:

(action == F_EXIT || action == F_STOOD)

This is double stated. It only needs 'action == blah || blab'

Here at first I thought you were pointing out a short-hand that I did not know exists, but it did seem strange to me. In none of the many languages I have coded in did that kind of conditional statement make sense. In every other language that would be interpreted as 'check if action is equal to blah OR if blab (i.e. is blab TRUE). But LSL being what it is I thought perhaps this was interpreted differently. So I wrote a test script (below) and much to my (non)surprise, what you suggested was completely incorrect:

default
{
    state_entry()
    {

        string sCONST_1 = "a";
        string sCONST_2 = "b";
        string sCONST_3 = "c";

        string check = sCONST_3;

        llSay(0, "Answer should be False in all cases");
        llSay(0, "check == sCONST_1 || sCONST_2");
        if (check == sCONST_1 || sCONST_2)
        {
            llSay(0, "Answer: True");
        }
        else
        {
            llSay(0, "Answer: False");
        }
        llSay(0, "check == (sCONST_1 || sCONST_2)");
        if (check == (sCONST_1 || sCONST_2))
        {
            llSay(0, "Answer: True");
        }
        else
        {
            llSay(0, "Answer: False");
        }
        llSay(0, "check == sCONST_1 || check == sCONST_2");
        if (check == sCONST_1 || check == sCONST_2)
        {
            llSay(0, "Answer: True");
        }
        else
        {
            llSay(0, "Answer: False");
        } 
    }
}

Console Output (LSL Editor)
new: Answer should be False in all cases
new: check == sCONST_1 || sCONST_2
new: Answer: True
new: check == (sCONST_1 || sCONST_2)
new: Answer: True
new: check == sCONST_1 || check == sCONST_2
new: Answer: False

so your comment:

5 hours ago, steph Arnott said:

Incedently you used '&&' (and) so am surpprised you did not know '||' (or).

actually gets turned around .. apparently you do not understand how Logical conditions work.

(2)

The next area was around certain list constants that I had defined:

7 hours ago, steph Arnott said:

Why this for example? It creates five lists when only one stride list is needed. And why lists when there is already an LL function i can not figure out.

to which I pointed out that in the way the lists were used a stride list would have made no sense. To which you followed up with:

5 hours ago, steph Arnott said:

The function you refer to is already a list. You are simply using one list to copy into another list which is odd

... which did not make much sense to me, and though I tried to explain why I was doing it the way I did, you only response was that

5 hours ago, steph Arnott said:

At some point in the future you will get what i mean in regards to the fact that the hard code does not need to be in a seperate list.

.. though without an explanation I highly doubt I will, and if what you are hinting at is along the lines of the previous 'direction' as to the use of OR in conditionals .. well you can imagine I am a bit skeptical. So, my take away from this is that if you feel that ' trying to read it is a headache' and 'it is three times lomger than needed and damned hard to read', perhaps the problem lies somewhere else besides my code.

One final suggestion: The forum does have spell check, and puts a nifty red squiggly line under misspelled words. It only takes a second to correct these (words in RED above directly quoted/copied).

Link to post
Share on other sites

FYI English is my fourth language and i do not have time to be correcting minor spelling errors when the cntents are easy to read and understand. Also '||" is a logical test the same as '&&' so stop wasting my time claiming it is 'completely wrong'. That is basics in code testing.

Link to post
Share on other sites

@steph Arnott

You are right .. my apologies for the snarky comment in regards to the spelling. That was uncalled for.

I will have to insist though ... I do clearly understand the use of the || (OR) operator and how Boolean logic works. I was a professional programmer for 8 years and some of the applications I have written are still being used by major companies.

I did not say that || was not a logical test, what I said was that the conditional statement:

var == blah || blab

does not in C, C++, Java, FORTRAN, COBOL, SQL, PHP, Pascal, Object Pascal, Basic, Object Basic, Visual Basic, VBA, or LSL ... evaluate the same as

var == blah || var == blab

... claiming that is does goes against all the basic rules of Boolean logic. And I presented you with the code to test this above .. if you do not believe me, copy it as is  and run it in world.

Edited by Wandering Soulstar
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 654 days.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...