Jump to content

Learning to Script


Goldenstar Sands
 Share

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

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

Recommended Posts

Hello! I've been on SL for some time and Done a tiny bit of scripting here and there; I'm better at moding then writing code and I wanted to get more into learning code properly for a personal project.

Some of the things I am trying to find resources on are:

Random Number generatiors

Secure communication between objects.

Objects Storing, communicating and displaying data/information.

  • Like 1
Link to comment
Share on other sites

8 minutes ago, Goldenstar Sands said:

Hello! I've been on SL for some time and Done a tiny bit of scripting here and there; I'm better at moding then writing code and I wanted to get more into learning code properly for a personal project.

Some of the things I am trying to find resources on are:

Random Number generatiors

Secure communication between objects.

Objects Storing, communicating and displaying data/information.

Hey Goldenstar, 

   We are friends in world.. if you ever need any help feel free to shoot me a message.

Floyd Sack

  • Like 1
Link to comment
Share on other sites

46 minutes ago, Goldenstar Sands said:

Random Number generatiors

Leveraging built-in functions for "true" randomization (e.g. probably deterministic, but the determinism is handled by SL somewhere in the background) the main options are to use llFrand(), llListRandomize() or llGenerateKey() and convert the key to an integer (which you can do by prepending "0x" to the key before the cast : (integer)("0x"+key); ).

If you want to implement something yourself, https://en.wikipedia.org/wiki/List_of_random_number_generators might be a good starting point. I wouldn't reccomend using one of those methods in a "practical" application, but it might be a good educational exercise.

46 minutes ago, Goldenstar Sands said:

Secure communication between objects.

llRegionSayTo() is sufficient for pretty much all cases, slightly more secure if you "authenticate" based on the creator of the object. a gratuitously secure application might leverage the xtea implementation I posted in the lsl library (object 1 sends an encoded key to object 2 using a secret shared between object 1&2, then object 2 sends back the decoded key. if the decoded key matches the one object 1 encoded, then object 1 can trust object 2 ), or use a private server to broker a http connection between the two objects.

Just using a secret large channel, or generate a channel based on an unguessable algorithm (for example: (integer)("0x"+llGetKey())^sharedSecret ) is enough security for most applications though.

46 minutes ago, Goldenstar Sands said:

Objects Storing information,

LinksetData functions and global variables. If you're not already familiar with lsl's data types: https://wiki.secondlife.com/wiki/Category:LSL_Types

46 minutes ago, Goldenstar Sands said:

Objects communicating information

llSay functions: llSay llRegionSay(to) llShout()

rarely llEmail() (fun fact, every single prim (and mesh) rezzed in SL has its own email address!) or llHTTPRequest() (Somewhat counterintuitively, a request can be used to ~send information, not gust get it back from the requestee )

46 minutes ago, Goldenstar Sands said:

Objects displaying data/information.

This gets interesting, as it often involves the design of the object just as much if not more than how it's scripted. Most of the ways to get information out of an object involve changing the visual appearance of the object in some way, and most of the visual change functionality can be done with a rather bloated function llSetLinkPrimitiveParamsFast() which will let you change the color/texture/physical appearance of an object in numerous ways. llSetText() also a notable way of displaying short and simple text on an object. Other options include using llSay/Shout/Whisper on channel 0, which makes an object "talk" in public chat, or llDialog() which brings up a pop-up box for a specific person. You can also use 'media on a prim' functions to display a simple webpage hosted by a LSL script onto a face of an object.

 

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

The LSL wiki might not be the best place for tutorials, but it's a good reference for what events and functions are available and what they do, and there certainly are examples scattered around categories.

For your specific questions, LSL provides one random number generator: https://wiki.secondlife.com/wiki/LlFrand.

Communication between objects is usually done via various forms of say, for example: https://wiki.secondlife.com/wiki/LlSay or https://wiki.secondlife.com/wiki/LlRegionSay. Within linksets, objects can communicate via linkmessages or linkset data, https://wiki.secondlife.com/wiki/LlMessageLinked and https://wiki.secondlife.com/wiki/Category:LSL_LinksetData.

To secure the communications, you can choose a suitable obscure channel to make drive-by snooping harder and encrypt the messages; the wiki has documentation on the basic string XOR pad functions (usable on base64-encoded strings) https://wiki.secondlife.com/wiki/LlXorBase64 and has other articles and examples for stronger encryption available at https://wiki.secondlife.com/wiki/Category:LSL_Encryption.

For storing data, the linkset data features mentioned above are probably the most spacious and versatile. Data display is a bit limited without getting involved with object-based displays or media on prim but generally forms of say on channel 0 (local chat) or https://wiki.secondlife.com/wiki/LlOwnerSay for owner-only display go pretty far. You can also set hovertext above objects with https://wiki.secondlife.com/wiki/LlSetText

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

9 minutes ago, Frionil Fang said:

The LSL wiki might not be the best place for tutorials, but it's a good reference for what events and functions are available and what they do, and there certainly are examples scattered around categories.

operators and flow control are also (IMO) essential reading. Even if you think you know it, it never hurts to refresh on basics, and LSL has some subtle differences from analogous things in other languages.

  • Like 1
Link to comment
Share on other sites

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