Difference between revisions of "Wizardry and Steamworks"
Kira Komarov (talk | contribs) |
Kira Komarov (talk | contribs) m |
||
Line 208: | Line 208: | ||
</lsl> | </lsl> | ||
== | ==Pass Data to a Rezzed Object== | ||
This will allow you to avoid using [[llRegionSay]], [[llWhisper]], [[llSay]] to pass data to a newly rezzed object. Meant for setting up private [[listen]] channels between the newly rezzed object and the rezzer by using the [[llDialog]] key hash method. | This will allow you to avoid using [[llRegionSay]], [[llWhisper]], [[llSay]] to pass data to a newly rezzed object. Meant for setting up private [[listen]] channels between the newly rezzed object and the rezzer by using the [[llDialog]] key hash method. |
Revision as of 16:59, 23 November 2011
Wizardry and Steamworks
Wizardry and Steamworks are a development group to be found in Second Life. The leaders of the group are Kira Komarov and Flax Quirina. We specialize on scripting in Second Life, however anything that pushes the boundaries of what is currently possible in Second Life is of interest to us.
Member Wiki Mirrors
- WaS-K - Kira Komarov
FUS (Frequently Used Snippets)
Frequently Used Snippets (FUS) are short snippets that are generic enough to be included in any script. Just as you have generic types, generic functions, these represent an abstraction over Second Life script programming methodologies particular to Wizardry and Steamworks [WaS] and although they aren't delivered in the form of scripts, they can be used in any script by inserting them at the right places.
Private Channel Key-Hash
Extremely useful, taken from llDialog.
Inline Usage <lsl> integer comChannel = ((integer)("0x"+llGetSubString((string) /* llGetOwner(), llGetCreator(), llDetectedKey(0), id */,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; </lsl>
Endless Menu with Back and Next
This generates an endless menu with Back and Next buttons by arranging a list dynamically whenever the Back and Next buttons are pressed. It has been used in several scripts with some variations.
Global Primitives <lsl> list menu_items = []; list key_items = []; integer mitra = 0; list cList = [] </lsl> Global Functions <lsl> list mFwd() {
if(mitra+1>llGetListLength(menu_items)) return cList; cList = llListInsertList(llListInsertList(llList2List(menu_items, ++mitra, (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2); return cList;
}
list mBwd() {
if(mitra-19<0) return cList; cList = llListInsertList(llListInsertList(llList2List(menu_items, (mitra-=19), (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2); return cList;
} </lsl> Inline Usage <lsl>
integer itra; for(itra=0, mitra=0, menu_items=[]; itra< llGetListLength(/* list */); ++itra) { menu_items += llList2String(/* list */, itra); } cList = llListInsertList(llListInsertList(llList2List(menu_items, mitra, (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2); llDialog(/* Key to prompt */, /* Dialog Text */, cList, /* channel */);
</lsl>
Generic Notecard Reader
This is a generic notecard loader. In this variation, it does not set a timer to check whether the notecard has been loaded.
Global Primitives <lsl> key nQuery = NULL_KEY; integer nLine = 0; list nList = []; //pragma inline string nName = "New Notecard"; </lsl> Reading <lsl>
integer itra; for(itra=0. accessList=[]; itra<llGetInventoryNumber(INVENTORY_NOTECARD); ++itra) { if(llGetInventoryName(INVENTORY_NOTECARD, itra) == nName) jump found_notecard; } llInstantMessage(llGetOwner(), "Failed to find notecard."); return;
@found_notecard;
nQuery = llGetNotecardLine(nName, nLine);
</lsl> Dataserver <lsl>
dataserver(key id, string data) { if(id != nQuery) return; if(data == EOF) return; if(data == "") jump next_line; list nList += data;
@next_line;
nQuery = llGetNotecardLine(nName, ++nLine); }
</lsl> Extension: Return if key/name NOT in nList <lsl>
if(!~llListFindList(nList, (list)/* llDetectedKey(0), llDetectedName(0) */)) return;
</lsl>
RLV: Wearables & Attachment Lists as Strings
A pain to type.
Local preferred, global if needed <lsl> //pragma inline list CLOTHES = [ "gloves", "jacket", "pants", "shirt", "shoes", "skirt", "socks", "underpants", "undershirt" ]; //pragma inline list ATTACHMENTS = [ "none", "chest", "skull", "left shoulder", "right shoulder", "left hand", "right hand",
"left foot", "right foot", "spine", "pelvis", "mouth", "chin", "left ear", "right ear", "left eyeball", "right eyeball", "nose", "r upper arm", "r forearm", "l upper arm", "l forearm", "right hip", "r upper leg", "r lower leg", "left hip", "l upper leg", "l lower leg", "stomach", "left pec", "right pec", "center 2", "top right", "top", "top left", "center", "bottom left", "bottom", "bottom right" ];
</lsl>
RLV: Rotate Avatar To Face Target
Primitives <lsl> vector targetpos = < /* x */, /* y */, /* z */ >; </lsl> Inline usage <lsl>
vector pointTo = targetpos - llGetPos(); float angleTo = llAtan2(pointTo.x, pointTo.y); llOwnerSay("@setrot:" + (string)angleTo + "=force")
</lsl>
Using llSensorRepeat as a Timer
Can be used as a second timer event. Explained in User:Kira Komarov/Trick or Treat.
Global primitives; <lsl> integer flag = 0; </lsl> Starting the sensor-timer <lsl>
llSensorRepeat("", NULL_KEY, flag=1, 0.1, 0.1, 60);
</lsl> (No) Sensor <lsl>
no_sensor() { if(flag) { --flag; return; }
/* this area will be hit 60 * seconds after the llSensorRepeat() * has been executed. */ }
</lsl>
Planar or Grid Distance
The x,y planar distance between the kitty and the book is given by: <lsl> float length_of_red_primitive=llVecDist(<kitty.x,kitty.y,0>,<book.x,book.y,0>); </lsl>
This works for all planes: (x,y), (x,z) and (y,z) by eliminating one of the components - in this example, z.
Object Rotate to Face Object
The rotation is given by qΔ. <lsl> vector book_position = <83.889717, 92.310814, 500.5>; vector kitty_position = <82.306671, 92.310814, 501.714783>;
default {
state_entry() { rotation qΔ = llRotBetween(<1,0,0>,llVecNorm(<book_position.x-kitty_position.x, book_position.y-kitty_position.y, book_position.z-kitty_position.z>)); llSetRot(llGetRot() * qΔ); }
} </lsl> By eliminating a component x, y or z in llVecNorm the kitty may turn on only on certain axes.
Propulse an Object towards Target (Artillery)
This will hurl an object at a target using, in order:
- High angle.
- Low angle.
- Abort if object won't even lift off.
More explanations at the Artillery article.
Global primitives <lsl> vector target = < /* x */, /* y */, /* z */ >; float velocity = /* some velocity */; </lsl> Inline usage <lsl>
vector origin = llGetPos(); dΔ=llVecDist(<target.x,target.y,0>,<origin.x,origin.y,0>); valSin = 9.81*dΔ/llPow(velocity, 2); /* Attempt high angle. */ if(valSin < -1 || valSin > 1) valSin = 9.81/llPow(velocity, 2); /* Attempt low angle. */ if(valSin < -1 || valSin > 1) return; /* Won't even lift the object off the ground. Abort. */ llSetVelocity(llVecNorm(<1,0,0>*llRotBetween(<1,0,0>,llVecNorm(<target.x-origin.x,target.y-origin.y, dΔ*llTan((90-RAD_TO_DEG*llAsin(valSin)/2) * DEG_TO_RAD) + llFabs(target.z-origin.z)>)))*velocity, FALSE);
</lsl>
Pass Data to a Rezzed Object
This will allow you to avoid using llRegionSay, llWhisper, llSay to pass data to a newly rezzed object. Meant for setting up private listen channels between the newly rezzed object and the rezzer by using the llDialog key hash method.
Hasher <lsl> integer Key2Number(key objKey) {
return ((integer)("0x"+llGetSubString((string)objKey,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
} </lsl> Inline usage <lsl> llRezObject("object name",...,Key2Number(some key)); </lsl> Rezzed object event <lsl> default {
on_rez(integer param) { /* param contains the passed data */ }
} </lsl>
Resources
All this work should be attributed to the Wizardry and Steamworks group under the GPLv3 license. You are free to use these resources and even commercialize the products using them as long as you attribute the components you got from here to the Wizardry and Steamworks [WaS] group.
These resources are originals, in the sense that they have been made, ground-up by Wizardry and Steamworks members.
Animations
File | Description |
WaS Lighter Two_Hands.bvh | The avatar leans forward and places the left mouth (holding a cigarette) and the right hand over and in front of the left mouth (holding a lighter). |
WaS-K AnkleLock Animation | Running this animation will lock your shoes to your ankles so they do not appear strange when being animated. See AnkleLock. |
Butter | Ice cream |
Sounds
File | Length | Description | Key |
WaS Zippo Short Flick Spin Click.wav | 00:01s | Zippo cap flicks open, the wheel is spun once, the zippo cap clicks shut. | bc1b20c7-fc34-6df2-2296-64be51390be2 |
Bread | Pie | Bread | Pie |
Butter | Ice cream | Bread | Pie |