Thursday, March 20, 2008

A trick for flipping a flag in LSL

Chatting on the Scripters Support Group, Trent Platthy posted an interesting trick I hadn't thought of before for flipping a flag variable.

flag=!flag;


Nice and simple. :)

A code example:

integer flag=0;
default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}

touch_start(integer total_number)
{
if(flag)
{
//flag is set
llSay(0,"Flag is Set");
}
else
{
llSay(0,"Flag is not set.");
}
flag=!flag; //toggle
}
}

No comments:


Official Second Life Blog