//Alan's basic gate script 
//Last updated April 10, 2001 
//This is a general-purpose script to put in your gate. 
//It performs common gate functions and defines functions that can be used in other rooms. 
//Place this entire script in your gate. 
//Tailor the signon and room list for your palace at the start of this script. 
//Tailor the functions you want near the end of this script. 
//Place the last portion of this script, only, in rooms where you want these functions. 
ON SIGNON {
    //*****Tailor here***** 
    LOCALMSG("Welcome to " & SERVERNAME() & ", " & USERNAME() & "!");
    ALARMEXEC(100, { SOUND("your_welcome"); } );
    //*****Tailor here***** 
    // 
    // 
    //Roomlist - go to a room by saying its name 
    //Say "roomlist" to get a list of the rooms you can go to. 
    //This is an OUTCHAT script. 
    GLOBAL roomlist;
    DEF <void> roomlist() {
        // 
        //*****Tailor here***** 
        //Put room names and numbers here in form: [ roomname roomnumber ] [ roomname roomnumber ] 
        //*****Tailor here***** 
        // 
        roomarray = [ [ "gate", 86 ] ];
        FOREACH ( this0 IN roomarray) {
            temparray = this0;
            IF (CHATSTR == temparray[0]) {
                CHATSTR = "";
                GOTOROOM(temparray[1]);
            }
        }
        IF (CHATSTR == "roomlist") {
            smack = "You may type any of the following room names to go directly there:  ";
            FOREACH ( this1 IN roomarray) {
                temparray = this1;
                smack += temparray[0] & ",";
            }
            LOCALMSG(smack);
            CHATSTR = "";
        }
    }
    // 
    // 
    //ICameFrom - send a message to Owners/Operators when someone arrives 
    GLOBAL ICameFrom;
    IF (IPTVERSION()) {
        IF (NOT(VARTYPE(ICameFrom) == 4)) {
            ICameFrom = "(unknown)";
        }
        var3 = CLIENTTYPE();
    } ELSE {
        IF (ICameFrom == 0) {
            ICameFrom = "(unknown)";
        }
        IF (DATETIME() > 0) {
            var2 = "PC";
        } ELSE {
            var2 = "Mac";
        }
        var3 = var2;
    }
    SUSRMSG("I am using a " & var3 & " client and I came from '" & ICameFrom & "'.  My userID is " & ITOA(WHOME()));
    ICameFrom = SERVERNAME();
    // 
    // 
    //The following are standard scripts for any room 
    //You may call them individually, or as a whole with the commands at the end of this script. 
    // 
    // 
    //Allscray - cause others in room to say/do things.  Does not affect other Owners/Operators. 
    //If you whisper to someone they are the only one affected. 
    // ";as" makes everyone say/do something 
    // ";ao" makes everyone except you say/do something. 
    //Includes part of 'clone' script. 
    //This is an INCHAT script 
    GLOBAL xDoIt;
    GLOBAL nDoIt;
    // let anybody use Allscary - NOT RECOMMENDED. 
    DEF <void> xDoIt() {
        IF (GREPSTR(LOWERCASE(CHATSTR), "^;as (.*)") AND NOT(ISWIZARD())) {
            EXEC(STRTOATOM(GREPSUB("$1")));
        }
        IF (GREPSTR(LOWERCASE(CHATSTR), "^;ao (.*)") AND NOT(WHOCHAT() == WHOME()) AND NOT(ISWIZARD())) {
            EXEC(STRTOATOM(GREPSUB("$1")));
        }
        IF (GREPSTR(LOWERCASE(CHATSTR), "^;*allscray (.*)") AND NOT(ISWIZARD())) {
            EXEC(STRTOATOM(GREPSUB("$1")));
        }
        //myavis - receive the cloned av 
        IF (GREPSTR(LOWERCASE(CHATSTR), "^;myavis (.*)$") AND WHOCHAT() == WHOTARGET()) {
            EXEC(STRTOATOM(GREPSUB("$1 SETPROPS")));
            LOGMSG("Received cloned prop.");
        }
    }
    // let only Owners and Operators use Allscray.  They must be wearing their *.  RECOMMENDED. 
    DEF <void> nDoIt() {
        GLOBAL xDoIt;
        IF (GREPSTR(WHONAME(WHOCHAT()), "^[*]")) {
            xDoIt();
        }
    }
    // 
    //Allscraycommands - useful allscray commands 
    //Uses Owners/Operators, only, allscray. 
    //This is an OUTCHAT script 
    GLOBAL allscraycommands;
    DEF <void> allscraycommands() {
        IF (CHATSTR == "gothere") {
            //gothere - send to mouse position 
            <mouseX, mouseY> = MOUSEPOS();
            CHATSTR = ";ao " & ITOA(mouseX) & " " & ITOA(mouseY) & " SETPOS";
        }
        //sendroom - send to another room 
        IF (GREPSTR(LOWERCASE(CHATSTR), "sendroom ([0-9]*)")) {
            CHATSTR = GREPSUB(";ao $1 GOTOROOM");
        }
        //sendpal - send to another palace 
        IF (GREPSTR(LOWERCASE(CHATSTR), "sendpal (.*)")) {
            CHATSTR = GREPSUB(";ao \"palace://$1\" NETGOTO");
        }
        //sendmail - send to a web address 
        IF (GREPSTR(LOWERCASE(CHATSTR), "sendmail (.*)")) {
            CHATSTR = GREPSUB(";ao \"mailto:$1\" NETGOTO");
        }
        //sendweb - send to a web address 
        IF (GREPSTR(LOWERCASE(CHATSTR), "sendweb (.*)")) {
            CHATSTR = GREPSUB(";ao \"http://$1\" NETGOTO");
        }
        //ghost - see if the person has poofed 
        IF (CHATSTR == "ghost") {
            CHATSTR = ";ao \"I'm still here.\" WHOCHAT PRIVATEMSG";
        }
        //clone - clone the avatar of another person. 
        IF (CHATSTR == "clone") {
            IF (WHOTARGET()) {
                PRIVATEMSG(";ao 
			0 i =
			\"i: \" i ITOA & LOGMSG
				{ \";myavis [ \" smack =
					{  i USERPROP ITOA \" \" & smack +=
					i ++
					} { i NBRUSERPROPS < } WHILE smack \"]\" & WHOCHAT PRIVATEMSG
				} NBRUSERPROPS IF", WHOTARGET());
            } ELSE {
                LOGMSG("Clone:  You must be whispering to someone.");
            }
            CHATSTR = "";
        }
        //giveav - give your av to other(s) 
        IF (CHATSTR == "giveav") {
            p = ";allscray [ ";
            i = 0;
            WHILE (i < NBRUSERPROPS) {
                p = p & ITOA(USERPROP(i)) & " ";
                i++;
            }
            CHATSTR = p & "] SETPROPS";
        }
    }
    // 
    // 
    //Offer/Accept/URL - trade avs and URLs with others. 
    //Whisper to offer to one person, say to offer to all people. 
    //This part is an INCHAT script. 
    GLOBAL offerInScript;
    DEF <void> offerInScript() {
        GLOBAL offeredAvatar;
        GLOBAL offeredURL;
        IF (GREPSTR(CHATSTR, "^;urloffer ([0-9a-zA-Z\./?=%:@~]+)") AND NOT(WHOCHAT() == WHOME())) {
            offeredURL = GREPSUB("$1");
            LOCALMSG(GREPSUB("You have been offered a URL link to $1 by ") & WHONAME(WHOCHAT()) & ". To visit it say \"accepturl\".");
        }
        // 
        IF (GREPSTR(CHATSTR, "^;avoffer [\[] ([0-9<>A-Fa-f -]+) [\]]") AND NOT(WHOCHAT() == WHOME())) {
            prps = GREPSUB("$1");
            IF (NOT(GREPSTR(prps, ".* .* .* .* .* .* .* .* .* .*")) AND NOT(GREPSTR(prps, "-$")) AND NOT(GREPSTR(prps, "- ")) AND NOT(GREPSTR(prps, ">$")) AND NOT(GREPSTR(prps, "> ")) AND NOT(GREPSTR(prps, "<$")) AND NOT(GREPSTR(prps, "< "))) {
                offeredAvatar = "[ " & prps & " ] SETPROPS";
                <whoX4, whoY4> = WHOPOS(WHOCHAT());
                LOCALMSG("@" & ITOA(whoX4) & "," & ITOA(whoY4) & " You have been offered an avatar by " & WHONAME(WHOCHAT()) & ". To accept it, type \"accept\".");
            }
            CHATSTR = "";
        }
    }
    // 
    //This part is an OUTCHAT script. 
    GLOBAL offeredAvatar;
    offeredAvatar = "";
    GLOBAL offeredURL;
    offeredURL = "";
    GLOBAL offerOutScript;
    DEF <void> offerOutScript() {
        GLOBAL offeredAvatar;
        GLOBAL offeredURL;
        //offerweb - offer a web address 
        IF (GREPSTR(LOWERCASE(CHATSTR), "^offerweb ([0-9a-zA-Z\./?=%:@~]+)$")) {
            IF (WHOTARGET()) {
                PRIVATEMSG(GREPSUB(";urloffer http://$1"), WHOTARGET());
            } ELSE {
                STATUSMSG("You must whisper to offer.");
            }
            CHATSTR = "";
        }
        //offerpal - offer a palace address 
        IF (GREPSTR(LOWERCASE(CHATSTR), "^offerpal ([0-9a-zA-Z\./?=%:@~]+)$")) {
            IF (WHOTARGET()) {
                PRIVATEMSG(GREPSUB(";urloffer palace://$1"), WHOTARGET());
            } ELSE {
                STATUSMSG("You must whisper to offer.");
            }
            CHATSTR = "";
        }
        //offermail - offer an email address 
        IF (GREPSTR(LOWERCASE(CHATSTR), "^offermail ([0-9a-zA-Z\./?=%:@~]+)$")) {
            IF (WHOTARGET()) {
                PRIVATEMSG(GREPSUB(";urloffer mailto:$1"), WHOTARGET());
            } ELSE {
                STATUSMSG("You must whisper to offer.");
            }
            CHATSTR = "";
        }
        //accepturl - accept web, palace or email address 
        IF (CHATSTR == "accepturl" AND NOT(offeredURL == "")) {
            NETGOTO(offeredURL);
            CHATSTR = "";
        }
        //offer - offer av 
        IF (CHATSTR == "offer") {
            IF (WHOTARGET()) {
                IF (NBRUSERPROPS) {
                    i = 0;
                    smack = ";avoffer [ ";
                    WHILE (i < NBRUSERPROPS) {
                        smack += ITOA(USERPROP(i)) & " ";
                        i++;
                    }
                    PRIVATEMSG(smack & "]", WHOTARGET());
                }
            } ELSE {
                STATUSMSG("You must whisper to offer.");
            }
            CHATSTR = "";
        }
        //accept - accept av 
        IF (CHATSTR == "accept" AND NOT(offeredAvatar == "")) {
            EXEC(STRTOATOM(offeredAvatar));
            CHATSTR = "";
        }
        // 
        //Dont let anybody say the automated commands 
        // 
        IF (GREPSTR(CHATSTR, "^;avoffer")) {
            CHATSTR = "";
        }
        IF (GREPSTR(CHATSTR, "^;urloffer")) {
            CHATSTR = "";
        }
    }
    // 
    // 
    //Helpmsgs - help messages 
    //This is an OUTCHAT script. 
    GLOBAL helpmsgs;
    DEF <void> helpmsgs() {
        IF (CHATSTR == "help") {
            STATUSMSG("Help messages written to your Log.");
            LOGMSG("For a list of rooms you can go to by name type 'roomlist'");
            LOGMSG("Whisper/say 'offer' to offer your av, say 'accept' to accept it.");
            LOGMSG("Whisper 'offerweb <address>', 'offerpal <address>' or 'offermail <address>' to offer an address.");
            LOGMSG("Say 'accepturl' to open your browser, go to a palace or open an email to the offered address.");
            IF (ISWIZARD()) {
                LOGMSG("\x0dOperator/Owner commands.  You must be wearing your *.");
                LOGMSG("clone - clone another person's av.");
                LOGMSG("giveav - give your av to another person(s).");
                LOGMSG("ghost - check to see if person(s) has poofed.");
                LOGMSG("gothere - move person(s) to mouse position.");
                LOGMSG("sendroom <room number> - send person(s) to room here.");
                LOGMSG("sendpal <address> - send person(s) to palace at address.");
                LOGMSG("sendmail <addressee> - open person(s) email program to addressee.");
                LOGMSG("sendweb <address> - open person(s) browser to address.");
            }
            CHATSTR = "";
        }
    }
    // 
    // 
    //Cleanroom - clean up a room when the last person leaves it. 
    //This is a LEAVE script. 
    GLOBAL cleanroom;
    DEF <void> cleanroom() {
        IF (NBRROOMUSERS() < 2) {
            CLEARLOOSEPROPS();
            PAINTCLEAR();
        }
    }
    // 
    // 
    //***************************************************************** 
    //The following enable all of the above for easy reference in rooms. 
    //If you do not want a particular script put a semicolon (;) in front of the appropriate line(s). 
    //Use all ENTER scripts 
    GLOBAL AllENTERScripts;
    DEF <void> AllENTERScripts() {
    }
    // 
    //Use all INCHAT scripts 
    GLOBAL AllINCHATScripts;
    DEF <void> AllINCHATScripts() {
        GLOBAL nDoIt;
        nDoIt();
        //allscray 
        GLOBAL offerInScript;
        offerInScript();
        //offer/accept 
    }
    // 
    //Use all OUTCHAT scripts 
    GLOBAL AllOUTCHATScripts;
    DEF <void> AllOUTCHATScripts() {
        GLOBAL allscraycommands;
        allscraycommands();
        //allscray commands 
        GLOBAL offerOutScript;
        offerOutScript();
        //offer/accept 
        GLOBAL roomlist;
        roomlist();
        //room list 
        GLOBAL helpmsgs;
        helpmsgs();
        //help messages 
    }
    // 
    //Use all SELECT scripts 
    GLOBAL AllSELECTScripts;
    DEF <void> AllSELECTScripts() {
    }
    // 
    //Use all ALARM scripts 
    GLOBAL AllALARMScripts;
    DEF <void> AllALARMScripts() {
    }
    // 
    //Use all LEAVE scripts 
    GLOBAL AllLEAVEScripts;
    DEF <void> AllLEAVEScripts() {
        GLOBAL cleanroom;
        cleanroom();
        //cleanroom 
    }
    //***************************************************************** 
}
//The following is part of this gate script. 
//In addition, place the following part, only, in rooms where you want the functions defined above. 
//Enable all gate functions 
ON ENTER {
    GLOBAL AllENTERScripts;
    AllENTERScripts();
}
ON INCHAT {
    GLOBAL AllINCHATScripts;
    AllINCHATScripts();
}
ON OUTCHAT {
    GLOBAL AllOUTCHATScripts;
    AllOUTCHATScripts();
}
ON SELECT {
    GLOBAL AllSELECTScripts;
    AllSELECTScripts();
}
ON ALARM {
    GLOBAL AllALARMScripts;
    AllALARMScripts();
}
ON LEAVE {
    GLOBAL AllLEAVEScripts;
    AllLEAVEScripts();
}
(C) 2006 Satin Hinge