<?xml version="1.0" encoding="UTF-16"?>
<lboxes>
  <lbox>
    <id>102</id>
    <name><![CDATA[Greeting]]></name>
    <desc><![CDATA[The butler will say a greeting to an approaching visitor.]]></desc>
    <script><![CDATA[-- You can customize the butler's greeting to match every visitor.
-- Enter the character name in the table below, along with the greeting text and sound for the character's visit.

helloTable = {
    ["[kvalue:Name1;CharacterName1;str]"] = {
        "[kvalue:Greeting1;, Hello;str]",
        [kvalue:Greet SFX 1;H.Percussion.fx2;fx]
    },

    ["[kvalue:Name2;CharacterName2;str]"] = {
        "[kvalue:Greeting2;, Hi;str]",
        [kvalue:Greet SFX 2;H.Percussion.fx11;fx]
    },

    ["[kvalue:Name3;CharacterName3;str]"] = {
        "[kvalue:Greeting3;, Come on in;str]",
        [kvalue:Greet SFX 3;H.Percussion.fx6;fx]
    }
}

function GetHelloString(desc)
    if helloTable[desc] == nil then
        return desc .. "[kvalue:Default Greet;, Hello, dear.;str]"
    else
        return helloTable[desc][1]
    end
end

function GetHelloSound(desc)
    if helloTable[desc] == nil then
        return [kvalue:Default SFX;H.Percussion.fx9;fx]
    else
        return helloTable[desc][2]
    end
end

-- Called on initialization.
function OnInit()
    H.SetSensor(3, 30)
end

-- Called when a user enters the sensor range.
function OnUserEntered(desc)

    H.PlaySound(0, "r[1]r[2]")

    local sound = GetHelloSound(desc)

    if sound ~= nil then
        H.SetPercussion(1, sound)
        H.PlaySound(1, "x")
    end

    H.StartAnimation(0, 1, [kvalue:Greet Motion;H.Emotion.wave;moti])

    H.Say(2, GetHelloString(desc))
end

-- Available Motions for Setup:
--    point, sleep, angry, blush, dance, clap, comfort, drink, eat, laugh, kneel, no, 
--    otl, pat, plead, ready, sad, slap, surprise, taunt, thanks, thunder,
--    useup, victory, yes, wave, boo, charge, dislike, panic, salute, smile,
--    sorry, think, blueflag, twoflag, whiteflag, sing, jump]]></script>
    <icon>4</icon>
  </lbox>
</lboxes>
