Jump to content

Referencing Function/Variables in Other Script Files


GManB
 Share

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

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

Recommended Posts

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.
 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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