Preprocessing

From Second Life Wiki
Revision as of 19:30, 5 May 2009 by Aeron Kohime (talk | contribs) (New page: I suggest the ability to add preprocessing to LSL, as this has no effect on LSL itself but can provide scripts which can do many different things, depending on. This would include. #Basic...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I suggest the ability to add preprocessing to LSL, as this has no effect on LSL itself but can provide scripts which can do many different things, depending on.

This would include.

  1. Basic Define keyword, can be used to define custom static variables. (these may need to be typed)
  2. IF, IFN, ELSE, ENDIF preprocessor branches

As such a script such as this: <lsl>

  1. define DEBUG TRUE
  1. if DEBUG

string mode = "DEBUG";

  1. else

string mode = "NORMAL";

  1. endif

default {

  1. if DEBUG
   on_rez(integer s)
   {
       llResetScript()
   }
  1. endif
   state_entry()
   {
       llOwnerSay(mode);
  1. if DEBUG
       llOwnerSay(llGetDate();
   }
  1. else
   }
  1. endif

} </lsl>

Could produce two different scripts depending on the value of DEBUG, which would then get compiled/interpreted.

With DEBUG set to TRUE. <lsl>

  1. define DEBUG TRUE

string mode = "DEBUG";

default {

   on_rez(integer s)
   {
       llResetScript()
   }
   state_entry()
   {
       llOwnerSay(mode);
       llOwnerSay(llGetDate();
   }

} </lsl>

With DEBUG set to FALSE. <lsl>

  1. define DEBUG FALSE

string mode = "NORMAL";

default {

   state_entry()
   {
       llOwnerSay(mode);
   }

} </lsl>