Implemented basic water well and water bucket
This commit is contained in:
parent
f928139088
commit
3dbc618418
17 changed files with 862 additions and 0 deletions
210
LSL/raw/basic_ingredient.lsl
Normal file
210
LSL/raw/basic_ingredient.lsl
Normal file
|
@ -0,0 +1,210 @@
|
|||
#include "Common.lsl"
|
||||
|
||||
key g_kID=NULL_KEY;
|
||||
string g_sIngredientType = "none";
|
||||
integer g_iQuantity = 0;
|
||||
key g_kFollow = NULL_KEY;
|
||||
integer g_iProdLink=3;
|
||||
integer g_iDies=FALSE;
|
||||
vector g_vScale;
|
||||
|
||||
setText() {
|
||||
llSetText(g_sIngredientType + ": " + (string)g_iQuantity, <1,1,1>, 1);
|
||||
}
|
||||
|
||||
setProductTexture(key kID) {
|
||||
#ifdef PRODUCT_PRIM
|
||||
if(g_iProdLink!=-99) {
|
||||
#ifdef PRODUCT_FACE
|
||||
llSetLinkTexture(PRODUCT_PRIM, kID, PRODUCT_FACE);
|
||||
#else
|
||||
llSetLinkTexture(PRODUCT_PRIM, kID, ALL_SIDES);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
stopFollowing(float fOffset) {
|
||||
if(g_kFollow == NULL_KEY)return;
|
||||
g_kFollow = NULL_KEY;
|
||||
llSetTimerEvent(0);
|
||||
llSetPos(llGetPos() - <0,0,fOffset>);
|
||||
}
|
||||
|
||||
follow(key kID) {
|
||||
g_kFollow = kID;
|
||||
llSetTimerEvent(1);
|
||||
}
|
||||
|
||||
vector g_vParticleColor = ZERO_VECTOR;
|
||||
|
||||
particles(key kTarget) {
|
||||
if(kTarget == NULL_KEY) llParticleSystem([]);
|
||||
else {
|
||||
llParticleSystem(
|
||||
[
|
||||
// texture parameters:
|
||||
PSYS_SRC_TEXTURE , "",
|
||||
PSYS_PART_START_SCALE , <0.67,0.58,0.00>, PSYS_PART_END_SCALE , <0.09,0.09,0.00>,
|
||||
PSYS_PART_START_COLOR , g_vParticleColor, PSYS_PART_END_COLOR , <0.16,0.71,0.83>,
|
||||
PSYS_PART_START_ALPHA , (float)1.00, PSYS_PART_END_ALPHA , (float)1.00,
|
||||
// production parameters:
|
||||
PSYS_SRC_BURST_PART_COUNT , 16,
|
||||
PSYS_SRC_BURST_RATE , (float)0.10,
|
||||
PSYS_PART_MAX_AGE , (float)6.54,
|
||||
PSYS_SRC_MAX_AGE , (float)0.18,
|
||||
// placement parameters:
|
||||
PSYS_SRC_PATTERN , 2,
|
||||
PSYS_SRC_BURST_SPEED_MIN , (float)1.00, PSYS_SRC_BURST_SPEED_MAX , (float)1.00,
|
||||
PSYS_SRC_BURST_RADIUS , (float)0.00,
|
||||
// placement parameters (for angles only):
|
||||
PSYS_SRC_ANGLE_BEGIN , (float)0.00,
|
||||
PSYS_SRC_ANGLE_END , (float)0.00,
|
||||
PSYS_SRC_OMEGA , <0.00,0.00,0.00>,
|
||||
// after-effects & influences:
|
||||
PSYS_SRC_ACCEL , <0.00,0.00,0.00>,
|
||||
PSYS_SRC_TARGET_KEY , kTarget,
|
||||
PSYS_PART_FLAGS , ( 0 // texture & influence options:
|
||||
// | PSYS_PART_INTERP_COLOR_MASK
|
||||
| PSYS_PART_INTERP_SCALE_MASK
|
||||
// | PSYS_PART_BOUNCE_MASK
|
||||
// | PSYS_PART_WIND_MASK
|
||||
// | PSYS_PART_FOLLOW_SRC_MASK
|
||||
| PSYS_PART_FOLLOW_VELOCITY_MASK
|
||||
| PSYS_PART_TARGET_POS_MASK
|
||||
// | PSYS_PART_TARGET_LINEAR_MASK
|
||||
| PSYS_PART_EMISSIVE_MASK
|
||||
)] );
|
||||
}
|
||||
}
|
||||
|
||||
default
|
||||
{
|
||||
state_entry() {
|
||||
llLinksetDataReset();
|
||||
llSetText("Empty", <1,1,1>, 1);
|
||||
llSay(0, "Freshly initialized");
|
||||
PROTECT();
|
||||
|
||||
XteaKey(PSK);
|
||||
|
||||
global_ingredients = getIngredientChannel(NULL_KEY);
|
||||
llListen(global_ingredients, "", "", "");
|
||||
particles(NULL_KEY);
|
||||
setProductTexture(TEXTURE_TRANSPARENT);
|
||||
llSay(0, "Ready to package");
|
||||
}
|
||||
|
||||
touch_start(integer num_detected)
|
||||
{
|
||||
llParticleSystem([]);
|
||||
if(g_kFollow == NULL_KEY) {
|
||||
follow(llDetectedKey(0));
|
||||
}else {
|
||||
stopFollowing(g_vScale.z-0.2);
|
||||
}
|
||||
}
|
||||
|
||||
timer () {
|
||||
g_vScale = llGetAgentSize(g_kFollow);
|
||||
if(g_vScale == ZERO_VECTOR) {
|
||||
stopFollowing(g_vScale.z-0.2);
|
||||
}else {
|
||||
list lData = llGetObjectDetails(g_kFollow, [OBJECT_POS, OBJECT_ROT]);
|
||||
vector vPos = llList2Vector(lData,0);
|
||||
rotation rPos = llList2Rot(lData,1);
|
||||
llSetRegionPos(vPos + <1.1, -1, 1> * rPos);
|
||||
}
|
||||
}
|
||||
|
||||
on_rez(integer n) {
|
||||
llSetText("Empty", <1,1,1>, 1);
|
||||
|
||||
llListen(getIngredientChannel(llGetKey()), "", "", "");
|
||||
setProductTexture(TEXTURE_TRANSPARENT);
|
||||
|
||||
// Check if ingredient type was already set. This is not a storage container.
|
||||
if(g_sIngredientType != "none") {
|
||||
llWhisper(0, "I spilled in your inventory, consider using a sealed storage container.");
|
||||
if(g_iDies) llDie();
|
||||
#ifdef DIES
|
||||
llDie();
|
||||
#endif
|
||||
|
||||
g_sIngredientType = "none";
|
||||
g_iQuantity = 0;
|
||||
g_vParticleColor = ZERO_VECTOR;
|
||||
setProductTexture(NULL_KEY);
|
||||
}else {
|
||||
// Inform any nearby object that is waiting that we've been rezzed
|
||||
llWhisper(global_ingredients, xtea_encrypt_string(llList2Json(JSON_OBJECT, ["cmd", "alive", "type", INGREDIENT_HOLDER_TYPE])));
|
||||
}
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i,string m) {
|
||||
// Decode message
|
||||
string params = xtea_decrypt_string(m);
|
||||
|
||||
// Get operation
|
||||
if(c == global_ingredients) {
|
||||
if(g_kID == NULL_KEY) return;
|
||||
else {
|
||||
if(llJsonGetValue(params, ["cmd"]) == "query") {
|
||||
llRegionSayTo(i,c,xtea_encrypt_string(llList2Json(JSON_OBJECT, ["cmd", "reply", "ingredient", g_sIngredientType, "id", g_kID])));
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(llJsonGetValue(params, ["cmd"]) == "init") {
|
||||
g_kID = llGenerateKey();
|
||||
llSetText("Initializing...", <0.5,0,0>, 1);
|
||||
} else if(llJsonGetValue(params, ["cmd"]) == "deposit") {
|
||||
if(g_sIngredientType == "none" || g_sIngredientType == llJsonGetValue(params, ["type"])) {
|
||||
g_sIngredientType = llJsonGetValue(params, ["type"]);
|
||||
string sStatus = "fail";
|
||||
|
||||
if(g_iQuantity == 0) {
|
||||
g_iQuantity += (integer)llJsonGetValue(params, ["amount"]);
|
||||
sStatus = "ok";
|
||||
setProductTexture(llJsonGetValue(params, ["texture"]));
|
||||
g_vParticleColor = (vector)llJsonGetValue(params, ["particle"]);
|
||||
g_iDies = (integer)llJsonGetValue(params, ["dies"]);
|
||||
|
||||
particles(llGetKey());
|
||||
llMessageLinked(LINK_SET, 0, "", "");
|
||||
}
|
||||
|
||||
setText();
|
||||
|
||||
|
||||
llRegionSayTo(i, getIngredientChannel(NULL_KEY), xtea_encrypt_string(llList2Json(JSON_OBJECT, ["cmd", "deposit_reply", "status", sStatus])));
|
||||
|
||||
particles(NULL_KEY);
|
||||
}
|
||||
|
||||
} else if(llJsonGetValue(params, ["cmd"]) == "use" && llJsonGetValue(params, ["id"]) == g_kID) {
|
||||
particles(i);
|
||||
if(g_iQuantity==0) {
|
||||
llRegionSayTo(i,global_ingredients,llList2Json(JSON_OBJECT, ["cmd", "use_reply", "id", NULL_KEY, "amount", 0]));
|
||||
return;
|
||||
}
|
||||
g_iQuantity--;
|
||||
llRegionSayTo(i,global_ingredients,llList2Json(JSON_OBJECT, ["cmd", "use_reply", "id", g_kID, "amount", 1, "ingredient", g_sIngredientType]));
|
||||
|
||||
setText();
|
||||
if(g_iQuantity<=0) {
|
||||
g_iQuantity=0;
|
||||
setProductTexture(TEXTURE_TRANSPARENT);
|
||||
|
||||
g_sIngredientType = "none";
|
||||
|
||||
#ifdef DIES
|
||||
llDie();
|
||||
#endif
|
||||
|
||||
if(g_iDies) llDie();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue