Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

LSL script -> C# -> compile

Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-21-2006 14:26
I hate to say this but the only way to do this is to write a full LSL parser.
_____________________
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
Iron Perth
Registered User
Join date: 9 Mar 2005
Posts: 802
10-21-2006 15:48
On that note, I have compiled the grammar files with lex and yacc, however I get quite a few compilation errors when I go to gcc.

Has anyone successfully done this?

Cheers,

Iron.
_____________________
http://ironperth.com - Games for SecondLife and more.
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
Update on the LSLeditor
10-22-2006 13:04
I we have to build a complete LSL parser.... okay! :cool:

At first i had yacc at the back of my mind. Because i have to little experience on yacc, i do the Regex thing.....

Status:

- llHTTPRequest / http_response
- some editor highlight improvements
- a lot of ll list function implementation

Todo:

- a lot :rolleyes:

New snapshot of the editor can be downloaded.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-23-2006 18:24
Just in case you didn't know, you can find a copy (an old copy) of the lex & yacc file on the wiki (LexFile). If you use the one on the wiki, you will need to replace "% %" with "%%".
_____________________
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-23-2006 18:40
Things to do:
Get delete key to work in editor (it does *nothing*).
Get this to compile:
CODE

string hexc="0123456789ABCDEF";//faster

string Float2Hex(float a)
{// Copyright Strife Onizuka, 2006, LGPL, http://www.gnu.org/copyleft/lesser.html
if(a)
{
float b = llFabs(a);//logs don't work on negatives.
string f = "p";
integer c = llFloor(llLog(b) / 0.69314718055994530941723212145818);//floor(log2(b))
if(c > 127) c = 127;//catch fatal rounding error in exponent.
integer d = (integer)((b / (float)("0x1p"+(string)c)) * 0x1000000);//shift up into integer range
while(!(d & 0xf))
{//strip extra zeros off before converting or they break "p"
d = d >> 4;
c+=4;
}
do
f = llGetSubString(hexc,15&d,15&d) + f;
while(d = d >> 4);
if(a < 0)
return "-0x" + f +(string)(c - 24);
return "0x" + f +(string)(c - 24);
}
return "0";//zero would hang the zero stripper.
}
default{state_entry(){llSay(0,Float2Hex(PI));}}
_____________________
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-24-2006 01:26
Btw, you will need to use C++'s "atof" function. Convert.ToDouble lacks HexFloat support.

At some point you might ask "Strife, if you know so well how this should be written, why don't/haven't you written this?" Simple answer. I lack the experience/education. I spent the last three hours trying to get an "atof" function into C# and hit the managed-unmanaged wall. I have yet to manage to successfully scale the managed-unmanaged wall (This is one of the reasons I hate .Net).
_____________________
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
10-25-2006 11:17
"Get this to compile" ...... :eek: gives me enough adrenaline to go on, thanx.

"I spent the last three hours trying to get an "atof" function into C# and hit the managed-unmanaged wall."

Nice!! I got a quick look into some code of the atof..... and cried a while.

I spend a few hours on making just a simple "integer" of my own, so you are doing a great job, compared to mine. Meanwhile found out you can't use a const when compiling on-the-fly. So in my sleep i remembered i really should use "static readonly" on my base class consts.... Also SoapFormatter and BinaryFormatter suck big time. XmlSerializer is a better choice for saving some conf parameters.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-26-2006 02:34
My thought was to just make an assembly that was just atof, and compile it in VC++. One of the features of VC++ is that you can mix managed and unmanaged code; all you have to do is traverse the managed bridge, and the compiler handles the threading. I suspect it would actually be easier to compile a standard simple dll which exported atof, and just pinvoke it in C#.

I have a background in C & C++, so doing greasy programing has become a bit of a skill.

I've been using Reflector with a plug-in to decompile the source, I've found not marking things "static" made everything compile. Unfortunately it also made the code crash. Wish I had a better understanding of classes and what the flags like "static" do.

I think the problem I was having with managed & unmanaged code is related to security with .Net.
_____________________
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
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
10-26-2006 10:17
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.


