Notecard

A closed mouth gathers no feet.
A journey of a thousand miles begins with a cash advance.
A king's castle is his home.
A penny saved is ridiculous.
All that glitters has a high refractive index.
Ambition a poor excuse for not having enough sense to be lazy.
Anarchy is better that no government at all.
Any small object when dropped will hide under a larger object.
As you read the scroll, it vanishes...
Automobile - A mechanical device that runs up hills and down people.
Be moderate where pleasure is concerned, avoid fatigue.
Of the choice of two evils, I pick the one I've never tried before.
Brain -- the apparatus with which we think that we think.
BATCH - A group, kinda like a herd.
Computer hackers do it all night long.
Computer modelers simulate it first.
Computer programmers don't byte, they nybble a bit.
Computer programmers know how to use their hardware.
Computers are not intelligent.  They only think they are.
Courage is your greatest present need.
CLEARASOL - Effective sunspot remover.
Death is life's way of telling you you've been fired.
Death is Nature's way of saying 'slow down'.
Do something unusual today.  Accomplish work on the computer.
Documentation is like sex: When it's good, it's fantastic, when it's bad...
Don't force it, get a larger hammer.
Don't hate yourself in the morning -- sleep till noon.
Drive defensively -- buy a tank.
Earn cash in your spare time -- blackmail friends.
Entropy isn't what it used to be.
Fairy tales: horror stories for children to get them use to reality.
Familiarity breeds children.
God didn't create the world in 7 days.  He pulled an all-nighter on the 6th.
Going the speed of light is bad for your age.
GAY ABANDON - Homosexual repellent perfume.
He who hesitates is sometimes saved.
Health is merely the slowest possible rate at which one can die.
Help support helpless victims of computer error.
Herblock's Law: if it is good, they will stop making it.
History does not repeat itself, -- historians merely repeat each other.
I'm defending her honor, which is more than she ever did.
If you don't change your direction, you may end up where you were headed.
If you're not part of the solution, be part of the problem!
In the field of observation, chance favors only the prepared minds.
It is a miracle that curiosity survives formal education.  Albert Einstein
It works better if you plug it in.
It's not hard to meet expenses, they're everywhere.
Jury -- Twelve people who determine which client has the better lawyer.
KODACLONE - duplicating film.
Let not the sands of time get in your lunch.
Life is what happens to you while you are planning to do something else.
Life's a bitch, then you die.
Lynch's Law: When the going gets tough, everyone leaves.
Mediocrity thrives on standardization.
MOP AND GLOW - Floor wax used by Three Mile Island cleanup team.
Never lick a gift horse in the mouth.
Old MacDonald had an agricultural real estate tax abatement.
Quoting one is plagiarism.  Quoting many is research.
QUARKBAR - the candy with flavour and charm.
QUASIMOTO - 4 wheeled hard-top moped made in France.
Reality's the only obstacle to happiness.
Screw up your life, you've screwed everything else up.
Silver's law:   If Murphy's law can go wrong it will.
Some grow with responsibility, others just swell.
SQWERTY - Computer keyboard sized down for use by children.
SYSTEM GOING DOWN AT 4:45 THIS AFTERNOON FOR DISK CRASHING.
The attention span of a computer is as long as its electrical cord.
The only difference between a rut and a grave is the depth.
The only way to get rid of temptation is to yield to it.
The road to to success is always under construction.
Those who can't write, write help files.
To be, or not to be, those are the parameters.
To err is human, to really foul things up requires a computer.
Today is the last day of your life so far.
TRAPEZOID - A device for catching zoids.
Wasting time is an important part of life.
When all else fails, read the instructions.
When in doubt, don't bother.
Xerox does it again and again and again and...
XMODEM - A spot-marking transfer protocol.
YTERM - A terminal program for queries.
When in doubt, ignore it.
I'd insult you, but you're not bright enough to notice.

Script

