Jump to content
puneetg30

Using two scripts

Recommended Posts

I want to use the methods from second script by calling them from first script. Is it possible?   How? 

Basically i want to use to use another script for other function. 

Share this post


Link to post
Share on other sites

Link messages is the first thing that comes to mind. You can have one script send a link message to LINK_THIS if you only want scripts in the same prim to receive it. Using the other link message fields to send specific commands, you can send an integer, a message or a uuid, or a combination of them depending on what data you need to send to the other script.

In the second script you'll have a link_message event that will receive all link messages sent to that prim. Using the data sent from the other script you can tell it what it needs to do

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

To clarify, you can't directly call a function from a separate script.

You need to send a message to the script you want to call a function from.
That script must also be listening to some kind of message, and call the function when all the criteria is met.

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites
7 hours ago, Wulfie Reanimator said:

To clarify, you can't directly call a function from a separate script.

You need to send a message to the script you want to call a function from.
That script must also be listening to some kind of message, and call the function when all the criteria is met.

Imagine if you could...inheritance in LSL. That would be so useful if you use the same custom function in multiple scripts

  • Like 1

Share this post


Link to post
Share on other sites

With careful LSL centric optimization you can probably get away with only needing one script for most things.

functions in LSL are allocated memory in 512b chunks, heavy inline results in smaller faster code.

Share this post


Link to post
Share on other sites
Posted (edited)

I've had to do this because I ran out of script space. It's a pain. The calling script has to check to see if the called script is working. You can lose messages, although this is rare, so you have to time out and retry.  Also, getting the scripts started up and synchronized on rez can get complicated. If you send before the receiver has started, you will silently lose a message.

Unless you really need to do this, don't.

Edited by animats

Share this post


Link to post
Share on other sites
6 hours ago, ItHadToComeToThis said:

That would be so useful if you use the same custom function in multiple scripts

Come pretty close with the Firefox Preprocessor ... have you looked into that? Since I discovered it has changed my life 😉

 

  • Thanks 1

Share this post


Link to post
Share on other sites
11 hours ago, Wandering Soulstar said:

Come pretty close with the Firefox Preprocessor ... have you looked into that? Since I discovered it has changed my life 😉

 

Yes I have but I’m more talking about native implementation of it that let’s you import specific functions from another script if you have to use them for each script. For example writing something vaguely like :

sysSecurity(): scriptName.sysSecurity{ }

instead of pasting in each script

sysSecurity(){

    .......

    .......

}

would be even neater if the function you were importing returned an integer and you could write

if(!sysSecurity():scriptName.sysSecurity)return

to determine whether the script had passed the security check

Idk random thoughts

  • Like 2

Share this post


Link to post
Share on other sites

The servers are too resource limited to allow much computation in LSL. Technically, LL could let you run full C# code in addition to LSL. OpenSimulator allows this.The execution engine is Mono, which can run many different languages. But keeping the servers from overloading is hard enough now.

Share this post


Link to post
Share on other sites
8 hours ago, animats said:

The servers are too resource limited to allow much computation in LSL. Technically, LL could let you run full C# code in addition to LSL. OpenSimulator allows this.The execution engine is Mono, which can run many different languages. But keeping the servers from overloading is hard enough now.

Resource limitation is not why they don't allow that. IT was started, it was never finished ..

The only certainty is that there is no certainty that changing the precursor language from LSL to C# would make the slightest difference to how the final script executes. If I had to place bets, I would say the C# base would product slower bulkier bytecode. There are also security concerns, LSL is very well sandboxed.

Opensim is not a reference for anything LL do. Not even close.  If SL popped and we all went to Opensim, it would be dead 5 minutes later as it doesn't scale, and then on fire a day later when the hackery types pwned the entire mess.

  • Like 1

Share this post


Link to post
Share on other sites

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...