Don't click here unless you want to be banned.

LSL Wiki : EcoFoodSpore1

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org

Food Spore Script


This open-source code is part of the Ecosystem project. Please read the EcosystemDisclaimer before using.
Please do not edit the code below on this page unless you've already tested it to ensure it works. If you make minor changes, please add a note describing the change. For major changes, it's better to start a new wiki page and add a link on the Ecosystem page. Thanks.


string MyEcoNameVersion = "A0";
integer FoodRootWorth = 20;
string MyProperName = "Food Spore";
string MyEcoType = "P";



//                        ~ ECO-NAME                                                                                     ~//


SetEcoName(integer FoodRoot, integer FoodLeaf, string Action, key TargetKey, integer EnergyRequested) {
    list EcoName = [MyProperName, MyEcoNameVersion, MyEcoType, FoodRoot, FoodLeaf, Action, TargetKey, EnergyRequested];
    llSetObjectName(llList2CSV(EcoName));
}

string EcoNameVersion(string name) {
    return llList2String(llCSV2List(name), 1);
}

integer EcoName2FoodRootAmount(string name) {
    if (EcoNameVersion(name) == MyEcoNameVersion) return llList2Integer(llCSV2List(name), 3);
    else return 0;
}  

integer EcoName2FoodLeafAmount(string name) {
    if (EcoNameVersion(name) == MyEcoNameVersion) return llList2Integer(llCSV2List(name), 4);
    else return 0;
}  
string EcoName2Action(string name) {
    if (EcoNameVersion(name) == MyEcoNameVersion) return llList2String(llCSV2List(name), 5);
    else return "";
}

key EcoName2TargetKey(string name) {
    if (EcoNameVersion(name) == MyEcoNameVersion) return llList2Key(llCSV2List(name), 6);
    else return NULL_KEY;
}

integer EcoName2RequestedFood(string name) {
    if (EcoNameVersion(name) == MyEcoNameVersion) return llList2Integer(llCSV2List(name), 7);
    else return 0;
}


//                                                                                                                //

reset() {
    llSetStatus(STATUS_PHYSICS, TRUE);
    llMinEventDelay(1.0);
    SetEcoName(FoodRootWorth, 0, "", NULL_KEY, 0);
}

default
{
    state_entry()
    {
        reset();
    }
    
    on_rez(integer start_param)
    {
        reset();
        if (start_param > 0) llSetTimerEvent(55);
    }
                    
    collision (integer num_detected)
    {
        if (EcoName2TargetKey(llDetectedName(0)) == llGetKey()) {
            
            if (EcoName2RequestedFood(llDetectedName(0)) > 0) {
                llDie();
            }
  
        }     
    }
    
    timer()
    {
        llSetAlpha(0.5, ALL_SIDES);
        llSleep(5);
        llDie();
    }
    
}

...by NeverRust


EcosystemWorkingGroup | Ecosystem
There is no comment on this page. [Display comments/form]