// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Water jug puzzle // Not compiled or tested in-world // Setup: Enter fill3, fill5, empty3, empty5, 3to5 or 5to3. Owner-touch starts a fresh game; type reset to restart. Input times out after 90 seconds. // Stop / restore: Let the input timeout expire or remove the script. No world geometry, avatar or inventory is changed. // Notes: Original compact educational game. Owner-only local input; no scores or avatar identities are sent to a service. Output is short ASCII text. Not a competition authority. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer channel; integer handle; integer a; integer b; close() { if(handle)llListenRemove(handle); handle=0; llSetTimerEvent(0.0); } start() { a=0; b=0; } string board() { return "3L jug: "+(string)a+" | 5L jug: "+(string)b; } show() { llOwnerSay(board()); if(!handle) { channel=-1000-(integer)llFrand(1000000.0); handle=llListen(channel,"",llGetOwner(),""); } llTextBox(llGetOwner(),"Enter fill3, fill5, empty3, empty5, 3to5 or 5to3. 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 input) { if(!handle||incomingChannel!=channel||id!=llGetOwner())return; input=llToLower(llStringTrim(input,STRING_TRIM)); if(input=="reset")start(); else { if(input=="fill3")a=3; else if(input=="fill5")b=5; else if(input=="empty3")a=0; else if(input=="empty5")b=0; else if(input=="3to5") { integer amount=a; if(amount>5-b)amount=5-b; a-=amount; b+=amount; } else if(input=="5to3") { integer amount=b; if(amount>3-a)amount=3-a; b-=amount; a+=amount; } else llOwnerSay("Unknown move."); if(b==4)llOwnerSay("Exactly four liters!"); } show(); } timer() { close(); } }