Complex scripts and good style

View: New views
16 Messages — Rating Filter:   Alert me  

Complex scripts and good style

by Maxxi Short :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
This is really a question about style and efficiency in scripting. I have an object that needs to respond to lots of events - having notecards dropped on it, parsing strings in chat, being touched, menus, scanning for nearby objects and so on. Is the best way of handling this to have one large script with lots of events and functions in? Some of the parsing functions (extracting dates from text strings and formatting them, for instance) are quite complex, so I have quite a few functions that are 20 or so lines of script each.
 
If I put it all in one script in the root prim, the script will be several hundred lines long. Is this bad practice, or is it better to distribute my scripts among prims in the object (it will be a HUD, so consists of a few linked prims) so that I have lots of different shorter scripts spread over a few prims? For example, when it hears text in chat it could send a linked message to another prim that will do the work of decoding the message and sending the result back to the root prim. Or is it OK to have a large script that does what I want it to in the root prim?
 
Maxxi.
 

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Dale Innis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don't forget you can also do it with multiple scripts in the same prim.

Most of us got into the habit of thinking that scripts must be tiny in
pre-Mono times.  Nowadays, though, I don't think there's any problem
with a script several hundred lines long.  Although I don't have any
that big myself.  As a matter of personal style you may prefer to
break it up, but that's up to you.

On Thu, Oct 15, 2009 at 6:58 AM, Maxxi Short <maxxi@...> wrote:

> This is really a question about style and efficiency in scripting. I have an
> object that needs to respond to lots of events - having notecards dropped on
> it, parsing strings in chat, being touched, menus, scanning for nearby
> objects and so on. Is the best way of handling this to have one large script
> with lots of events and functions in? Some of the parsing functions
> (extracting dates from text strings and formatting them, for instance) are
> quite complex, so I have quite a few functions that are 20 or so lines of
> script each.
>
> If I put it all in one script in the root prim, the script will be several
> hundred lines long. Is this bad practice, or is it better to distribute my
> scripts among prims in the object (it will be a HUD, so consists of a few
> linked prims) so that I have lots of different shorter scripts spread over a
> few prims? For example, when it hears text in chat it could send a linked
> message to another prim that will do the work of decoding the message and
> sending the result back to the root prim. Or is it OK to have a large script
> that does what I want it to in the root prim?
>
> Maxxi.
>
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>
>
_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Eloise Pasteur :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There aren't the tools to absolutely answer this question sadly.

However, every script, and every event has a bit of overhead on the sim, which would suggest that, in general, longer scripts rather than more scripts works just fine and possibly better in the wider sense. I did have the tools for a simple (non-networked) vendor I wrote to see the difference and after the additional llDetectedTouch* functions came along changed from a multi-script to a single script vendor. Each one lost about 8 events and 4 scripts. The savings for a single vendor were just about detectable on the sim, but as soon as I had 70 of them in a shop, it was really pretty noticeable.

I tend to keep my scripts into one larger script where possible in part because of this and in part because I find it easier to debug that way rather than to debug across dozens of scripts that swap things back and forth - the order of the data transfer isn't really under my control and can cause unexpected problems quite easily. If you find you debug small scripts that talk to each other better, then you probably gain more from that than you lose in the case of a HUD.

El.

On 15 Oct 2009, at 11:58, Maxxi Short wrote:

This is really a question about style and efficiency in scripting. I have an object that needs to respond to lots of events - having notecards dropped on it, parsing strings in chat, being touched, menus, scanning for nearby objects and so on. Is the best way of handling this to have one large script with lots of events and functions in? Some of the parsing functions (extracting dates from text strings and formatting them, for instance) are quite complex, so I have quite a few functions that are 20 or so lines of script each.
 
If I put it all in one script in the root prim, the script will be several hundred lines long. Is this bad practice, or is it better to distribute my scripts among prims in the object (it will be a HUD, so consists of a few linked prims) so that I have lots of different shorter scripts spread over a few prims? For example, when it hears text in chat it could send a linked message to another prim that will do the work of decoding the message and sending the result back to the root prim. Or is it OK to have a large script that does what I want it to in the root prim?
 
