Changed Event Example
From OpenSimulator
(Difference between revisions)
(→an example of a supported changed event script) |
m (Indentation) |
||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | default { | + | __NOTOC__ |
− | state_entry() { | + | {{Quicklinks}} |
− | llSitTarget(<0, 0, 0.1>, ZERO_ROTATION); | + | |
+ | '''Code:''' | ||
+ | <source lang="lsl"> | ||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | // needed for llAvatarOnSitTarget to work | ||
+ | llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); | ||
} | } | ||
− | + | ||
− | changed(integer change) { // something changed | + | changed(integer change) |
− | if ((change & CHANGED_LINK) != 0) { // and it was a link change | + | { |
− | + | // something changed | |
+ | if ((change & CHANGED_LINK) != 0) | ||
+ | { | ||
+ | // and it was a link change | ||
+ | // llSleep(0.5); // llUnSit works better with this delay | ||
key av = llAvatarOnSitTarget(); | key av = llAvatarOnSitTarget(); | ||
− | + | if (av != "") | |
− | if (av != "") { // somebody is sitting on me | + | { |
− | llSay( | + | // somebody is sitting on me |
− | + | llSay(PUBLIC_CHANNEL, "Get off!"); // say in chat when person is remove from prim | |
} | } | ||
} | } | ||
} | } | ||
} | } | ||
+ | </source> | ||
+ | |||
+ | [[Category:Scripts]] |
Latest revision as of 06:38, 22 September 2020
Code:
default { state_entry() { // needed for llAvatarOnSitTarget to work llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); } changed(integer change) { // something changed if ((change & CHANGED_LINK) != 0) { // and it was a link change // llSleep(0.5); // llUnSit works better with this delay key av = llAvatarOnSitTarget(); if (av != "") { // somebody is sitting on me llSay(PUBLIC_CHANNEL, "Get off!"); // say in chat when person is remove from prim } } } }