Jump to content
You are about to reply to a thread that has been inactive for 1522 days.

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

Recommended Posts

Posted

Just wondering. I haven't seen any mention of how code in one scrip might reference a function or variable in another script. Is there a straightforward way to do this in lsl?

Thanks,

G

Posted

There are various ways of storing data in a prim.

I agree with Floyd that llMessageLinked() is the preferred way. But if you need a single value or string and want to have another script in the same linkset read that, then you could use llSetObjectDesc() to store a value in the object description.
Another way would be to set a hover text, but set its alpha value to zero. Example, llSetText("This is my text", <1,1,1>, 0). You can then have the other script read the hovertext using llGetLinkPrimitiveParams(LINK_ROOT, [ PRIM_TEXT ])
Some people store data in the media string of an object, shared media properties do allow for this in a way but is not recommended in case LL changes something about how shared media works.

I believe there are a few other methods but I can't remember them off the top of my noggin right now.

Note that although the above IS possible , I would still advice to use llMessageLinked() because that is the most secure, and future proof method around.
 

Posted

And just to clarify, LSL scripts cannot directly (or indirectly) "reference a variable or a function in another script." All you can do is communicate with that other script, and the other script is the only one with access to its own variables/functions. (This distinction might seem minor, but I'm not sure if @GManB is talking about something like class-members of other languages, which LSL simply doesn't have.)

  • Like 2
Posted

It is NOT possible to reference a function or variable in another script.

You can only communicate between scripts by chat or link message or http or email or you change something that another script can poll. 

  • Like 1
Posted
3 hours ago, Wulfie Reanimator said:

And just to clarify, LSL scripts cannot directly (or indirectly) "reference a variable or a function in another script." All you can do is communicate with that other script, and the other script is the only one with access to its own variables/functions. (This distinction might seem minor, but I'm not sure if @GManB is talking about something like class-members of other languages, which LSL simply doesn't have.)

Well, even something like a simple

#include <filename>

would be nice. (The pre-compiler just inserts the named file(s) at the location of the #include). We could at least put all helper, utility, etc. functions in other files. My one script is getting toward 500 lines and a bit awkward to have to scroll around. Multiple files would at least allow us to have multiple tabs/windows at positions in the code which we might want to look at frequently.

Anything like this?

 

G

  • Haha 1
Posted
2 minutes ago, GManB said:

Well, even something like a simple

#include <filename>

would be nice. (The pre-compiler just inserts the named file(s) at the location of the #include). We could at least put all helper, utility, etc. functions in other files. My one script is getting toward 500 lines and a bit awkward to have to scroll around. Multiple files would at least allow us to have multiple tabs/windows at positions in the code which we might want to look at frequently.

Anything like this?

 

G

Yes, Firestorm has an "LSL Preprocessor" built in. It's literally the same as other precompilers.

66b6d85f41.png

Posted (edited)
8 minutes ago, GManB said:

Anything like this?

Yes, Firestorm has it.  Preferences/Firestorm/Build 1, Enable LSL pre-processor.

There's an optimiser that'll remove unused stuff from the include files, as well as a couple of extras like a switch() statement and "lazy lists". All optional.

Just like Wulfie said.

Edited by KT Kingsley
You are about to reply to a thread that has been inactive for 1522 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
×
×
  • Create New...