Maxxi.
 
_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters



_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Ann Otoole :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

I have read of people having collapsed back to the monolithic one script with no functions model to gain speed, efficiency, and reduced memory. Just makes it as easy to read as old PHP scripts rofl.

Given the nature of LSL I am willing to put odds on it is something that must be decided on a case by case basis.

Now some LSL functions want to be in scripts in linked prims to avoid built in delays so perhaps thinking in "containers are prims" mode might be useful. I wonder what others think about that aspect.

From: Maxxi Short <maxxi@...>
To: secondlifescripters@...
Sent: Thu, October 15, 2009 6:58:01 AM
Subject: Complex scripts and good style

This is really a question about style and efficiency in scripting. I have an object that needs to respond to lots of events - having notecards dropped on it, parsing strings in chat, being touched, menus, scanning for nearby objects and so on. Is the best way of handling this to have one large script with lots of events and functions in? Some of the parsing functions (extracting dates from text strings and formatting them, for instance) are quite complex, so I have quite a few functions that are 20 or so lines of script each.
 
If I put it all in one script in the root prim, the script will be several hundred lines long. Is this bad practice, or is it better to distribute my scripts among prims in the object (it will be a HUD, so consists of a few linked prims) so that I have lots of different shorter scripts spread over a few prims? For example, when it hears text in chat it could send a linked message to another prim that will do the work of decoding the message and sending the result back to the root prim. Or is it OK to have a large script that does what I want it to in the root prim?
 
Maxxi.
 


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by jbhancroft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I try to strike the right balance... shorter "utility" scripts that soak up our much-loved SL-applied delays, and
longer scripts to keep the processing model simpler.  "simpler": the scripts aren't really running in parallel,
and with events not being pre-emptive, I want as few errors introduced as possible by race conditions or odd
timing-related errors, *just* because I had to break code into small chunks to avoid memory limitations of SL.

I have one project that required a number of smaller scripts, and 18 scripts each 500-800 lines long... and it
was manageable. With some control logic to start/stop scripts when you need them, you can even manage the lag
impact pretty well.  With some forethought to try and avoid "designing myself into a corner", I don't see why that
can't be extended to whatever is needed.

(The only torturous part of that project was where I absolutely needed to implement some serialization and holdoff
logic, and had to build a semaphore/lock mechanism using llMessageLinked.  ugh.)

- JB

On Thu, Oct 15, 2009 at 8:28 AM, Ann Otoole <missannotoole@...> wrote:

I have read of people having collapsed back to the monolithic one script with no functions model to gain speed, efficiency, and reduced memory. Just makes it as easy to read as old PHP scripts rofl.

Given the nature of LSL I am willing to put odds on it is something that must be decided on a case by case basis.

Now some LSL functions want to be in scripts in linked prims to avoid built in delays so perhaps thinking in "containers are prims" mode might be useful. I wonder what others think about that aspect.

From: Maxxi Short <maxxi@...>
To: secondlifescripters@...
Sent: Thu, October 15, 2009 6:58:01 AM
Subject: Complex scripts and good style

This is really a question about style and efficiency in scripting. I have an object that needs to respond to lots of events - having notecards dropped on it, parsing strings in chat, being touched, menus, scanning for nearby objects and so on. Is the best way of handling this to have one large script with lots of events and functions in? Some of the parsing functions (extracting dates from text strings and formatting them, for instance) are quite complex, so I have quite a few functions that are 20 or so lines of script each.
 
If I put it all in one script in the root prim, the script will be several hundred lines long. Is this bad practice, or is it better to distribute my scripts among prims in the object (it will be a HUD, so consists of a few linked prims) so that I have lots of different shorter scripts spread over a few prims? For example, when it hears text in chat it could send a linked message to another prim that will do the work of decoding the message and sending the result back to the root prim. Or is it OK to have a large script that does what I want it to in the root prim?
 
Maxxi.
 


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters



