mixrmastr-bartender-droid.lua
self:onSpeech("mixdrink", function(self, speaker, fullText)
local input = removeFirstWord(fullText)
local strength = trim(input:gmatch("%w+")())
strength = strength:lower()
drink = removeFirstWord(input)
strengthTable = {}
drinkBP = ""
if string.find(strength, "triple") then
strengthTable = { 20 }
drinkBP = "a mind-blasting alcoholic beverage"
elseif string.find(strength, "double") then
strengthTable = { 16, 17 }
drinkBP = "a double-shot strength alcoholic beverage"
elseif string.find(strength, "stiff") then
strengthTable = { 2, 5, 7, 8, 19 }
drinkBP = "a strong alcoholic beverage"
elseif string.find(strength, "weak") then
strengthTable = { 1, 3, 4, 13, 14 }
drinkBP = "a weak alcoholic beverage"
elseif string.find(strength, "virgin") then
strengthTable = { 0, 6, 9, 10, 11, 12, 15, 18 }
drinkBP = "a non-alcoholic beverage"
end
local drinkName = "((xcd " .. LOTJ.stripColor(drink)
local drinkBlueprint = drinkBP
local drinkShort = drink
local drinkLong = drink .. " &Dhas been abandoned here."
local randStrength = strengthTable[math.random(#strengthTable)]
local newDrink = Object.invoke(36691)
newDrink:toChar(self)
newDrink:setName(drinkName)
newDrink:setBlueprint(drinkBlueprint)
newDrink:setShortDescription(drinkShort)
newDrink:setLongDescription(drinkLong)
newDrink:setValue2(randStrength)
self:echo("&rThe sounds of sloshing and mixing emanate from {1} for a moment before it "..
"dings and produces {2} upon its tray.&G", self, newDrink)
newDrink:toChar(speaker)
end)
function trim(str)
str = str:gsub("%s+", "")
str = string.gsub(str, "%s+", "")
return str
end
function removeFirstWord(str)
str, i = str:gsub("1", "", 1)
str = ( i > 0 ) and str or str:gsub("^.-%s", "", 1)
return str
end