User:Fred Gandt/Tuition: Difference between revisions
Jump to navigation
Jump to search
Fred Gandt (talk | contribs) m creating page |
Fred Gandt (talk | contribs) applied function examples to be tidied later. |
||
| Line 1: | Line 1: | ||
== Some examples of User Created Functions == | |||
'''THIS IS NOT A SINGLE SCRIPT.''' | |||
<lsl>// This first example shows the most basic syntax used to create a function. | |||
Function() | |||
{ | |||
; | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
Function(); | |||
} | |||
touch_start(integer nd) | |||
{ | |||
Function(); | |||
} | |||
} | |||
// So we add the actions we desire within the function braces. | |||
Function() | |||
{ | |||
llOwnerSay("I worked!!"); | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
Function(); | |||
} | |||
touch_start(integer nd) | |||
{ | |||
Function(); | |||
} | |||
} | |||
// We can add conditions inside the function and pass to it any type of information. | |||
Function(integer i) | |||
{ | |||
if(i) | |||
llOwnerSay("I worked!!"); | |||
else | |||
llOwnerSay("I still worked!!"); | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
Function(TRUE); | |||
} | |||
touch_start(integer nd) | |||
{ | |||
Function(FALSE); | |||
} | |||
} | |||
// We can give the function a type and have it return the result dependent on what we feed it. | |||
string Function(integer i, integer q) | |||
{ | |||
integer r = (i + q); | |||
return ((string)r); | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
llOwnerSay(Function(5, 5)); | |||
} | |||
touch_start(integer nd) | |||
{ | |||
integer i = 5; | |||
integer q = (i*5); | |||
llOwnerSay(Function(i, q)); | |||
} | |||
}</lsl> | |||
Revision as of 05:57, 27 January 2010
Some examples of User Created Functions
THIS IS NOT A SINGLE SCRIPT.
<lsl>// This first example shows the most basic syntax used to create a function.
Function() {
;
}
default {
state_entry()
{
Function();
}
touch_start(integer nd)
{
Function();
}
}
// So we add the actions we desire within the function braces.
Function() {
llOwnerSay("I worked!!");
}
default {
state_entry()
{
Function();
}
touch_start(integer nd)
{
Function();
}
}
// We can add conditions inside the function and pass to it any type of information.
Function(integer i) {
if(i)
llOwnerSay("I worked!!");
else
llOwnerSay("I still worked!!");
}
default {
state_entry()
{
Function(TRUE);
}
touch_start(integer nd)
{
Function(FALSE);
}
}
// We can give the function a type and have it return the result dependent on what we feed it.
string Function(integer i, integer q) {
integer r = (i + q); return ((string)r);
}
default {
state_entry()
{
llOwnerSay(Function(5, 5));
}
touch_start(integer nd)
{
integer i = 5;
integer q = (i*5);
llOwnerSay(Function(i, q));
}
}</lsl>