YourPages
YourChanges
You can reach Ezhar via
Google+. But I really don't know why you'd want to.
Useful LSL functions I wrote:
ExampleNumberConversion
String search/replace functions:
// searches 'src' and returns the number of times 'find' occurs in it
integer FindCount(string src, string find) {
return llGetListLength(llParseStringKeepNulls(src, [find], [])) - 1;
}
// returns the index in 'src' where 'find' first occurs
// same as llSubStringIndex but slightly slower
integer Find(string src, string find) {
list split;
split = llParseString2List(src, [find], []);
if (llGetListLength(split) == 1) return -1; else return llStringLength(llList2String(split, 0));
}
// returns list of all positions in 'src' where 'find' occurs
list FindAll(string src, string find) {
list split;
list ret;
integer i;
integer pos;
integer len;
integer findlen = llStringLength(find);
split = llParseStringKeepNulls(src, [find], []);
len = llGetListLength(split) - 1;
for (i = 0; i < len; i++) {
pos += llStringLength(llList2String(split, i));
ret += [pos];
pos += findlen;
}
return ret;
}
// search 'src' and replace all occurences of 'find' with 'replace'
string ReplaceString(string src, string find, string replace) {
return llDumpList2String(llParseStringKeepNulls(src, [find], []), replace);
}
default {
state_entry() {
string s = "xblablafoobarfoo";
string search = "bla";
llResetTime();
llSay(0, "occurs " + (string)FindCount(s, search) + " times.");
llSay(0, "1st position (Find): " + (string)Find(s, search));
llSay(0, "all positions (FindAll): " + llList2CSV(FindAll(s, search)));
llSay(0, ReplaceString(s, search, "monkey"));
llSay(0, (string)llGetTime());
}
}
Transporting lists safely through chat/linkmessages:
string SEPARATOR = "|%&|"; // for transmitting lists via linked messages
string List2TypeSep(list input) { // converts a list to a separated string with type information prepended to each item
integer i;
list output;
for (i = 0; i < llGetListLength(input); i++) {
output += [llGetListEntryType(input, i)] + llList2List(input, i, i);
}
return llDumpList2String(output, SEPARATOR);
}
list TypeSep2List(string inputstring) { // converts a separated string created with List2TypeSep back to a list with the correct type information
integer i;
list input;
list output;
input = llParseString2List(inputstring, [SEPARATOR], []);
for (i = 0; i < llGetListLength(input); i += 2) {
if (llList2Integer(input, i) == TYPE_INTEGER) output += (integer)llList2String(input, i + 1);
else if (llList2Integer(input, i) == TYPE_FLOAT) output += (float)llList2String(input, i + 1);
else if (llList2Integer(input, i) == TYPE_STRING) output += llList2String(input, i + 1);
else if (llList2Integer(input, i) == TYPE_KEY) output += (key)llList2String(input, i + 1);
else if (llList2Integer(input, i) == TYPE_VECTOR) output += (vector)llList2String(input, i + 1);
else if (llList2Integer(input, i) == TYPE_ROTATION) output += (rotation)llList2String(input, i + 1);
}
return output;
}
Boolean input/output:
string Bool2String(integer bool) { // returns TRUE or FALSE as string
if (bool) return("TRUE"); else return("FALSE");
}
integer String2Bool(string str) { // returns TRUE or FALSE based on string
list positive = ["y", "yes", "t", "true", "on", "1"];
if (llListFindList(positive, [llToLower(str)]) == -1) return FALSE; else return TRUE;
}
Recognize a UUID:
Various output formatting functions:
// return <number> as string with zero-padding on the left so it's <length> characters
string PadLeft(integer number, integer length) {
return llDeleteSubString("0000000000", length, llStringLength((string)number) - 1) + (string)number;
}
// return the input <number> as string with <point> decimals
string float2stringcut(float number, integer point) {
return llGetSubString((string)number, 0, llSubStringIndex((string)number, ".") + point);
}
I also did some unpublished hacking on this
WakkaWiki and wrote a LSL syntax highlighter for it. Here it is:
<?php
// Syntax Highlight LSL Code
//
// written by Ezhar Fairlight <efairlight@gmail.com>
//
// 2005/04/04 updated wordlist for SL 1.6
// preg callback function
if (!function_exists("lslCallback")) {
function lslCallback($matches) {
// colors for syntax highlighting
$colors['keyword'] = "#0000FF";
$colors['type'] = "#007700";
$colors['event'] = "#00A0A0";
$colors['constant'] = "#0000A0";
$colors['function'] = "#A00000";
$colors['comment'] = "#FF7700";
$colors['string'] = "#00A000";
$colors['vecrot'] = "#FF00FF"; // pink is only tolerable because it's just single characters
$colors['list'] = "#FF0000";
// define the magic words for syntax highlighting
$words['keywords'] = array(
'default',
'state',
'for',
'do',
'while',
'if',
'else',
'jump',
'return',
);
$words['types'] = array(
'integer',
'float',
'string',
'key',
'vector',
'rotation',
'list'
);
$words['events'] = array(
'state_entry',
'state_exit',
'touch_start',
'touch_end',
'touch',
'collision_start',
'collision_end',
'collision',
'land_collision_start',
'land_collision_end',
'land_collision',
'timer',
'listen',
'no_sensor',
'sensor',
'control',
'not_at_target',
'at_target',
'not_at_rot_target',
'at_rot_target',
'money',
'email',
'run_time_permissions',
'attach',
'dataserver',
'moving_start',
'moving_end',
'on_rez',
'object_rez',
'link_message',
'changed',
'remote_data'
);
$words['constants'] = array(
'TRUE',
'FALSE',
'STATUS_PHYSICS',
'STATUS_PHANTOM',
'STATUS_ROTATE_X',
'STATUS_ROTATE_Y',
'STATUS_ROTATE_Z',
'STATUS_SANDBOX',
'STATUS_BLOCK_GRAB',
'STATUS_DIE_AT_EDGE',
'STATUS_RETURN_AT_EDGE',
'AGENT',
'ACTIVE',
'PASSIVE',
'SCRIPTED',
'CONTROL_FWD',
'CONTROL_BACK',
'CONTROL_LEFT',
'CONTROL_RIGHT',
'CONTROL_ROT_LEFT',
'CONTROL_ROT_RIGHT',
'CONTROL_UP',
'CONTROL_DOWN',
'CONTROL_LBUTTON',
'CONTROL_ML_LBUTTON',
'PERMISSION_DEBIT',
'PERMISSION_TAKE_CONTROLS',
'PERMISSION_TRIGGER_ANIMATION',
'PERMISSION_ATTACH',
'PERMISSION_CHANGE_LINKS',
'AGENT_FLYING',
'AGENT_ATTACHMENTS',
'AGENT_SCRIPTED',
'AGENT_SITTING',
'AGENT_ON_OBJECT',
'AGENT_MOUSELOOK',
'AGENT_AWAY',
'AGENT_WALKING',
'AGENT_IN_AIR',
'AGENT_TYPING',
'AGENT_CROUCHING',
'AGENT_BUSY',
'AGENT_ALWAYS_RUN',
'PSYS_PART_FLAGS',
'PSYS_PART_START_COLOR',
'PSYS_PART_START_ALPHA',
'PSYS_PART_START_SCALE',
'PSYS_PART_END_COLOR',
'PSYS_PART_END_ALPHA',
'PSYS_PART_END_SCALE',
'PSYS_PART_MAX_AGE',
'PSYS_PART_BOUNCE_MASK',
'PSYS_PART_WIND_MASK',
'PSYS_PART_INTERP_COLOR_MASK',
'PSYS_PART_INTERP_SCALE_MASK',
'PSYS_PART_FOLLOW_SRC_MASK',
'PSYS_PART_FOLLOW_VELOCITY_MASK',
'PSYS_PART_TARGET_POS_MASK',
'PSYS_PART_EMISSIVE_MASK',
'PSYS_PART_TARGET_LINEAR_MASK',
'PSYS_SRC_PATTERN',
'PSYS_SRC_INNERANGLE',
'PSYS_SRC_OUTERANGLE',
'PSYS_SRC_ANGLE_BEGIN',
'PSYS_SRC_ANGLE_END',
'PSYS_SRC_BURST_RATE',
'PSYS_SRC_BURST_PART_COUNT',
'PSYS_SRC_BURST_RADIUS',
'PSYS_SRC_BURST_SPEED_MIN',
'PSYS_SRC_BURST_SPEED_MAX',
'PSYS_SRC_MAX_AGE',
'PSYS_SRC_ACCEL',
'PSYS_SRC_TEXTURE',
'PSYS_SRC_TARGET_KEY',
'PSYS_SRC_OMEGA',
'PSYS_SRC_PATTERN_DROP',
'PSYS_SRC_PATTERN_EXPLODE',
'PSYS_SRC_PATTERN_ANGLE',
'PSYS_SRC_PATTERN_ANGLE_CONE',
'PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY',
'VEHICLE_TYPE_NONE',
'VEHICLE_TYPE_SLED',
'VEHICLE_TYPE_CAR',
'VEHICLE_TYPE_BOAT',
'VEHICLE_TYPE_AIRPLANE',
'VEHICLE_TYPE_BALLOON',
'VEHICLE_REFERENCE_FRAME',
'VEHICLE_LINEAR_FRICTION_TIMESCALE',
'VEHICLE_ANGULAR_FRICTION_TIMESCALE',
'VEHICLE_LINEAR_MOTOR_DIRECTION',
'VEHICLE_LINEAR_MOTOR_OFFSET',
'VEHICLE_ANGULAR_MOTOR_DIRECTION',
'VEHICLE_HOVER_HEIGHT',
'VEHICLE_HOVER_EFFICIENCY',
'VEHICLE_HOVER_TIMESCALE',
'VEHICLE_BUOYANCY',
'VEHICLE_LINEAR_DEFLECTION_EFFICIENCY',
'VEHICLE_LINEAR_DEFLECTION_TIMESCALE',
'VEHICLE_LINEAR_MOTOR_TIMESCALE',
'VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE',
'VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY',
'VEHICLE_ANGULAR_DEFLECTION_TIMESCALE',
'VEHICLE_ANGULAR_MOTOR_TIMESCALE',
'VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE',
'VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY',
'VEHICLE_VERTICAL_ATTRACTION_TIMESCALE',
'VEHICLE_BANKING_EFFICIENCY',
'VEHICLE_BANKING_MIX',
'VEHICLE_BANKING_TIMESCALE',
'VEHICLE_FLAG_NO_DEFLECTION_UP',
'VEHICLE_FLAG_LIMIT_ROLL_ONLY',
'VEHICLE_FLAG_HOVER_WATER_ONLY',
'VEHICLE_FLAG_HOVER_TERRAIN_ONLY',
'VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT',
'VEHICLE_FLAG_HOVER_UP_ONLY',
'VEHICLE_FLAG_LIMIT_MOTOR_UP',
'VEHICLE_FLAG_MOUSELOOK_STEER',
'VEHICLE_FLAG_MOUSELOOK_BANK',
'VEHICLE_FLAG_CAMERA_DECOUPLED',
'INVENTORY_TEXTURE',
'INVENTORY_SOUND',
'INVENTORY_OBJECT',
'INVENTORY_SCRIPT',
'INVENTORY_LANDMARK',
'INVENTORY_CLOTHING',
'INVENTORY_NOTECARD',
'INVENTORY_BODYPART',
'INVENTORY_ANIMATION',
'INVENTORY_GESTURE',
'INVENTORY_ALL',
'ATTACH_CHEST',
'ATTACH_HEAD',
'ATTACH_LSHOULDER',
'ATTACH_RSHOULDER',
'ATTACH_LHAND',
'ATTACH_RHAND',
'ATTACH_LFOOT',
'ATTACH_RFOOT',
'ATTACH_BACK',
'ATTACH_PELVIS',
'ATTACH_MOUTH',
'ATTACH_CHIN',
'ATTACH_LEAR',
'ATTACH_REAR',
'ATTACH_LEYE',
'ATTACH_REYE',
'ATTACH_NOSE',
'ATTACH_RUARM',
'ATTACH_RLARM',
'ATTACH_LUARM',
'ATTACH_LLARM',
'ATTACH_RHIP',
'ATTACH_RULEG',
'ATTACH_RLLEG',
'ATTACH_LHIP',
'ATTACH_LULEG',
'ATTACH_LLLEG',
'ATTACH_BELLY',
'ATTACH_RPEC',
'ATTACH_LPEC',
'LAND_LEVEL',
'LAND_RAISE',
'LAND_LOWER',
'LAND_SMOOTH',
'LAND_NOISE',
'LAND_REVERT',
'LAND_SMALL_BRUSH',
'LAND_MEDIUM_BRUSH',
'LAND_LARGE_BRUSH',
'DATA_ONLINE',
'DATA_NAME',
'DATA_BORN',
'DATA_RATING',
'DATA_SIM_POS',
'DATA_SIM_STATUS',
'ANIM_ON',
'LOOP',
'REVERSE',
'PING_PONG',
'SMOOTH',
'ROTATE',
'SCALE',
'ALL_SIDES',
'LINK_SET',
'LINK_ROOT',
'LINK_ALL_OTHERS',
'LINK_ALL_CHILDREN',
'LINK_THIS',
'CHANGED_INVENTORY',
'CHANGED_COLOR',
'CHANGED_SHAPE',
'CHANGED_SCALE',
'CHANGED_TEXTURE',
'CHANGED_LINK',
'CHANGED_ALLOWED_DROP',
'TYPE_INTEGER',
'TYPE_FLOAT',
'TYPE_STRING',
'TYPE_KEY',
'TYPE_VECTOR',
'TYPE_ROTATION',
'TYPE_INVALID',
'REMOTE_DATA_CHANNEL',
'REMOTE_DATA_REQUEST',
'REMOTE_DATA_REPLY',
'PRIM_TYPE',
'PRIM_MATERIAL',
'PRIM_PHYSICS',
'PRIM_TEMP_ON_REZ',
'PRIM_PHANTOM',
'PRIM_POSITION',
'PRIM_SIZE',
'PRIM_ROTATION',
'PRIM_TEXTURE',
'PRIM_COLOR',
'PRIM_BUMP_SHINY',
'PRIM_TYPE_BOX',
'PRIM_TYPE_CYLINDER',
'PRIM_TYPE_PRISM',
'PRIM_TYPE_SPHERE',
'PRIM_TYPE_TORUS',
'PRIM_TYPE_TUBE',
'PRIM_TYPE_RING',
'PRIM_HOLE_DEFAULT',
'PRIM_HOLE_SQUARE',
'PRIM_HOLE_CIRCLE',
'PRIM_HOLE_TRIANGLE',
'PRIM_MATERIAL_STONE',
'PRIM_MATERIAL_METAL',
'PRIM_MATERIAL_GLASS',
'PRIM_MATERIAL_WOOD',
'PRIM_MATERIAL_FLESH',
'PRIM_MATERIAL_PLASTIC',
'PRIM_MATERIAL_RUBBER',
'PRIM_MATERIAL_LIGHT',
'PRIM_SHINY_NONE',
'PRIM_SHINY_LOW',
'PRIM_SHINY_MEDIUM',
'PRIM_SHINY_HIGH',
'PRIM_BUMP_NONE',
'PRIM_BUMP_BRIGHT',
'PRIM_BUMP_DARK',
'PRIM_BUMP_WOOD',
'PRIM_BUMP_BARK',
'PRIM_BUMP_BRICKS',
'PRIM_BUMP_CHECKER',
'PRIM_BUMP_CONCRETE',
'PRIM_BUMP_TILE',
'PRIM_BUMP_STONE',
'PRIM_BUMP_DISKS',
'PRIM_BUMP_GRAVEL',
'PRIM_BUMP_BLOBS',
'PRIM_BUMP_SIDING',
'PRIM_BUMP_LARGETILE',
'PRIM_BUMP_STUCCO',
'PRIM_BUMP_SUCTION',
'PRIM_BUMP_WEAVE',
'MASK_BASE',
'MASK_OWNER',
'MASK_GROUP',
'MASK_EVERYONE',
'MASK_NEXT',
'PERM_TRANSFER',
'PERM_MODIFY',
'PERM_COPY',
'PERM_MOVE',
'PERM_ALL',
'PARCEL_MEDIA_COMMAND_STOP',
'PARCEL_MEDIA_COMMAND_PAUSE',
'PARCEL_MEDIA_COMMAND_PLAY',
'PARCEL_MEDIA_COMMAND_LOOP',
'PARCEL_MEDIA_COMMAND_TEXTURE',
'PARCEL_MEDIA_COMMAND_URL',
'PARCEL_MEDIA_COMMAND_TIME',
'PARCEL_MEDIA_COMMAND_AGENT',
'PARCEL_MEDIA_COMMAND_UNLOAD',
'PARCEL_MEDIA_COMMAND_AUTO_ALIGN',
'NULL_KEY',
'EOF',
'PI',
'TWO_PI',
'PI_BY_TWO',
'DEG_TO_RAD',
'RAD_TO_DEG',
'SQRT2',
'ZERO_VECTOR',
'ZERO_ROTATION'
);
$words['functions'] = array(
'llAbs',
'llAcos',
'llAddToLandPassList',
'llAdjustSoundVolume',
'llAllowInventoryDrop',
'llAngleBetween',
'llApplyImpulse',
'llApplyRotationalImpulse',
'llAsin',
'llAtan2',
'llAttachToAvatar',
'llAvatarOnSitTarget',
'llAxes2Rot',
'llAxisAngle2Rot',
'llBase64ToInteger',
'llBase64ToString',
'llBreakAllLinks',
'llBreakLink',
'llCeil',
'llCloseRemoteDataChannel',
'llCloud',
'llCollisionFilter',
'llCollisionSound',
'llCollisionSprite',
'llCos',
'llCreateLink',
'llCSV2List',
'llDeleteSubList',
'llDeleteSubString',
'llDetachFromAvatar',
'llDetectedGrab',
'llDetectedGroup',
'llDetectedKey',
'llDetectedLinkNumber',
'llDetectedName',
'llDetectedOwner',
'llDetectedPos',
'llDetectedRot',
'llDetectedType',
'llDetectedVel',
'llDialog',
'llDie',
'llDumpList2String',
'llEdgeOfWorld',
'llEjectFromLand',
'llEmail',
'llEuler2Rot',
'llFabs',
'llFloor',
'llForceMouselook',
'llFrand',
'llGetAccel',
'llGetAgentInfo',
'llGetAgentSize',
'llGetAlpha',
'llGetAndResetTime',
'llGetAnimation',
'llGetAnimationList',
'llGetAttached',
'llGetBoundingBox',
'llGetCenterOfMass',
'llGetColor',
'llGetCreator',
'llGetDate',
'llGetEnergy',
'llGetForce',
'llGetFreeMemory',
'llGetGeometricCenter',
'llGetGMTclock',
'llGetInventoryCreator',
'llGetInventoryKey',
'llGetInventoryName',
'llGetInventoryNumber',
'llGetInventoryPermMask',
'llGetKey',
'llGetLandOwnerAt',
'llGetLinkKey',
'llGetLinkName',
'llGetLinkNumber',
'llGetListEntryType',
'llGetListLength',
'llGetLocalPos',
'llGetLocalRot',
'llGetMass',
'llGetNextEmail',
'llGetNotecardLine',
'llGetNumberOfNotecardLines',
'llGetNumberOfPrims',
'llGetNumberOfSides',
'llGetObjectDesc',
'llGetObjectMass',
'llGetObjectName',
'llGetObjectPermMask',
'llGetOmega',
'llGetOwner',
'llGetOwnerKey',
'llGetPermissions',
'llGetPermissionsKey',
'llGetPos',
'llGetPrimitiveParams',
'llGetRegionCorner',
'llGetRegionFPS',
'llGetRegionName',
'llGetRegionTimeDilation',
'llGetRootPosition',
'llGetRootRotation',
'llGetRot',
'llGetScale',
'llGetScriptName',
'llGetScriptState',
'llGetSimulatorHostname',
'llGetStartParameter',
'llGetStatus',
'llGetSubString',
'llGetSunDirection',
'llGetTexture',
'llGetTextureOffset',
'llGetTextureRot',
'llGetTextureScale',
'llGetTime',
'llGetTimeOfDay',
'llGetTimestamp',
'llGetTorque',
'llGetVel',
'llGetWallclock',
'llGiveInventory',
'llGiveInventoryList',
'llGiveMoney',
'llGodLikeRezObject',
'llGround',
'llGroundContour',
'llGroundNormal',
'llGroundRepel',
'llGroundSlope',
'llInsertString',
'llInstantMessage',
'llIntegerToBase64',
'llKey2Name',
'llList2CSV',
'llList2Float',
'llList2Integer',
'llList2Key',
'llList2List',
'llList2ListStrided',
'llList2Rot',
'llList2String',
'llList2Vector',
'llListen',
'llListenControl',
'llListenRemove',
'llListFindList',
'llListInsertList',
'llListRandomize',
'llListReplaceList',
'llListSort',
'llLoadURL',
'llLog',
'llLog10',
'llLookAt',
'llLoopSound',
'llLoopSoundMaster',
'llLoopSoundSlave',
'llMakeExplosion',
'llMakeFire',
'llMakeFountain',
'llMakeSmoke',
'llMD5String',
'llMessageLinked',
'llMinEventDelay',
'llModifyLand',
'llMoveToTarget',
'llOffsetTexture',
'llOpenRemoteDataChannel',
'llOverMyLand',
'llOwnerSay',
'llParcelMediaCommandList',
'llParcelMediaQuery',
'llParseString2List',
'llParseStringKeepNulls',
'llParseStringKeepNulls',
'llParticleSystem',
'llPassCollisions',
'llPassTouches',
'llPlaySound',
'llPlaySoundSlave',
'llPointAt',
'llPow',
'llPreloadSound',
'llPushObject',
'llReleaseCamera',
'llReleaseControls',
'llRemoteDataReply',
'llRemoteDataSetRegion',
'llRemoteLoadScript',
'llRemoteLoadScriptPin',
'llRemoveInventory',
'llRemoveVehicleFlags',
'llRequestAgentData',
'llRequestInventoryData',
'llRequestPermissions',
'llRequestSimulatorData',
'llResetOtherScript',
'llResetScript',
'llResetTime',
'llRezAtRoot',
'llRezObject',
'llRot2Angle',
'llRot2Axis',
'llRot2Euler',
'llRot2Fwd',
'llRot2Left',
'llRot2Up',
'llRotateTexture',
'llRotBetween',
'llRotLookAt',
'llRotTarget',
'llRotTargetRemove',
'llRound',
'llSameGroup',
'llSay',
'llScaleTexture',
'llScriptDanger',
'llSendRemoteData',
'llSensor',
'llSensorRemove',
'llSensorRepeat',
'llSetAlpha',
'llSetBuoyancy',
'llSetCameraAtOffset',
'llSetCameraEyeOffset',
'llSetColor',
'llSetDamage',
'llSetForce',
'llSetForceAndTorque',
'llSetHoverHeight',
'llSetInventoryPermMask',
'llSetLinkAlpha',
'llSetLinkColor',
'llSetLocalRot',
'llSetObjectDesc',
'llSetObjectName',
'llSetObjectPermMask',
'llSetParcelMusicURL',
'llSetPos',
'llSetPrimitiveParams',
'llSetRemoteScriptAccessPin',
'llSetRot',
'llSetScale',
'llSetScriptState',
'llSetSitText',
'llSetSoundQueueing',
'llSetSoundRadius',
'llSetStatus',
'llSetText',
'llSetTexture',
'llSetTextureAnim',
'llSetTimerEvent',
'llSetTorque',
'llSetTouchText',
'llSetVehicleFlags',
'llSetVehicleFloatParam',
'llSetVehicleRotationParam',
'llSetVehicleType',
'llSetVehicleVectorParam',
'llShout',
'llSin',
'llSitTarget',
'llSleep',
'llSound',
'llSoundPreload',
'llSqrt',
'llStartAnimation',
'llStopAnimation',
'llStopHover',
'llStopLookAt',
'llStopMoveToTarget',
'llStopPointAt',
'llStopSound',
'llStringLength',
'llStringToBase64',
'llSubStringIndex',
'llTakeCamera',
'llTakeControls',
'llTan',
'llTarget',
'llTargetOmega',
'llTargetRemove',
'llTeleportAgentHome',
'llToLower',
'llToUpper',
'llTriggerSound',
'llTriggerSoundLimited',
'llUnSit',
'llVecDist',
'llVecMag',
'llVecNorm',
'llVolumeDetect',
'llWater',
'llWhisper',
'llWind',
'llXorBase64Strings'
);
global $wakka;
$match = $matches[0];
// string
if (substr($match, -1, 1) == "\"") {
return '<span style="color: ' . $colors['string'] . ';">' . $match . '</span>';
}
// comments
else if (substr($match, 0, 2) == "//") {
return '<span style="color: ' . $colors['comment'] . ';">' . $match . '</span>';
}
// vector / rotation
else if ( ($match == '<') || ($match == '>') ) {
return '<span style="color: ' . $colors['vecrot'] . ';">' . $match . '</span>';
}
// list
else if ( ($match == '[') || ($match == ']') ) {
return '<span style="color: ' . $colors['list'] . ';">' . $match . '</span>';
}
// word
else {
if (in_array($match, $words['keywords'])) return '<span style="color: ' . $colors['keyword'] . ';">' . $match . '</span>';
else if (in_array($match, $words['types'])) return '<span style="color: ' . $colors['type'] . ';">' . $match . '</span>';
else if (in_array($match, $words['events'])) return '<a href="' . $wakka->GetConfigValue("base_url") . $match . '" style="color: ' . $colors['event'] . ';">' . $match . '</a>';
else if (in_array($match, $words['constants'])) return '<a href="' . $wakka->GetConfigValue("base_url") . 'TextSearch?phrase=' . $match . '" style="color: ' . $colors['constant'] . ';">' . $match . '</a>';
else if (in_array($match, $words['functions'])) return '<a href="' . $wakka->GetConfigValue("base_url") . $match . '" style="color: ' . $colors['function'] . ';">' . $match . '</a>';
else return $match;
}
}
}
// filter HTML
$lsl = htmlentities($text, ENT_NOQUOTES);
$lsl = str_replace("\r", "", $lsl);
// the regex that does all the highlighting
$lsl = preg_replace_callback('@(?:' .
'".*?(?:[^\x5c]"|\x5c\x5c")|' . // string (this is how to fix your editor highlighting, Lindens! :P) 0x5c = backslash
'[^\x5c]""|' . // string too (empty)
'//.*?(?:\n|$)|' . // comments
'(?:<|>)|' . // vector / rotation
'[\[\]]|' . // list
'[a-zA-Z_][a-zA-Z0-9_]*' . // words
')@ms', 'lslCallback', $lsl);
// output (replace tabs with 4 spaces)
print("<pre>" . str_replace("\t", " ", $lsl) . "</pre>");
?>