// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Tiny food-web model // Not compiled or tested in-world // Setup: Enter step, rain to add plants, or seed to add one herbivore. Owner-touch initializes; enter reset to restart. Text input closes after90seconds. // Stop / restore: Close or ignore the text box, or remove the script. It changes no world objects, avatar state or inventory. // Notes: Original bounded, manually stepped educational toy. Not a calibrated simulator, real-world control system, or live scientific measurement. Rules are invented for a teaching toy, not ecological prediction. All populations have explicit caps. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer channel; integer handle; integer plants; integer herbivores; integer predators; integer turns; close() { if(handle)llListenRemove(handle); handle=0; llSetTimerEvent(0.0); } start() { plants=30; herbivores=6; predators=2; turns=0; } string view() { return "Turn "+(string)turns+" | plants "+(string)plants+" herbivores "+(string)herbivores+" predators "+(string)predators; } show() { llOwnerSay(view()); if(!handle) { channel=-1000-(integer)llFrand(1000000.0); handle=llListen(channel,"",llGetOwner(),""); } llTextBox(llGetOwner(),"Enter step, rain to add plants, or seed to add one herbivore. Type reset to restart.",channel); llSetTimerEvent(90.0); } default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; close(); start(); show(); } listen(integer incomingChannel,string name,key id,string s) { if(!handle||incomingChannel!=channel||id!=llGetOwner())return; s=llToLower(llStringTrim(s,STRING_TRIM)); if(s=="reset")start(); else { if(s=="rain") { plants+=10; if(plants>100)plants=100; } else if(s=="seed") { if(herbivores<30)++herbivores; } else if(s=="step") { ++turns; plants+=5; if(plants>100)plants=100; if(plants>=herbivores) { plants-=herbivores; if(herbivores<30)++herbivores; } else { plants=0; if(herbivores>0)--herbivores; } integer eaten=predators; if(eaten>herbivores)eaten=herbivores; herbivores-=eaten; if(eaten==predators&&eaten>0&&turns%3==0&&predators<10)++predators; else if(eaten0)--predators; } } show(); } timer() { close(); } }