Cool VL Viewer forum

View unanswered posts | View active topics It is currently 2024-03-28 08:04:12



Reply to topic  [ 6 posts ] 
Create and save custom functions and code snippet 
Author Message

Joined: 2021-02-21 10:34:43
Posts: 3
Reply with quote
I have approached other third party viewers in the past about this but they always seem cagey about giving us scripters anything new and interesting to work with. So figured that maybe you might be interested in actually implementing this as you seem to like including things in your viewer to enhance the user experience.

At present when scripting in LSL, if you create an interesting snippet of code or regularly use the same snippets of code then you are generally limited to how you store those snippets for future use. For me, they are stored in multiple scripts, separated into categories in my inventory that I have to go searching for each and every time I want to copy and paste a sections of code into my current project. This is not a bad solution by any means but can be a bit cumbersome if you have multiple snippets to retrieve from multiple different scripts. So, my idea is this...

The ability to save code snippets to your own custom function / snippet library that is stored on your computer / cloud server / where ever you desire.

It works like this.

Firstly click the edit menu and set your library location. This could be, for example Cloud Drive / LSL / MathLibrary.

Once the library location has been selected the viewer could set up a simple key pair value file that links the name of the snippet to the snippet code itself. (Maybe...you are more the expert on this than me).

Then to save the snippet you would....
1. Highlight section of code.
2. Right click section of code.
3. Select "Save Function / Snippet" from the menu.
4. Give your snippet a name and click save.
5. This is then stored locally in the library file created earlier. Snippet name would appear in a drop down box at the bottom of the viewer next to the drop down box for built in LSL function.

To load a snippet you would....
1. Place cursor where you want the snippet inserted.
2. Select snippet name from drop down list.
3. Snippet is inserted at cursor position.

Why do I think this is a good idea?.
1. It would help users quickly organise and access their code snippets.
2. The use of "set library location" could allow users to switch between different libraries depending on their needs.
3. It would allow users to access their LSL libraries between SL and Open Sim without the need of copy pasting multiple code snippets from one world to the other.
4. Users could in fact share their library files for other scripters to use maybe leading to quite large useful open source libraries.
5. It would add depth to the notion of scripting purely in the viewer and keep the immersion aspect of being in Second Life.

Yes I am aware that Firestorm has it's include function. But honestly, that seems janky and doesn't feel all that immersive or well thought out.
Yes there are external programs that you can use such as external editors but adding something native to the viewer would simplify the process and give some power back to the built in script editor.

Scripters literally get no love when it comes to viewer development. The focus always seems to be on the shoppers, bloggers and photographers and quite honestly it's getting tiring. I feel like there is so much potential that LL / TPV developers could tap into for the built in script editor and yet no one ever does anything to improve it.

For example, opening multiple scripts in the one window in tabs with a save all option. Thus letting you work on multiple scripts without needing 6 script windows open in front of you. Or outputting llOwnerSay messages to the lower text area (apologies I forget what its called) where it tells you that the script has been saved. Could even enable a "histories" version of the library idea that when enabled saves a copy of the scripts current saved state externally allowing you to revert to earlier versions.

Lastly. Thank you for taking the time reading this :).

Concept image is here : https://pasteboard.co/JPn0dZx.png


2021-02-21 11:02:27
Profile

Joined: 2009-03-17 18:42:51
Posts: 5523
Reply with quote
You already can use #include script assets (*) to fulfill that need of reusing "snippets" of code.

Please, see the built-in sources preprocessor documentation.


( *) Or files. Note that other TPVs implementing a preprocessor cannot deal with script assets (i.e. server-side) #includes, but only with local (i.e. stored on the computer mass memory) #include files... The Cool VL Viewer can do both.


2021-02-21 12:37:53
Profile WWW

Joined: 2021-02-21 10:34:43
Posts: 3
Reply with quote
Henri Beauchamp wrote:
You already can use #include script assets (*) to fulfill that need of reusing "snippets" of code.

Please, see the built-in sources preprocessor documentation.


( *) Or files. Note that other TPVs implementing a preprocessor cannot deal with script assets (i.e. server-side) #includes, but only with local (i.e. stored on the computer mass memory) #include files... The Cool VL Viewer can do both.


To just come back to this after a few years, as I had totally forgotten I asked it. Yes, you have the pre processor, but im not talking about that. Im talking about users being able to completely create their own, easily insertable, function libraries without the need for the pre processor or #include. Even Rider Linden has shown interest in implementing this at some point and says he is eventually going to, though it's sadly not high on his list of priorities.

Would it really be that difficult to code in?

Say you write

myFunction(){
Do a thing
}

to then be able to highlight that entire function, right click, save as function, give it a name and then select it from a drop up box at the bottom of the script. Similar to how LL's function box operates.

And then, when you want to re insert it. You can open the drop up box, scroll to your snippet, click it and it inserts the code where your cursor currently is?

See attached image/file


Attachments:
Screenshot 2023-04-02 at 19.42.13.png
Screenshot 2023-04-02 at 19.42.13.png [ 46.56 KiB | Viewed 3329 times ]
2023-04-02 18:45:53
Profile

Joined: 2009-03-17 18:42:51
Posts: 5523
Reply with quote
This is a very specific "need", that I did not even see implemented in programming editors.

No, sorry, but I do not plan on implementing such a feature.

I might however expand Lua scripting features, at some point, to allow adding Lua-specific context menu entries for UI text editors and input lines, at which point you could likely script such a feature in Lua...


2023-04-02 22:16:47
Profile WWW

Joined: 2021-02-21 10:34:43
Posts: 3
Reply with quote
Henri Beauchamp wrote:
This is a very specific "need", that I did not even see implemented in programming editors.

No, sorry, but I do not plan on implementing such a feature.

I might however expand Lua scripting features, at some point, to allow adding Lua-specific context menu entries for UI text editors and input lines, at which point you could likely script such a feature in Lua...


Yeah, specific, but also I think neat. SL isn't like other coding programs and unless we are using external editors, we only have what we have in world. And, I quite like keeping things "in world". There's too much external world development these days and scripting is one of those last remaining things that you don't NEED to go out of world for.

Yes, if you enhance Lua though that would be neat!


2023-04-02 22:51:10
Profile

Joined: 2009-03-17 18:42:51
Posts: 5523
Reply with quote
chibiusaling wrote:
Yes, if you enhance Lua though that would be neat!
In today's release (v1.30.2.10), you should find all the bits and pieces to implement your own code snippet library feature in Lua... I added custom Lua context menu entries support, so you can define a custom "copy to" and/or "cut to" context menu action(s) for script editors to send your snippet to your Lua automation script, and use a custom "paste from" context menu action to paste in the script editors snippets you'd have previously saved, e.g. using a custom Lua menu with a list of snippets to choose from them...

Oh, and feel free to share and contribute what you will come up with... ;)


2023-04-15 09:54:42
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.