_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Domchi Underwood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 15, 2009 at 12:58 PM, Maxxi Short <maxxi@...> wrote:
If I put it all in one script in the root prim, the script will be several hundred lines long. Is this bad practice, or is it better to distribute my scripts among prims in the object (it will be a HUD, so consists of a few linked prims) so that I have lots of different shorter scripts spread over a few prims?

My rule of thumb is - it goes in another script if I need two threads, if I don't have enough memory, or if it needs to be in specific prim. I have scripts with more than 1000 lines inside and don't consider it a problem.

Having as little code as possible in events is good for readability - though it's a bit slower, I prefer having huge functions than huge events (if you can keep functions short even better). Also, code must be properly commented (but not overcommented) - it goes without saying.


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Very Keynes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I tend to work on the basis of timing, with separate scripts providing
 either Asynchronous multitasking or storage, where needed. Anything
that has to be sequential, or cannot afford to wait for link-messages
or data-server events go in the core scripts, long-term storage and
outbound communication can go in separate threads, and I often have a
"Watchdog" script that can reset, start and stop the others to try and
keep the whole in synchronisation. Most  of my code Post MONO has
tended to larger single scripts.
_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Glen Canaday :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My AO script is one great big giant 1200-line monster compiled Mono. I
can put in however many stands, sits, etc into it that I'll ever need
(who needs 45 stands? not me, but it's ok to do it) and I still have 20k
of memory left over.

When I need memory I'll usually break things up. Large datasets, etc.,
etc. Both my question and the root Q of this thread are pretty much the
same Q!

--GC

Dale Innis wrote:

> Don't forget you can also do it with multiple scripts in the same prim.
>
> Most of us got into the habit of thinking that scripts must be tiny in
> pre-Mono times.  Nowadays, though, I don't think there's any problem
> with a script several hundred lines long.  Although I don't have any
> that big myself.  As a matter of personal style you may prefer to
> break it up, but that's up to you.
>
> On Thu, Oct 15, 2009 at 6:58 AM, Maxxi Short <maxxi@...> wrote:
>  
>> This is really a question about style and efficiency in scripting. I have an
>> object that needs to respond to lots of events - having notecards dropped on
>> it, parsing strings in chat, being touched, menus, scanning for nearby
>> objects and so on. Is the best way of handling this to have one large script
>> with lots of events and functions in? Some of the parsing functions
>> (extracting dates from text strings and formatting them, for instance) are
>> quite complex, so I have quite a few functions that are 20 or so lines of
>> script each.
>>
>> If I put it all in one script in the root prim, the script will be several
>> hundred lines long. Is this bad practice, or is it better to distribute my
>> scripts among prims in the object (it will be a HUD, so consists of a few
>> linked prims) so that I have lots of different shorter scripts spread over a
>> few prims? For example, when it hears text in chat it could send a linked
>> message to another prim that will do the work of decoding the message and
>> sending the result back to the root prim. Or is it OK to have a large script
>> that does what I want it to in the root prim?
>>
>> Maxxi.
>>
>> _______________________________________________
>> Click here to unsubscribe or manage your list subscription:
>> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>>
>>
>>    
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>
>  

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Parent Message unknown Re: Complex scripts and good style

by Maxxi Short :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Many thanks for the responses, they've been really helpful! I think my main script will be in the region of 500 lines which I thought might be excessive, but Domchi says he has no problems with 1,000 line scripts, so I think it would be more efficient to have everything that logically belongs to the root in a single script.
 
I do comment quite heavily - I assume that "compilation" strips out comments so 500 lines of code and 500 lines of comments would be no different to 500 lines of code? Or am I being naive there?
 
Maxxi.
 

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Eloise Pasteur :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No, the compiled code has no comments, you're not being naive.

And as someone else has commented, if I know I'm going to be storing a lot of stuff, I usually use additional scripts for memory scripts - those limits are still pretty tight for storing data in SL and not everyone wants to direct stuff to an outside server for a variety of reasons.

El.

On 15 Oct 2009, at 17:25, Maxxi Short wrote:

Many thanks for the responses, they've been really helpful! I think my main script will be in the region of 500 lines which I thought might be excessive, but Domchi says he has no problems with 1,000 line scripts, so I think it would be more efficient to have everything that logically belongs to the root in a single script.
 
I do comment quite heavily - I assume that "compilation" strips out comments so 500 lines of code and 500 lines of comments would be no different to 500 lines of code? Or am I being naive there?
 
Maxxi.
 
_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters



_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Maxxi Short :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Many thanks to you Eloise, and to you Very - and yes, good advice about keeping a local off-SL copy of the source!
 
So for a memory script do you mean have one of the prims whose job is basically to receive data - and that's where I can store my lists? So if my main object wants to store long lists of dates and avatars, rather than having global list variables in the main script, have those variables in a script in a separate prim and have the main script send items to that prim telling it to add/remove from the lists via a linked message?
 
Maxxi.
 
----- Original Message -----
Sent: Thursday, October 15, 2009 6:04 PM
Subject: Re: Complex scripts and good style

No, the compiled code has no comments, you're not being naive.

And as someone else has commented, if I know I'm going to be storing a lot of stuff, I usually use additional scripts for memory scripts - those limits are still pretty tight for storing data in SL and not everyone wants to direct stuff to an outside server for a variety of reasons.

El.

On 15 Oct 2009, at 17:25, Maxxi Short wrote:

Many thanks for the responses, they've been really helpful! I think my main script will be in the region of 500 lines which I thought might be excessive, but Domchi says he has no problems with 1,000 line scripts, so I think it would be more efficient to have everything that logically belongs to the root in a single script.
 
I do comment quite heavily - I assume that "compilation" strips out comments so 500 lines of code and 500 lines of comments would be no different to 500 lines of code? Or am I being naive there?
 
Maxxi.
 

 


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Glen Canaday :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You don't have to use separate prims, just separate scripts. Each script
gets x amount (16k in lsl, 64k in mono); it's not per-prim memory.

One day I will actually *use* an outside server. Not sure when... I have
one with mysql, but... meh.

--GC

Maxxi Short wrote:

> Many thanks to you Eloise, and to you Very - and yes, good advice
> about keeping a local off-SL copy of the source!
>  
> So for a memory script do you mean have one of the prims whose job is
> basically to receive data - and that's where I can store my lists? So
> if my main object wants to store long lists of dates and avatars,
> rather than having global list variables in the main script, have
> those variables in a script in a separate prim and have the main
> script send items to that prim telling it to add/remove from the lists
> via a linked message?
>  
> Maxxi.
>  
>
>     ----- Original Message -----
>     *From:* Eloise Pasteur <mailto:eloisepasteur@...>
>     *To:* Maxxi Short <mailto:maxxi@...>
>     *Cc:* secondlifescripters@...
>     <mailto:secondlifescripters@...>
>     *Sent:* Thursday, October 15, 2009 6:04 PM
>     *Subject:* Re: Complex scripts and good style
>
>     No, the compiled code has no comments, you're not being naive.
>
>     And as someone else has commented, if I know I'm going to be
>     storing a lot of stuff, I usually use additional scripts for
>     memory scripts - those limits are still pretty tight for storing
>     data in SL and not everyone wants to direct stuff to an outside
>     server for a variety of reasons.
>
>     El.
>
>     On 15 Oct 2009, at 17:25, Maxxi Short wrote:
>
>>     Many thanks for the responses, they've been really helpful! I
>>     think my main script will be in the region of 500 lines which I
>>     thought might be excessive, but Domchi says he has no problems
>>     with 1,000 line scripts, so I think it would be more efficient to
>>     have everything that logically belongs to the root in a single
>>     script.
>>      
>>     I do comment quite heavily - I assume that "compilation" strips
>>     out comments so 500 lines of code and 500 lines of comments would
>>     be no different to 500 lines of code? Or am I being naive there?
>>      
>>     Maxxi.
>>      
>
>      
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>  

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by ordinal.malaprop :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Honestly, using a remote database for any serious storage is *so much  
better in every way* than having some sort of LSL database solution.  
It's far easier to write, quicker, more powerful, easier on the sim,  
and the data will be regularly backed up. By all means cache  
information locally for speed and in case your remote server goes down  
but honestly, I can't imagine dealing with any serious database stored  
with LSL any more.

Even a system without a mysql server could use, say, sqlite as long as  
it has the required version of PHP.

This is even more important when scripting for use with Opensim, which  
I do increasingly these days, since opensims (insert usual disclaimer  
about how impressive the project is and how great all the developers  
smell) are liable to go down and reset scripts at the drop of a hat.  
Keeping as much as possible stored externally means that all the  
scripts have to do is sync back on reset. This can also be a lot  
easier on the opensim itself.

On 15 Oct 2009, at 22:15, Glen wrote:

> You don't have to use separate prims, just separate scripts. Each  
> script
> gets x amount (16k in lsl, 64k in mono); it's not per-prim memory.
>
> One day I will actually *use* an outside server. Not sure when... I  
> have
> one with mysql, but... meh.
>
> --GC
>
> Maxxi Short wrote:
>> Many thanks to you Eloise, and to you Very - and yes, good advice
>> about keeping a local off-SL copy of the source!
>>
>> So for a memory script do you mean have one of the prims whose job is
>> basically to receive data - and that's where I can store my lists? So
>> if my main object wants to store long lists of dates and avatars,
>> rather than having global list variables in the main script, have
>> those variables in a script in a separate prim and have the main
>> script send items to that prim telling it to add/remove from the  
>> lists
>> via a linked message?
>>
>> Maxxi.
>>
>>
>>    ----- Original Message -----
>>    *From:* Eloise Pasteur <mailto:eloisepasteur@...>
>>    *To:* Maxxi Short <mailto:maxxi@...>
>>    *Cc:* secondlifescripters@...
>>    <mailto:secondlifescripters@...>
>>    *Sent:* Thursday, October 15, 2009 6:04 PM
>>    *Subject:* Re: Complex scripts and good style
>>
>>    No, the compiled code has no comments, you're not being naive.
>>
>>    And as someone else has commented, if I know I'm going to be
>>    storing a lot of stuff, I usually use additional scripts for
>>    memory scripts - those limits are still pretty tight for storing
>>    data in SL and not everyone wants to direct stuff to an outside
>>    server for a variety of reasons.
>>
>>    El.
>>
>>    On 15 Oct 2009, at 17:25, Maxxi Short wrote:
>>
>>>    Many thanks for the responses, they've been really helpful! I
>>>    think my main script will be in the region of 500 lines which I
>>>    thought might be excessive, but Domchi says he has no problems
>>>    with 1,000 line scripts, so I think it would be more efficient to
>>>    have everything that logically belongs to the root in a single
>>>    script.
>>>
>>>    I do comment quite heavily - I assume that "compilation" strips
>>>    out comments so 500 lines of code and 500 lines of comments would
>>>    be no different to 500 lines of code? Or am I being naive there?
>>>
>>>    Maxxi.
>>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Click here to unsubscribe or manage your list subscription:
>> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>>
>
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Parent Message unknown Re: Complex scripts and good style

by Mike Procter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I prefer to think of applications in terms of (hopefully) reusable components. 

Like everyone else I'll use multiple scripts to get around various resource limitations and restrictions in LSL's runtime environment, but I also find it easier to contain certain functionality within separate scripts (menu interface, scanning/data collection, data storage, etc) just to make them easier to plug in to another application. 

I know this can be achieved other ways, but for me this works.  With a fairly well defined messaging protocol, making a new script work with one of these existing functions is usually a matter of pasting in the some global definitions at the top of the script and using a template link message structure.

Mike


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Re: Complex scripts and good style

by Maxxi Short :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, I think that makes sense - thanks! Presumably I communicate between the
scripts by using a link message to the same prim? So if I have my big list
in script B in the prim, and the main work in script A, script A sends a
linked message to THIS_PRIM so that script B can store it?

Maxxi.

----- Original Message -----
From: "Glen" <gcanaday@...>
To: <secondlifescripters@...>
Sent: Thursday, October 15, 2009 10:15 PM
Subject: Re: Complex scripts and good style


> You don't have to use separate prims, just separate scripts. Each script
> gets x amount (16k in lsl, 64k in mono); it's not per-prim memory.
>
> One day I will actually *use* an outside server. Not sure when... I have
> one with mysql, but... meh.
>
> --GC
>
> Maxxi Short wrote:
>> Many thanks to you Eloise, and to you Very - and yes, good advice
>> about keeping a local off-SL copy of the source!
>>
>> So for a memory script do you mean have one of the prims whose job is
>> basically to receive data - and that's where I can store my lists? So
>> if my main object wants to store long lists of dates and avatars,
>> rather than having global list variables in the main script, have
>> those variables in a script in a separate prim and have the main
>> script send items to that prim telling it to add/remove from the lists
>> via a linked message?
>>
>> Maxxi.
>>
>>
>>     ----- Original Message -----
>>     *From:* Eloise Pasteur <mailto:eloisepasteur@...>
>>     *To:* Maxxi Short <mailto:maxxi@...>
>>     *Cc:* secondlifescripters@...
>>     <mailto:secondlifescripters@...>
>>     *Sent:* Thursday, October 15, 2009 6:04 PM
>>     *Subject:* Re: Complex scripts and good style
>>
>>     No, the compiled code has no comments, you're not being naive.
>>
>>     And as someone else has commented, if I know I'm going to be
>>     storing a lot of stuff, I usually use additional scripts for
>>     memory scripts - those limits are still pretty tight for storing
>>     data in SL and not everyone wants to direct stuff to an outside
>>     server for a variety of reasons.
>>
>>     El.
>>
>>     On 15 Oct 2009, at 17:25, Maxxi Short wrote:
>>
>>>     Many thanks for the responses, they've been really helpful! I
>>>     think my main script will be in the region of 500 lines which I
>>>     thought might be excessive, but Domchi says he has no problems
>>>     with 1,000 line scripts, so I think it would be more efficient to
>>>     have everything that logically belongs to the root in a single
>>>     script.
>>>
>>>     I do comment quite heavily - I assume that "compilation" strips
>>>     out comments so 500 lines of code and 500 lines of comments would
>>>     be no different to 500 lines of code? Or am I being naive there?
>>>
>>>     Maxxi.
>>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Click here to unsubscribe or manage your list subscription:
>> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>>
>
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters 

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

Parent Message unknown Re: Complex scripts and good style

by Maxxi Short :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, Kubota - actually "LINK_THIS" is what I was thinking of when I said
"THIS_PRIM". This makes a lot of sense - I'll give that a go!


----- Original Message -----
From: "Kubota Homewood" <sl42@...>
To: "Maxxi Short" <maxxi@...>
Sent: Friday, October 16, 2009 12:18 AM
Subject: Re: Complex scripts and good style


> Yes, you can.  Further, use LINK_THIS to only talk to the current  prim,
> or use the link number of the prim the script is in (but the  same
> object).  If you have a script in a "library" prim you can send  responses
> to the sender (the first parameter in the link_message  event).  The thing
> to keep aware of is that any script in a prim that  has a link_message
> handler will wake up with a link message is sent to  that prim.  Link
> messages do appear to be reasonably efficient, but  also remember there is
> a queue depth of 64 so if you send them faster  than they can be handled
> (perhaps because a script doesn't get run  often enough in a busy sim)
> that you can lose link messages.
>
> I dearly wish we could direct a link message at a specific script.
> Barring that, it would be wonderful to have two sets of mask/value  pairs
> such that
>
> if ((n & mask1) == value 1 || (n & mask2) == value2)
> send link message to script
>
> Why two sets?  One set to limit it to this prim, the other set to  still
> allow global messages.  I would even go for:
>
> if ((n & mask) == value 1 || (n & mask) == value2)
> send link message to script
>
> I already more or less do this inside scripts, but it would be nice  if,
> on a busy sim, the script never even had to be woken up.
>
> Kubota
>

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters