Difference between revisions of "Computer:jaycoonlanguage"
Jump to navigation
Jump to search
Huney Jewell (talk | contribs) (Brush up and add to category index) |
Kireji Haiku (talk | contribs) m (a few readability improvements) |
||
Line 2: | Line 2: | ||
This is a language that is written in LSL. It reads a notecard specified by the user (meant for use with my computer that you can buy here: http://slurl.com/secondlife/Coda/249/46/73) | This is a language that is written in LSL. It reads a notecard specified by the user (meant for use with my computer that you can buy here: http://slurl.com/secondlife/Coda/249/46/73) | ||
<lsl> | <lsl> | ||
// initialised: Starts un initialised | |||
integer open = FALSE; | |||
string notecard; | string notecard; | ||
key | |||
key | key notecardLineQueryID; | ||
key notecardTextQueryID; | |||
integer lines; | integer lines; | ||
string process; | string process; | ||
Line 12: | Line 16: | ||
list ints; | list ints; | ||
list strings; | list strings; | ||
default | default | ||
{ | { | ||
state_entry() | state_entry() | ||
{ | { | ||
llListen( | // PUBLIC_CHANNEL has the integer value 0 | ||
llListen(4,"", | llListen(PUBLIC_CHANNEL, "", NULL_KEY, ""); | ||
llListen(4, "", NULL_KEY, ""); | |||
} | } | ||
listen(integer | |||
listen(integer channel, string name, key id, string message) | |||
{ | { | ||
if(message == "os:load progs") | // init start | ||
if(message == "os:load progs") | |||
llSay(4,"prog:jaycoonlanguage"); | llSay(4, "prog:jaycoonlanguage"); | ||
if(message == "bios:startjaycoonlanguage") | else if(message == "bios:startjaycoonlanguage") | ||
open = TRUE; | open = TRUE; | ||
if(message == "close" && open) | else if(message == "close" && open) | ||
open = FALSE; | open = FALSE; | ||
// init done | |||
if(~llSubStringIndex(message, "notecard:") && open | |||
// set notecard | |||
notecard = llDeleteSubString(message,0,9); | if(~llSubStringIndex(message, "notecard:") && open) | ||
notecard = llDeleteSubString(message, 0, 9); | |||
if(message == "compile" && notecard != "" && open) | if(message == "compile" && notecard != "" && open) | ||
{ | { | ||
// start compiling | |||
notecardLineQueryID = llGetNumberOfnotecardLineQueryIDs(notecard); | |||
process = "lines"; | process = "lines"; | ||
integer contvar = 0; | integer contvar = 0; | ||
while (contvar <= lines) | while (contvar <= lines) | ||
{ | { | ||
notecardTextQueryID = llGetnotecardLineQueryID(notecard,contvar); | |||
if(~llSubStringIndex(line, "print:")) | |||
{ | { | ||
line = llDeleteSubString(line,0,6); | |||
if(~llListFindList(ints,[line])) | |||
if(~llListFindList(ints, [line])) | |||
llSay( | llSay(PUBLIC_CHANNEL, | ||
llList2String(ints,llListFindList(ints, [line]))); | |||
if(~llListFindList(strings,[line])) | |||
if(~llListFindList(strings, [line])) | |||
llSay( | llSay(PUBLIC_CHANNEL, | ||
llList2String(ints,llListFindList(strings, [line]))); | |||
llSay( | |||
llSay(PUBLIC_CHANNEL, line); | |||
} | } | ||
if(~llSubStringIndex(line,"int:")) | if(~llSubStringIndex(line, "int:")) | ||
{ | { | ||
line = llDeleteSubString(line,0,4); | line = llDeleteSubString(line, 0, 4); | ||
ints += (integer)line; | ints += (integer)line; | ||
} | } | ||
if(~llSubStringIndex(line,"string:")) | if(~llSubStringIndex(line, "string:")) | ||
{ | { | ||
line = llDeleteSubString(line,0,4); | line = llDeleteSubString(line, 0, 4); | ||
strings += (string)line; | strings += (string)line; | ||
} | } | ||
++contvar; | |||
} | } | ||
} | } | ||
} | } | ||
dataserver(key | |||
dataserver(key query_id, string data) | |||
{ | { | ||
if( | if(query_id == notecardLineQueryID) | ||
lines = (integer)data; | |||
lines = (integer) | |||
if(query_id == notecardTextQueryID) | |||
if( | line = data; | ||
line = | |||
} | } | ||
} | } |
Revision as of 08:34, 9 October 2012
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This is a language that is written in LSL. It reads a notecard specified by the user (meant for use with my computer that you can buy here: http://slurl.com/secondlife/Coda/249/46/73) <lsl> // initialised: Starts un initialised integer open = FALSE;
string notecard;
key notecardLineQueryID; key notecardTextQueryID;
integer lines; string process; string line; string notcard; list ints; list strings;
default {
state_entry() { // PUBLIC_CHANNEL has the integer value 0 llListen(PUBLIC_CHANNEL, "", NULL_KEY, ""); llListen(4, "", NULL_KEY, ""); }
listen(integer channel, string name, key id, string message) { // init start if(message == "os:load progs") llSay(4, "prog:jaycoonlanguage");
else if(message == "bios:startjaycoonlanguage") open = TRUE;
else if(message == "close" && open) open = FALSE; // init done
// set notecard if(~llSubStringIndex(message, "notecard:") && open) notecard = llDeleteSubString(message, 0, 9);
if(message == "compile" && notecard != "" && open) { // start compiling notecardLineQueryID = llGetNumberOfnotecardLineQueryIDs(notecard); process = "lines"; integer contvar = 0; while (contvar <= lines) { notecardTextQueryID = llGetnotecardLineQueryID(notecard,contvar);
if(~llSubStringIndex(line, "print:")) { line = llDeleteSubString(line,0,6);
if(~llListFindList(ints, [line])) llSay(PUBLIC_CHANNEL, llList2String(ints,llListFindList(ints, [line])));
if(~llListFindList(strings, [line])) llSay(PUBLIC_CHANNEL, llList2String(ints,llListFindList(strings, [line])));
llSay(PUBLIC_CHANNEL, line); } if(~llSubStringIndex(line, "int:")) { line = llDeleteSubString(line, 0, 4); ints += (integer)line; } if(~llSubStringIndex(line, "string:")) { line = llDeleteSubString(line, 0, 4); strings += (string)line; }
++contvar; } } }
dataserver(key query_id, string data) { if(query_id == notecardLineQueryID) lines = (integer)data;
if(query_id == notecardTextQueryID) line = data; }
} </lsl>