///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3      //
///////////////////////////////////////////////////////////////////////////
//
// A fortune module for Corrade Eggdrop.
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0    //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
    if(llStringLength(data) == 0) return "";
    if(llStringLength(k) == 0) return "";
    list a = llParseStringKeepNulls(data, ["&", "="], []);
    integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]);
    if(i != -1) return llList2String(a, 2*i+1);
    return "";
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueEncode(list data) {
    list k = llList2ListStrided(data, 0, -1, 2);
    list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2);
    data = [];
    do {
        data += llList2String(k, 0) + "=" + llList2String(v, 0);
        k = llDeleteSubList(k, 0, 0);
        v = llDeleteSubList(v, 0, 0);
    } while(llGetListLength(k) != 0);
    return llDumpList2String(data, "&");
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
// http://was.fm/secondlife/wanderer
vector wasCirclePoint(float radius) {
    float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
    float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
    if(llPow(x,2) + llPow(y,2) <= llPow(radius,2))
        return <x, y, 0>;
    return wasCirclePoint(radius);
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
// escapes a string in conformance with RFC1738
string wasURLEscape(string i) {
    string o = "";
    do {
        string c = llGetSubString(i, 0, 0);
        i = llDeleteSubString(i, 0, 0);
        if(c == "") jump continue;
        if(c == " ") {
            o += "+";
            jump continue;
        }
        if(c == "\n") {
            o += "%0D" + llEscapeURL(c);
            jump continue;
        }
        o += llEscapeURL(c);
@continue;
    } while(i != "");
    return o;
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
list wasCSVToList(string csv) {
    list l = [];
    list s = [];
    string m = "";
    do {
        string a = llGetSubString(csv, 0, 0);
        csv = llDeleteSubString(csv, 0, 0);
        if(a == ",") {
            if(llList2String(s, -1) != "\"") {
                l += m;
                m = "";
                jump continue;
            }
            m += a;
            jump continue;
        }
        if(a == "\"" && llGetSubString(csv, 0, 0) == a) {
            m += a;
            csv = llDeleteSubString(csv, 0, 0);
            jump continue;
        }
        if(a == "\"") {
            if(llList2String(s, -1) != a) {
                s += a;
                jump continue;
            }
            s = llDeleteSubList(s, -1, -1);
            jump continue;
        }
        m += a;
@continue;
    } while(csv != "");
    // postcondition: length(s) = 0
    return l + m;
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasListToCSV(list l) {
    list v = [];
    do {
        string a = llDumpList2String(
            llParseStringKeepNulls(
                llList2String(
                    l,
                    0
                ),
                ["\""],
                []
            ),
            "\"\""
        );
        if(llParseStringKeepNulls(
            a,
            [" ", ",", "\n", "\""], []
            ) !=
            (list) a
        ) a = "\"" + a + "\"";
        v += a;
        l = llDeleteSubList(l, 0, 0);
    } while(l != []);
    return llDumpList2String(v, ",");
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
// unescapes a string in conformance with RFC1738
string wasURLUnescape(string i) {
    return llUnescapeURL(
        llDumpList2String(
            llParseString2List(
                llDumpList2String(
                    llParseString2List(
                        i,
                        ["+"],
                        []
                    ),
                    " "
                ),
                ["%0D%0A"],
                []
            ),
            "\n"
        )
    );
}
 
// configuration data
string configuration = "";
// callback URL
string URL = "";
// store message over state.
string data = "";
 
// Notecard reading.
key nQuery = NULL_KEY;
integer nLine = 0;
list nList = [];
 
default {
    state_entry() {
        llOwnerSay("[Fortune] Starting module...");
        llSetTimerEvent(10);
    }
    link_message(integer sender, integer num, string message, key id) {
        if(id != "configuration") return;
        llOwnerSay("[Fortune] Got configuration...");
        configuration = message;
        state read_fortunes;
    }
    timer() {
        llOwnerSay("[Fortune] Requesting configuration...");
        llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY);
    }
    on_rez(integer num) {
        llResetScript();
    }
    changed(integer change) {
        if((change & CHANGED_INVENTORY) ||
            (change & CHANGED_REGION_START) ||
            (change & CHANGED_OWNER)) {
            llResetScript();
        }
    }
    state_exit() {
        llSetTimerEvent(0);
    }
}
 
state read_fortunes {
    state_entry() {
        // DEBUG
        llOwnerSay("[Fortune] Reading fortunes...");
        if(llGetInventoryType("Fortune") != INVENTORY_NOTECARD) {
            llOwnerSay("[Fortune] Failed to find a notecard named fortune in the primitive's inventory.");
            return;
        }
        nQuery = llGetNotecardLine("Fortune", nLine);
    }
    dataserver(key id, string data) {
        if(id != nQuery) return;
        if(data == EOF) {
            // DEBUG
            llOwnerSay("[Fortune] Read fortunes...");
            state listen_group;
        }
        if(data == "") jump continue;
        nList += data;
@continue;
        nQuery = llGetNotecardLine("Fortune", ++nLine);
    }
    on_rez(integer num) {
        llResetScript();
    }
    changed(integer change) {
        if((change & CHANGED_INVENTORY) ||
            (change & CHANGED_REGION_START) ||
            (change & CHANGED_OWNER)) {
            llResetScript();
        }
    }
}
 
state listen_group {
    state_entry() {
        // DEBUG
        llOwnerSay("[Fortune] Waiting for group messages...");
    }
    link_message(integer sender, integer num, string message, key id) {
        // We only care about notifications now.
        if(id != "notification")
            return;
 
        // This script only processes group notifications.
        if(wasKeyValueGet("type", message) != "group" ||
            (wasKeyValueGet("type", message) == "group" &&
            wasURLUnescape(wasKeyValueGet("group", message)) !=
            wasKeyValueGet("group", configuration)))
            return;
 
        // Get the sent message.
        data = wasURLUnescape(
            wasKeyValueGet(
                "message",
                message
            )
        );
 
        // Check if this is an eggdrop command.
        if(llGetSubString(data, 0, 0) !=
            wasKeyValueGet("command", configuration))
            return;
 
        // Check if the command matches the current module.
        list command = llParseString2List(data, [" "], []);
        if(llList2String(command, 0) !=
            wasKeyValueGet("command", configuration) + "fortune")
            return;
 
        // Remove command.
        command = llDeleteSubList(command, 0, 0);
 
        data = llList2String(
            nList,
            (integer)
                llFrand(
                    llGetListLength(nList)
                )
        );
 
        state tell;
    }
    on_rez(integer num) {
        llResetScript();
    }
    changed(integer change) {
        if((change & CHANGED_INVENTORY) ||
            (change & CHANGED_REGION_START) ||
            (change & CHANGED_OWNER)) {
            llResetScript();
        }
    }
}
 
state tell {
    state_entry() {
        // DEBUG
        llOwnerSay("[Fortune] Sending to group.");
        llInstantMessage(
            wasKeyValueGet(
                "corrade",
                configuration
            ),
            wasKeyValueEncode(
                [
                    "command", "tell",
                    "group", wasURLEscape(
                        wasKeyValueGet(
                            "group",
                            configuration
                        )
                    ),
                    "password", wasURLEscape(
                        wasKeyValueGet(
                            "password",
                            configuration
                        )
                    ),
                    "entity", "group",
                    "message", wasURLEscape(data)
                ]
            )
        );
        state listen_group;
    }
}

secondlife/scripted_agents/corrade/projects/in_world/eggdrop/fortune.txt ยท Last modified: 2022/11/24 07:45 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.