Did I miss the download link?
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
Float2Hex example
10-27-2006 17:19
Parsing the global stuff has been improved a lot. Also the boolean stuff works. I had not much sleep, last couple of days, but the result on the "Get this to compile"

Done!!

PI?

Say[0]->"0x1921FB8p-23"

:D

Check this for editor and compiler screendumps: http://www.heijden.com/alphons/lsleditor/examples/Float2Hex.htm

Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-28-2006 05:33
I just remembered, you will need a special double->string routine, otherwise it will loose the sign on zero. (LSL supports signed floats, i do not think c# will print the sign on 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
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-28-2006 07:58
You should know, LSL uses floats (System.Single) not doubles (System.Double). A good number of functions I've written aren't designed to handed the added precision (Float2Hex). I don't know if you have considered this, but now is the time; are you going to be 100% LSL compliant?

I suppose you must have a working atof function, but here is one i wrote that will work exactly like the one in LSL uses. Decided it was a good way to brush up on my regex.

CODE

//Public Domain
public double Double(string text)
{
Regex r = new Regex(@"\A[ ]*(?<sign>[+-]?)
(?:
(?:
0x
(?:
(?:
(?<int>[0-9a-f]*)
(?:
(?:\.
(?<frac>[0-9a-f]*)
)
|
)
)
(?:
(?:p
(?<exp>[-+]?[\d]*)
)
|
)
)
)
|
(?<dec>
[\d]*[.]?[\d]*
(?:
(?:
e[+-]?[\d]*
)
|
)
)
)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
Match m = r.Match(text);
Double mantissa = 0.0;
if (r.Match(text).Groups["dec"].Value.Length > 0)
mantissa = Convert.ToDouble(r.Match(text).Groups["dec"].Value);
if (m.Groups["int"].Success)
{
if (m.Groups["int"].Value.Length > 0)
{
// System.Console.WriteLine("i:\t" + m.Groups["int"].Value);
mantissa = Convert.ToInt64(m.Groups["int"].Value, 16);
}
if (m.Groups["frac"].Value.Length > 0)
{
// System.Console.WriteLine("f:\t"+m.Groups["frac"].Value);
mantissa += Convert.ToInt64(m.Groups["frac"].Value, 16) / Math.Pow(16.0, m.Groups["frac"].Value.Length);
}
if (m.Groups["exp"].Value.Length > 0)
{
// System.Console.WriteLine("e:\t" + m.Groups["exp"].Value);
mantissa *= Math.Pow(2.0, Convert.ToInt64(m.Groups["exp"].Value, 10));
}
}
if (m.Groups["sign"].Value == "-")
return -mantissa;
return mantissa;
}
_____________________
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-28-2006 08:28
Things to do:
Typecasting string literals.
Creating null lists.

New code challenge:
CODE

//{TightList
list TightListParse(string a) {
string b = llGetSubString(a,((integer)""),((integer)""));//save memory
return llParseStringKeepNulls(llDeleteSubString(a, ((integer)""),((integer)"")), [a=b],[]);
}

default
{
touch_start(integer a)
{
llOwnerSay(llList2CSV(TightListParse("\a\b\c\d\e\f\g")));
}
}


Next Code Challenge: (and it isn't even the most up to date version)
CODE

// TLML Display Element - Version 0.62 release candidate

list stack;
integer position;

//{

string pop()
{
return llList2String(stack, ++position);
}


string peak()
{
return llList2String(stack, position);
}

//}
//#undef STACK

string url;
string config;
string source_url;
integer config_mask;
float config_scale = 1.0;
string show_command;
string path;
string vecmag_1 = "<1,1,1>";

vector size = <0.05,0.05,0.05>;
vector pos = <0.0,0.0,0.0>;

string floatingtext;
vector floatingtextcolor = <1.0,1.0,1.0>;
float floatingtextalpha = 1.0;
//{

//}
integer status = 0x7F;

//{TightList
list TightListParse(string a) {
string b = llGetSubString(a,((integer)""),((integer)""));//save memory
return llParseStringKeepNulls(llDeleteSubString(a,((integer)""),((integer)"")), [a=b],[]);
}

string TightListDump(list a, string b) {
string c = (string)a;
if(llStringLength(b)==1)
if(llSubStringIndex(c,b) & 0x80000000)
jump end;
integer d = 1 - llStringLength(b += "|\\/?!@#$%^&*()_=:;~{}`[],\n\" qQxXzZ");
while(1+llSubStringIndex(c,llGetSubString(b,d,d)) && d)
++d;
b = llGetSubString(b,d,d);
@end;
c = "";//save memory
return b + llDumpList2String(a, b);
}

list tokens(string a, integer b)
{
list c;
if(b)
c = tokens(llDeleteSubString(a,((integer)""),((integer)"")), b - 1);
return [llGetSubString(a,((integer)""),((integer)""))] + c;
}

list TightListTypeParse(string a) {
list b;
if(llStringLength(a) > 6)
{
string m = llGetSubString(a,((integer)""),6);
integer c = -llGetListLength(b = llDeleteSubList(llParseStringKeepNulls(llDeleteSubString(a,((integer)""),5), [a],tokens(m, 5)),((integer)""),((integer)"")));
integer d;
do
{
list f = [a=llList2String(b,c + 1)]; //TYPE_STRING || TYPE_INVALID (though we don't care about invalid)
if((d = (1 + llSubStringIndex(m, llList2String(b,c)))) == TYPE_INTEGER)
f = [(integer)a];
else if(d == TYPE_FLOAT)
f = [(float)a];
// else if(d == TYPE_STRING)
// already handled
else if(d == TYPE_KEY)
f = [(key)a];
else if(d == TYPE_VECTOR)
f = [(vector)a];
else if(d == TYPE_ROTATION)
f = [(rotation)a];
b = llListReplaceList(b, f, c, c+1);
}while((c+=2) & 0x80000000);
}
return b;
}
//}
//{


//#define DEBUG(a) llOwnerSay((string)(a))


//}
//#define SizeRange(x) (x)
//#define Unescape(x) (x)
//#define SetPrimTypeChained(a,b,c,d,e,f,g,h,i,j,k,l,m) ++position


float SizeRange(float a)
{
if(0.01 > (a = llFabs(a)))
a = 0.01;
if(a > 10.0)
a = 10.0;
return a;
}


string Unescape(string a)
{
string b = a;
integer c = -1;
integer d = ((integer)"");
integer e = ((integer)"");
integer f = ((integer)"");
while(d = llSubStringIndex(b, (b = "") + "\\") + 1)
{
if(2 < (e = llSubStringIndex("uUr\"\\nt", llGetSubString(a,d = 1 + (c+=d),d))))
a = llInsertString(llDeleteSubString(a,c,d), c, llGetSubString(" \"\\\n\t",e, (e - (7 * (e == 6)))));
else if(e == 2)
{
if(d+(e = (integer)("0x"+llGetSubString(a,d+1,d+1)) * 2)+1 >= (f = llStringLength(a)))
e = (f - d - 2) & -2;
if((f = e))//this may look like a mistake, it's not
{
do
b = "%"+llGetSubString(a,d + e,d + e + 1) + b;
while((e-=2) > ((integer)""));
}
a = llInsertString(llDeleteSubString(a,c, c + 2 + f),c, b = llUnescapeURL(b));
c += llStringLength(b) - 1;//add to c so we don't accidentily unescape result
}
else if(e + 1)// \uXXXX or \UXXXXXXXX
{
b = llGetSubString(a, d + 1, d + 4 + e *= 4);
a = llDeleteSubString(a, c, d + 4 + e);
if(((integer)"") < e = (integer)("0x"+b))
{
f = (e >= 0x80) + (e >= 0x800) + (e >= 0x10000) + (e >= 0x200000) + (e >= 0x4000000);
b = "%" + byte2hex((e >> (6 * f)) | ((0x3F80 >> f) * (!!f)));
while(f)
b += "%" + byte2hex((((e >> (6 * --f)) | 0x80) & 0xBF));
a = llInsertString(a, c, llUnescapeURL(b));
}
}
b = llDeleteSubString(a,((integer)""),c);
}
return a;
}

string byte2hex(integer x)
{
string hexc="0123456789ABCDEF";
integer xa = (x & 0xF);
return llGetSubString(hexc, xa = ((x >> 4) & 0xF), xa) + llGetSubString(hexc, xa, xa);
}

hideshow(integer a)
{
list b = [PRIM_SIZE];
if(a)
{
b += < SizeRange(size.x * config_scale),
SizeRange(size.y * config_scale * (1.0 + (0.1547344110854503464203233256351 * !!(status & 0x20)))),
SizeRange(size.z * config_scale)>;

if((status & (0x3)) || !(status & 0x800))//if something changed we refresh
llSetText(floatingtext, floatingtextcolor, floatingtextalpha);
}
else
{
b += <0.05,0.05,0.05>;
llSetText("", ((vector)""), ((float)""));
}
llSetPrimitiveParams([PRIM_POSITION, pos * config_scale * !!a] + b);
status = (status & (0xffffF7FF)) | (0x800 * !!a);
}

integer parse_config(string c)
{
stack = TightListParse(c);
integer mask = (integer)peak();
if(mask & 1)
config_scale = (float)pop();
position+=!!(mask & 2);
if(mask & 4)
pos = (vector)pop() + pos * !!(mask & 32);
if(mask & 16)
path = pop();
return mask;
}

default
{
link_message(integer t_int_1, integer t_int_2, string c, key d)
{
rotation t_rot = ((rotation)"");
position = 3;
if((t_int_2 & -2) == 1010)
{
if(llSubStringIndex(path, llGetSubString(d,0,0)) + 1)
{
if(t_int_2 & 1)
jump in3;
d = llDeleteSubString(d,0,0);
jump in1;
}
}
else if(t_int_2 == 1001)
{
if(d == show_command)
jump in4;
}
else if(t_int_2 == 1000)
jump in2;
jump out1;
@in3;@in4;
{
position = 1;
hideshow((integer)llList2String(stack,0) | ((status & 0x800) && (0x8 & parse_config(c))));
}
jump out2;
@in2;@in1;
{
config_mask = parse_config(config = d);
list config_list = stack;
// config_root_local_rot = (rotation)llList2String(config_list, 1);
// server = llList2String(config_list, 2);
position = -llGetListLength(stack = TightListParse(c));
if((t_int_2 = (llStringLength(c = peak()) | (t_int_1 = !((source_url = llList2String(config_list, ((integer)""))) == source_url)))))
{
url = "";
if(t_int_1)
show_command = "";
if(t_int_2 & 0xFFFFFFFE)
url = c;
llSetObjectDesc(url);
}
integer source = (integer)("0x"+(c = pop()));
integer t_int_3 = ((integer)"");
list t_list_1;
list t_list_2;
vector t_vec = ((vector)"");
integer settings_mask = 0xF; //default all
if(c != (d="-"))
{
if(0x1 & source)
{
if((c = pop()) == "-")
settings_mask = 0x1F0; //keep all
else if(c != "+")
settings_mask = (integer)("0x"+c);
}
else if(c!="+")
settings_mask = ((integer)""); //clear

status = ((status | ((0x3)) | (0x400 * t_int_1)) & (((0xffffFFDF)) | (0x20 * !!(settings_mask & 0x80))));

if(source & 0x2)
if(llStringLength(show_command = pop()) == 1)
show_command = "";

if((t_int_1 = (0xC & source)) == 0x4)
{
t_int_2 = (integer)llList2String(t_list_1 = TightListParse(pop()), ((integer)""));
if(t_int_2 >= ((integer)"") && t_int_2 <= 6)
{//PRIM_TYPE = 9
t_list_2 = [9, t_int_2, (integer)llList2String(t_list_1, 1),(vector)llList2String(t_list_1, 2),
(float)llList2String(t_list_1, 3),(vector)llList2String(t_list_1, 4),
(vector)llList2String(t_list_1, 5)];
if(t_int_2 != 3)//PRIM_TYPE_SPHERE
{
t_list_2 += (vector)llList2String(t_list_1, 6);
if(t_int_2 > 3)//== PRIM_TYPE_TORUS || e == PRIM_TYPE_TUBE || e == PRIM_TYPE_RING)
t_list_2 += [(vector)llList2String(t_list_1, 7),(vector)llList2String(t_list_1, 8),
(float)llList2String(t_list_1, 9), (float)llList2String(t_list_1, 10),
(float)llList2String(t_list_1, 11)];
}
llSetPrimitiveParams((t_list_1 = t_list_2 = []) + t_list_2);
}
}
else if(t_int_1 == 0x8)
{//check defines to see if this function evaporates into TLML-L script.
llMessageLinked(LINK_THIS, 1002, pop(), "");
}
else if(t_int_1 == 0xC || settings_mask & 0x1)
{// [Type][9, 0, 0, <0,1,0>, 0.0, <0,0,0>, <1,1,0>, <0,0,0>]
c = "if__v_i9iiv<0,1,0>fvv<1,1,0>v";
if(t_int_1)
c = pop();
llSetPrimitiveParams(TightListTypeParse((c="")+c));
}

if(source & 0x10)
size = (vector)((c="")+c) + ((vector)vecmag_1 * (float)(c = pop()));
if(source & 0x20)
pos = (vector)pop() + (pos * !!(settings_mask & 0x200));
if(source & 0x40){
t_vec = (vector)llList2String(t_list_1 = TightListParse(pop()), ((integer)""));
pos = 0.5 * (t_vec + (size = (vector)llList2String(t_list_1, 1))) + (pos * !!(settings_mask & 0x200));
size -= t_vec;
}

if(source & 0x80){
t_rot = (rotation)(c = pop());
if(<t_rot.x, t_rot.y, t_rot.z> != (t_vec = (vector)c))
t_rot = llEuler2Rot(t_vec * DEG_TO_RAD);
}else if(!(settings_mask & 0x2))
jump skip7;
//t_rot hasn't been used yet so we don't have to zero it, isn't that wonderful?
llSetLocalRot(t_rot * (rotation)llList2String(config_list, 1));
@skip7;

if(source & 0x100)
floatingtext = Unescape(pop());
else if(settings_mask & 0x4)
floatingtext = "";
else
status = status & (0xffffFFFE);

if(source & 0x200)
{
t_rot = (rotation)(c = pop());
if(<t_rot.x, t_rot.y, t_rot.z> == (floatingtextcolor = (vector)((c="")+c)))
floatingtextalpha = t_rot.s;
}
else if(settings_mask & 0x8)
floatingtextcolor = <1.0,1.0,(floatingtextalpha = 1.0)>;
else
status = status & (0xffffFFFD);

if(source & 0x400)
{
t_list_2 = TightListTypeParse(pop());
status = status | 0x4;
}
else if(!(settings_mask & 0x10) && (status & 0x4))
status = status & (0xffffFFFB);//t_list_2 is clean
else
jump skip8;
llParticleSystem(t_list_2);
@skip8;

if(source & 0x800)
{
llTargetOmega( (vector)llList2String(t_list_1 = TightListParse(pop()), ((integer)"")),
(float)llList2String(t_list_1, 1), (float)llList2String(t_list_1, 2));
status = status | 0x8;
}
else if(!(settings_mask & 0x20) && (status & 0x8))
{
status = status & (0xffffFFF7);
llTargetOmega(((vector)""), ((float)""), ((float)""));
}

if(source & 0x1000)
{
llSetTextureAnim((integer)llList2String(t_list_1 = TightListParse(pop()), ((integer)"")),
(integer)llList2String(t_list_1, 1),(integer)llList2String(t_list_1, 2),
(integer)llList2String(t_list_1, 3),(float)llList2String(t_list_1, 4),
(float) llList2String(t_list_1, 5),(float)llList2String((t_list_1 = []) + t_list_1, 6));
status = status | 0x10;
}
else if(!(settings_mask & 0x40) && (status & 0x10))
{
llSetTextureAnim(((integer)""), ((integer)""), ((integer)""), ((integer)""), ((float)""), ((float)""), ((float)""));
status = status & (0xffffFFEF);
}

if(source & 0x2000)
{
t_int_1 = (integer)llList2String(t_list_1 = TightListParse(pop()), t_int_2 = ((integer)""));
t_list_2 = TightListParse(llList2String(config_list, 2));
if(t_int_1 & 0x10)//XyText_key
{
t_list_2 = llListInsertList(t_list_2, llList2List(TightListParse(llList2String(t_list_1, t_int_2 = 1)) + ["",""],((integer)""),1), 1);
t_list_2 = llDeleteSubList(llDeleteSubList(t_list_2, t_int_3 = (llList2String(t_list_2,1) == ""), t_int_3),
t_int_3 = ((llList2String(t_list_2, -2) != "") - 2), t_int_3);
}
t_list_2 = [c=TightListDump(t_list_2, "*")];
if(!(t_int_1 & 0x18))//XyText_key
t_list_2 = [];
llMessageLinked(LINK_THIS, 3200,
TightListDump((t_list_1 = t_list_2 = [(0x10 * ((t_int_1 & 0x18) != ((integer)""))) | (t_int_1 & 0x3FFF7)]) +
t_list_2 + llList2List(t_list_1, t_int_2 + 1, t_int_2 + 12),"|"), c);
status = status | 0x20;
}
!!(source & 0x40000)+!!(source & 0x20000)+!!(source & 0x10000)+!!(source & 0x8000)+position+=!!(source & 0x4000);
// else if(!(settings_mask & BITPrimKeepXyText))
// status = status | BITStatus_XyText_default;
//
// if(source & BITSetURL)
// {
// llSetPrimURL(pop());
// status = status | BITStatus_SetURL;
// }
// else if(status & BITStatus_SetURL)
// {
// if(settings_mask & BITPrimKeepURL)
// llRefreshPrimURL();
// else
// {
// status = status & BITStatus_SetURL_no;
// llSetPrimURL("");
// }
// }
}
// llOwnerSay((string)llGetFreeMemory());
c = (string)(t_list_2 = t_list_1 = []);
if(!(config_mask & 0x8) || (status & 0x800))
hideshow(!(source & 0x2));
while((1+position) & (settings_mask = 0x80000000))
{
status = (status & ((0xffffFDFF))) | (0x180);
if(0xF == (t_int_1 = (0xF & (source = (integer)("0x"+llList2String(stack = llDeleteSubList((stack = [])+stack, 0, position), ++position))))))
{
t_int_1 = ALL_SIDES;
status = status | 0x200;
}

if(source & 0x10)
{
settings_mask = (integer)("0x"+(c = pop()));
if(c == "+")
settings_mask = 0xFF; //default all
// else if(c == "-")
// settings_mask = 0x0; //keep all
}

position+=!!(source & 0x20);

if((t_int_2 = (source & 0x100)) || (settings_mask & 0x1))
{
if(t_int_2)
c = pop();
if(!t_int_2 || (c == ""))
c = "5748decc-f629-461c-9a36-a35a221fe21f";
t_int_2 = 5000;
if((t_int_2 = (integer)("0x"+llGetSubString(c,((integer)""),6)+"1")))//if it's non zero then its likely a key
llSetTexture(c, t_int_1);
llMessageLinked(LINK_THIS, 5900 - (!t_int_2 * 900), c, c = (string)t_int_1);


}

t_vec = (vector)vecmag_1;
if(source & 0x200)
t_vec = (vector)pop();
else if(!(settings_mask & 0x2))
jump skip5;
llSetColor(t_vec, t_int_1);
@skip5;

t_vec.x = 1.0;
if(source & 0x400)
t_vec.x = (float)pop();
else if(!(settings_mask & 0x4))
jump skip6;
llSetAlpha(t_vec.x, t_int_1);
@skip6;

t_vec = (vector)vecmag_1;
if(source & 0x800)
t_vec = (vector)pop();
else if(!(settings_mask & 0x8))
jump skip1;
llScaleTexture(t_vec.x, t_vec.y, t_int_1);
@skip1;

t_vec = ((vector)"");
if(source & 0x1000)
t_vec = (vector)pop();
else if(!(settings_mask & 0x10))
jump skip2;
llOffsetTexture(t_vec.x, t_vec.y, t_int_1);
@skip2;

t_vec.z = ((float)"");
if(source & 0x2000)
t_vec.z = (float)pop();
else if(!(settings_mask & 0x20))//5 + 5+1+5+1 + 5 + 5
jump skip3;
llRotateTexture(t_vec.z, t_int_1);
@skip3;

// t_list_1 = [];//we don't need this since we haven't used it since the last wipe.
if(source & 0x40)
t_list_1 = [PRIM_FULLBRIGHT, t_int_1, !!(source & 0x80)];

if(source & 0x4000)
t_int_2 = (integer)pop();
else if(settings_mask & 0x40)
t_int_2 = PRIM_SHINY_NONE;
else
status = status & (0xffffFF7F);

//To Save memory we have totaly screwed up the script
//to add more flags, another integer will need to be added to the memory space
if(source & 0x8000)
t_int_3 = (integer)pop();
else if(settings_mask & 0x80)
t_int_3 = PRIM_BUMP_NONE;
else if(!(0x100 & (status = (status & (0xffffFEFF)))))
jump skip4;

if(status | 0x200)
t_int_1 = llGetNumberOfSides();

do
{
t_list_1 += t_list_2 + llGetPrimitiveParams(t_list_2 =
[PRIM_BUMP_SHINY, t_int_1 -= !!(status & 0x200)]);
if(status & 0x80)
t_list_1 = llListReplaceList(t_list_1, [t_int_2], -2, -2);
if(status & 0x100)
t_list_1 = llListReplaceList(t_list_1, [t_int_3], -1, -1);
}
while(t_int_1 && (status & 0x200));
// if(status & BITStatus_ALL_SIDES)
// t_int_1 = ALL_SIDES;

@skip4;
if(t_list_1 != [])
llSetPrimitiveParams((t_list_1 = [])+ t_list_1);
!!(source & 0x80000)+!!(source & 0x40000)+!!(source & 0x20000)+position+=!!(source & 0x10000);
}
stack = [];
}
@out1;@out2;
}
touch_start(integer a)
{
if (url)
llMessageLinked(1, 2000, url, config);
}
}
_____________________
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-28-2006 08:39
These should fix your key problem (lsl keys are just strings pretending to be GUIDs)

CODE

public bool _bool(key a)
{
string data = a;
if(data->Length != 36)
return false;
if(data[8] != '-')
return false;
if(data[13] != '-')
return false;
if(data[18] != '-')
return false;
if(data[23] != '-')
return false;
int count = 0;
try
{
int pos;
for(pos = 0; pos < 8; ++pos)
count += Uri.FromHex(data[pos]);
for(pos = 9; pos < 13; ++pos)
count += Uri.FromHex(data[pos]);
for(pos = 14; pos < 18; ++pos)
count += Uri.FromHex(data[pos]);
for(pos = 19; pos < 23; ++pos)
count += Uri.FromHex(data[pos]);
for(pos = 24; pos < 36; ++pos)
count += Uri.FromHex(data[pos]);
}
catch
{//if FromHex is given a non hex char it throws an exception.
return false;
}
return (count != 0);
}

public class key
{
private String data;
public static readonly key NULL_KEY;
public override String ToString()
{
return data;
}
static key()
{
NULL_KEY = new key("00000000-0000-0000-0000-000000000000");
}
public key()
{
data = "";
}
public key(String set)
{
data = set;
}
public key(key a)
{
data = a.ToString();
}
}
_____________________
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
11-06-2006 11:29
Next incremental challenge.

CODE

integer fui(float a){//union float to integer
if(a){//is it non zero?
integer b = (a < 0) << 31;//the sign, but later this variable is reused to store the shift
if((a = llFabs(a)) < 2.3509887016445750159374730744445e-38)//Denormalized range check & last stirde of normalized range
return b | (integer)(a / 1.4012984643248170709237295832899e-45);//this works because the math overlaps; saves cpu time.
integer c = llFloor(llLog(a) / 0.69314718055994530941723212145818);//extremes will error towards extreme. following yuch corrects it.
return (0x7FFFFF & (integer)(a * (0x1000000 >> b))) | (((c + 126 + (b = ((integer)a - (3 <= (a /= (float)("0x1p"+(string)(c -= (c == 128)))))))) << 23 ) | b);
}//for grins, detect the sign on zero. it's not pretty but it works. the previous requires alot of unwinding to understand it.
return ((string)a == (string)(-0.0)) << 31;
}

float iuf(integer a)
{//union integer to float
return ((float)("0x1p"+(string)((a | !a) - 150))) * ((!!(a = (0xff & (a >> 23))) << 23) | ((a & 0x7fffff))) * (1 | (a >> 31));
}//will crash if the raw exponent == 0xff; reason for crash deviates from float standard; though a crash is warented.

default
{
state_entry()
{
float a = PI;
integer b = fui(a);
llOwnerSay(llList2CSV([a,b,iuf(b)]));
}
}
_____________________
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
11-06-2006 12:35
*sighs*

When you rewrote my float code, you removed functionality that is present in LSL, and added flaws. Also, since it's case insensitive, you don't need a-fA-F you just need a-f or A-F
  1. LSL supports scientific notation. 1.0e1 == 10.0
  2. LSL supports NEGITIVE exponents. 10.0e-1 == 1.0 && 0x2.0p-1 == 1.0
  3. LSL exponent positive operator is optional 1.0e+1 == 10.0 && 0x0.8p+1 == 1.0
  4. Your regex doesn't validate the input, so a malliciously crafted input can *crash* the program (float)"1.0abcdef";
_____________________
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
11-07-2006 15:45
:(

changed it back.

thanx
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
New URL for the lslseditor project
11-14-2006 16:54
Hello all,

Works on the editor slowed down a bit. As of december i should have a lot of time to work on the beast. In meantime, i claimed a nice url for the project:

http://www.lsleditor.org/

have fun.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-24-2006 17:03
Everything is looking good though there are still some issues with conditional operators not returning integers; the thing you are doing to get booleans for conditionals is the right way of doing things.
_____________________
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
Mack Morgridge
Registered User
Join date: 19 Sep 2006
Posts: 1
11-27-2006 20:25
im good with computers and and all plus id like to write scripts but man this is some confusing stuff when ur new to it. guess being young has its disadvantages.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-27-2006 21:11
From: Mack Morgridge
im good with computers and and all plus id like to write scripts but man this is some confusing stuff when ur new to it. guess being young has its disadvantages.

Well being old doesn't make it any easier, believe me! But it does get easier.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Alphons Jano
Dancer
Join date: 27 Sep 2006
Posts: 121
New version update LSL editor
12-26-2006 04:35
I have to wait on (another) Christmas dinner...
In meantime, progged some print functionality into the editor.
Nothing much, really.

Available by the update functionality in the program, or go the project website.

http://www.lsleditor.org/

Merry Christmas and Best Wishes.

-Alphons.
Kiek Shinji
Registered User
Join date: 19 Dec 2006
Posts: 17
12-26-2006 10:42
I love your tool Alphons
I've been coding small tools like this sindce the VB5 days :)

I've only been playing SL for 14 days but I completly fell in love with it, mostly because of this LSL. I like the concept of a statemachine driven language


But i wondered, do you *share* your source? or should I just reflector it? ;)



If you do share source, I could assist you in refactoring this software into an enterprise class editor. Including parsers, intellisense, custom DOM and a dockable interface (think visual studio). This could become the premier coding solution for SL
Just think about it, I am VERRY experienced in .NET :)
Rosie Luna
Registered User
Join date: 10 Aug 2006
Posts: 1
Compiler - great - maybe the odd bug :)
01-03-2007 10:01
Alphons – I'm impressed by your compiler.
I've spent a few days recently switching between SL and my own editor and it is a very slow process. A colleague suggested a search for an editor/compiler which is how we found you.
My only problem is that the second bit of code I tried with your complier causes your program to give an unhandled exception. The code works ok in SL.

The offending line is:
iListening1=llListen(iInChan, sInName, "", "";);
in the state_entry()of default.

It compiles correctly if I move it (but doesn't then necessarily do what I want).
Kalel Venkman
Citizen
Join date: 10 Mar 2006
Posts: 587
A clarification for the readers
01-03-2007 10:26
It has never been stated that we will be allowed or enabled to compile locally and upload C# code. MONO has only been discussed in terms of a back-end replacement for the current interpreter, where existing scripts would be gradually recompiled into C# over time.

The offline editor is a wonderful idea. But to the people reading, it's not going to compile and upload C#. The compiler will be running as a daemon on the LL servers.
1 2 3