LSL script -> C# -> compile
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
10-01-2006 16:16
Hi there, I'm working on an editor wich highlights lsl scripts. I know there are many editors wich can do the same but this one can also translate the code to a pseudo C# language, and can be compiled. After running the program you can press buttons to trigger events. The idea was to make an offline programming environment, to do some simple testing, before launching the scripts into the real-world. (of second-life) Ik worked just a few evenings on the thing. Its programmed in C# (.NET). All 730+ lsl functions and lsl constants, basic classes for rotation,vector etc. are added in a header. The function bodies are empty, but when time goes by i will make them more or less work (i hope). For example this code: -- default { state_entry() { llSay(0, "Hello, Avatar!"  ; } touch_start(integer total_number) { llSay(0, "Touched."  ; } } -- is compiled to: public class _default : _base { public void state_entry() { llSay(0, "Hello, Avatar!"  ; } public void touch_start(int total_number) { llSay(0, "Touched."  ; } } -- When the program compiles it, it shows 2 buttons. One to trigger state_entry, and the other for touch_start. Its quite quick and dirty, because of lack of time. But if there are more people interested, i will go on, or maybe we can work together on the project. -Alphons.
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
Screen dumps of the program
10-01-2006 16:24
1 - The hello world loaded into the editor 2 - The translated script. (into C#) 3 - After compiling, pressed the first button. 4 - The "About" logo is just for fun, don't sue me for it.
|
|
Yo Brewster
Registered User
Join date: 1 Feb 2006
Posts: 139
|
10-01-2006 17:03
Linden Lab is building Mono into Second Life which will allow everybody to use C# or VB.NET or anything that is compatible with Mono. According to Linden Lab, this will be released fairly soon. Speed increase of scripts will be 50-150 times faster
|
|
Takuan Daikon
choppy choppy!
Join date: 22 Jun 2006
Posts: 305
|
10-01-2006 17:48
Alphons, a truly capable offline scripting environment would be fantastic, though the amount of work involved is almost surely prohibitive. Nevertheless, this sounds like an interesting intellectual excersize if nothing else, and I encourage you to keep with it! From: Yo Brewster Linden Lab is building Mono into Second Life which will allow everybody to use C# or VB.NET or anything that is compatible with Mono. According to Linden Lab, this will be released fairly soon. Speed increase of scripts will be 50-150 times faster Wouldn't that be great? I'll believe it when I see it, though, and not a moment sooner. I sure do hope it comes to be, especially since I've been a .NET developer since the first public beta was released, I'm just not gonna hold my breath. Seeing the Google TechTalk video where they discussed that is the primary reason I became interested in SL, though. I hadn't heard of it before. Funny world.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
10-01-2006 19:58
From: Takuan Daikon Wouldn't that be great? I'll believe it when I see it, though, and not a moment sooner. I sure do hope it comes to be, especially since I've been a .NET developer since the first public beta was released, I'm just not gonna hold my breath. They gave a pretty nice long and detailed presentation of current progress on recent Lang.NET conference. I was quite sceptical myself, but it seems they've gotten over most hurdles and have it pretty much working now.
|
|
Yo Brewster
Registered User
Join date: 1 Feb 2006
Posts: 139
|
10-01-2006 23:39
Yep - as Linden Lab mentioned --- it's all integrated and right now they're dealing with some memory leaks. The demo they gave was pretty impressive. So once this is all live, you can just use Visual Studio to create your apps 
|
|
Thraxis Epsilon
Registered User
Join date: 31 Aug 2005
Posts: 211
|
10-02-2006 00:02
I don't recall them ever stating that the scripting language itself would change. They have been quite specific in stating that this was a backend change. Meaning you will still code in LSL, it will just be converted to mono bytecode instead. So "Just code in Visual Studio" is very much a pipedream.. especially in the initial rollout of the mono backend.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
10-02-2006 04:38
From: Thraxis Epsilon I don't recall them ever stating that the scripting language itself would change. They have been quite specific in stating that this was a backend change. Meaning you will still code in LSL, it will just be converted to mono bytecode instead. So "Just code in Visual Studio" is very much a pipedream.. especially in the initial rollout of the mono backend. The LSL doesn't change, but it seems the new setup will also accept mono bytecode in 'raw' form (as long as it's deemed suitable by the code verifier) which is indeed quite different from what's originally said.
|
|
Ralph Doctorow
Registered User
Join date: 16 Oct 2005
Posts: 560
|
10-02-2006 06:20
From: Yo Brewster Linden Lab is building Mono into Second Life which will allow everybody to use C# or VB.NET or anything that is compatible with Mono. According to Linden Lab, this will be released fairly soon. Speed increase of scripts will be 50-150 times faster I believe this is not correct, there are a lot of things that are SL specific in LSL that are not available in the .NET languages so it is very doubtful that C# or any language except LSL will be usable. OTOH, the MONO environment might make some additions to LSL such as more memory, arrays, etc. reasonable to add (please, please....)
|
|
Zeera Xi
Real Join Date: Mid '05
Join date: 21 Sep 2006
Posts: 54
|
10-02-2006 13:57
The last I remember the Lindens stated that this would be a backend change just as Thraxis mentioned but I read that they *want to* add more abilities in later versions.
|
|
ScriptScavenger Lei
Registered User
Join date: 3 Sep 2006
Posts: 14
|
laziness is the mother of all shortcuts
10-02-2006 19:16
has anyone considered just seting up an auto correct spell checker in thier word processor to recognise the commands and syntax ? call me lazy but cut and paste is a beuatifull thing and with the syntax rules the word processor puts in the horrible ;'s for me granted so far im not writhing anything uber complex and i still have to compile in world but so far so good
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
10-02-2006 19:38
Use lslint for out of world compiling!
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-03-2006 10:36
sounds interesting. especialy event triggering
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
project will continue
10-03-2006 13:40
thanks for the feedback. The backoffice virtual machine of Secondlife is changed from proprietary LLab to MONO. This means, LSL script will be compiled to CLI byte-code. As a result, the programs will run faster, (50 times) than usual. There is NO other .NET integration, as far as i can tell. Thanks for tipping the lslint. So my project will continue. Another feature could be the resulting C# code to be single-step-debugged by VisualStudio, or the excellent, SharpDevelop2.0 environment. The last one is open-source C# IDE (looks exactly the same as the Microsoft IDE by the way) To make something clear, no IDE is needed by my program, its all stand-alone. So it could be an excellent lsl editor / test development environment. Because i'm getting more excited about it, i will keep on working on it. All help is appriciated. I will post some stuff when its past 0.01 beta..... 
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
Post some beta stuff about the editor/compiler
10-08-2006 03:30
I have made a page for downloading the LSL-editor (100kb zip). Don't kill me if things crash and burn, it is a beta. What it should do: - Code highlighting - Code completion - Code info, took the old LSLguide, and used Appendix, i can do better i know - F1 , on a keyword, does show up the LSLWiki page on the keyword - Compile, the hello world example should work on state_entry event - Open/Save and edit lsl script files Prereq: .NET framework installed have fun.
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
Post some beta stuff about the editor/compiler
10-08-2006 03:32
Download link: http://www.heijden.com/alphons/lsleditor/From: Alphons Jano I have made a page for downloading the LSL-editor (100kb zip). Don't kill me if things crash and burn, it is a beta. What it should do: - Code highlighting - Code completion - Code info, took the old LSLguide, and used Appendix, i can do better i know - F1 , on a keyword, does show up the LSLWiki page on the keyword - Compile, the hello world example should work on state_entry event - Open/Save and edit lsl script files Prereq: .NET framework installed have fun.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-09-2006 02:36
I started to play with it and found there are alot of things to be done (this is just so you are aware, i'm not jumping on you). You should take a look at How to optimize code and when not to for some of the inner secrets of LSL. Things todo: - Operators to overload: (bools are evil)
- !=
- ==
- <=
- >=
- <
- >
- %
- modulo (currently allowed for floats, illegal in LSL)
- vector cross product
- + Rotations & Vectors
- - Rotations & Vectors
- *
- Multiply float * vector
- combine rotations
- rotate vector
/- devide float * vector
- combine rotations
- rotate vector
llGetSubString llDeleteSubString llOwnerSay (list_a != list_b) returns bool, should return (llGetListLength(list_a) - llGetListLenght(list_b)) functions list addition (list + anything) (string_a != string_b) returns bool, should return strcmp(string_a, string_b) which is an integer that is either 1, 0, -1 typecasting 0x8xxxxxxx -> 0xFFFFFFFF is treated as uint, which it should be treated as negitive int. jump (convert to C# goto) conditions for non-tests [if("blah" ]- The best way to do conitionals would be to check them against the defaults (and overload them normaly so they cannot return bools). See below
//Pseudo-Code
bool isKey() {//users only access to this is by passing a key as a conditional value array byte value[16]; array byte null[16] = memset(16, 0); if(error == sscanf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8], value[9], value[10], value[11], value[12], value[13], value[14], value[15])) return false; return memcmp(value, null) == 0; }
enum types{INTEGER = 1, FLOAT, STRING, KEY, LIST, VECTOR, ROTATION};
If(command == conditional_jump)//if or while { output += command; if(value_type == INTEGER) ouput += "(0 != " + value + ")"; else if(value_type == FLOAT) ouput += "(0.0 != " + value + ")"; else if(value_type == STRING) ouput += "(\"\" != " + value + ")"; else if(value_type == KEY) ouput += "(" + isKey(value) + ")"; // else if(value_type == LIST)//LSL dies horribly if you try this else if(value_type == VECTOR) output += "(<0,0,0> != " + value +")"; else if(value_type == ROTATION) output += "(<0,0,0,1> != " + value +")"; else throw "I pitty the fool: I cannot handle this type of conditional: " + command; } else if( command == iconditional_jump)//do-while() { output += command; if(value_type == INTEGER) ouput += "(0 == " + value + ")"; else if(value_type == FLOAT) ouput += "(0.0 == " + value + ")"; else if(value_type == STRING) ouput += "(\"\" == " + value + ")"; else if(value_type == KEY) ouput += "(" + !isKey(value) + ")"; // else if(value_type == LIST)//LSL dies horribly if you try this else if(value_type == VECTOR) output += "(<0,0,0> == " + value +")"; else if(value_type == ROTATION) output += "(<0,0,0,1> == " + value +")"; else throw "I pitty the fool: I cannot handle this type of conditional: " + command; }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-09-2006 02:44
Some things that would be cool:
Multi script support with link_messages notecards & dataserver events.
A long time ago i had thought about writing one of these, but never found the time or motivation.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
Update
10-14-2006 10:04
Strife Onizuka, thanx for your input, and got your email. Past week i had so much to do. Project slowed down a bit. Used my time machine to catch up...  There is certainly much to do, but i think the program is already usable. De boolean stuff is realy a pain in the ass. Before i go and work on parsing script, first i want to get the overal structure of the program right. My idea was to make something like this: // header file namespace MyLife { public class _base { // atomic classes public class rotation { } public class vector { } public class key { } public class list { } // all 400+ constant definitions public const int TRUE = 1; public const int FALSE = 0; public const int STATUS_PHYSICS = 1; // all ll function implementation public void llSay(int channel, string text) { this.richTextBox.AppendText("llSay("+channel+@","""+text+@""")"+"\r\n"); } } } // generated global vars into seperate class namespace MyLife { public class _global : _base { // global stuff goes her } } // agregate of base and global class goes into every state namespace MyLife { public class _default : _global { // default state code goes here } }
Status on the downloadable program: I managed to put event arguments into the program, now the "Hello World" compiles and works for state_entry and touch_start event.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-15-2006 22:25
I would recommend having the LSL functions & constants stored in thier own un-compiled file, that way it becomes easy to update them. *downloads latests from website & decompiles* you need spaces after the comma's in the ToString methods for vectors & rotations. Rotations in LSL use 'w' not 's'. If you wanted to cheat with dealing with vectors & rotations you could use the directx9 managed to do it for you. btw, keys are *not* guids. They are strings; but only when it comes to a simple conditional test [if(key)] do they actualy get parsed into GUIDs; otherwise they are just strings. take a look at http://adammarker.org/shill/scite/lsl.apiit has all the lsl functions, and their paramaters (your still missing a few; like llLog & llOwnerSay). Just an fyi, llGiveMoney returns an integer, and it's always zero.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
Update on the editor
10-16-2006 15:10
The lsl constants, functions etc. are in a seperate file, but to keep distribution simple, i compile them into the program (embedded resource). All your remarks are on my todo list.... I have uploaded a new version of the program at http://www.heijden.com/alphons/lsleditor/ Now it can parse some examples having multiple states. - Improvement parsing script, vector,rotation, simple list (one line) - Global vars, wrapped in global class - Checkupdate function in the program - First attempt multiple state (only default state executes) have fun.
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
Multiple states work
10-18-2006 18:07
Update: - multiple states are working todo, the user interface of the compiler shows all events in the total script it must enable/disable, or better, make them visible/invisible depening on the state.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
10-18-2006 21:05
void functions, currently the void tag isn't being added. string string_test(string a) { return a; }
void_func_a(integer a)//return type error { return; }
void_func_b(integer a)//return type error { ; }
default { state_entry() { return; } }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
10-18-2006 21:40
From: Strife Onizuka If you wanted to cheat with dealing with vectors & rotations you could use the directx9 managed to do it for you. If i recall right openGL and directX use different-handed coordinate systems. (meaning transformation matrices are column-major in one and row-major in the other) Unless there's a way to override default directX approach you're likely to get very different results from 'real' LSL this way. o.O
|
|
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
|
(daily) Update on de LSLeditor
10-19-2006 15:28
Parsing script is q.a.d. Therefore only simple scripts are parsed correctly. When the projects emerges i have to redesign it. First goal of the project is to have a sort of framework to Edit LSL scripts, and compile to C#, and be able to "run" it, stand-allone. No graphics nor sound is involved. All build as a small Windows application, using .NET Up til now: Editor: - base framework - simple parsing LSL script - code highlighting - code completion - code indent - F1 on keyword goes LSLWiki Compiler: - translating to C# code - constants impl. - ll-functions impl. - classes for vector,rotation,list,key - global vars - multiple state impl. - multiple event impl. - timer impl. - compiling All messy and buggy, not even alpha release, so use at own risk. But.... It works (sometimes), but a lot of work has to be done.
|