Properly written, your code should look like this...
default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}
touch_start(integer total_number)
{
llSetTexture( "Handle", ALL_SIDES )
state new;
}
state new
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}
}
There's a couple of different coding styles out there, personally, I like to line up my brackets so that the code is much easier to read as well as debug. If you look at the code above (quote this message if using IE to see the layout), the state brackets, and each event brackets line up vertically, therefore, if you miss a bracket somewhere, it's pretty easy to follow the brackets up or down vertically and see where you're missing a bracket. Often times, you'll see this style...
default {
state_entry() {
llSay(0, "Hello, Avatar!");
}
touch_start(integer total_number) {
llSetTexture( "Handle", ALL_SIDES )
state new;
}
state new {
state_entry()
{
llSay(0, "Hello, Avatar!");
}
}
which just makes my eyes swim. Not so much in this simple example, but in more complex code, I generally will take to time to go 'fix' the bracketing so I can more easily read the code. Basically, it's a matter of personal preference, so one way over the other is not the 'correct' way, so it's just my preference to code with brackets that line up vertically.
The issue in your code as you wrote it was that you dont need the { between the llSetTexture() and state new statement. Here's a more generic look at how things should be written...
// global variable declarations here
type variable = 'data';
// function declarations here
type function (variable 1, variable 2, etc)
{
function code
}
state1 // in LSL the first state entered is always the default!
{
event1 ()
{
event 1 code;
more code;
stil more code;
}
event2 ()
{
event 2 code;
}
} // end of state1
state2
{
event1()
{
event1 code;
}
event2()
{
event2 code;
}
}
Flow control statements, such as for, if-else, while, and do-while are statements, not functions, therefore do not get a semi-colon at the end of the line...
integer i;
for (i=0; i < someValue; i++) //<-- note no semi colon
{
my repeating code here...
}
while (condition)
{
statements;
}
do
{
llSay(0, "monkey!");
}
while (monkeysRemain());
etc...
Jumps and returns DO get a semi colon, personally, I never ever ever ever ever use jump. It's just bad programming practice and if you use it, shoot yourself
