From 0486a9092d73a485c676deef10ca4cd89da8ad41 Mon Sep 17 00:00:00 2001 From: FreeArtMan <=> Date: Wed, 10 Jun 2015 12:29:34 +0300 Subject: update cowsay --- cowsay/cowsay.lua | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'cowsay') diff --git a/cowsay/cowsay.lua b/cowsay/cowsay.lua index 6f0588e..9c84d3f 100644 --- a/cowsay/cowsay.lua +++ b/cowsay/cowsay.lua @@ -1,4 +1,5 @@ +-------------------------------------------------------------------------------- -- my drawing function ascii_nerd( name ) local s = "" @@ -16,6 +17,7 @@ function ascii_nerd( name ) return s end +-------------------------------------------------------------------------------- --from beej.us function ascii_goat( text ) local s = "" @@ -28,6 +30,7 @@ function ascii_goat( text ) return s end +-------------------------------------------------------------------------------- --http://ascii.co.uk/art/shoot function ascii_shoot( name ) local s = "" @@ -41,15 +44,59 @@ function ascii_shoot( name ) return s end +-------------------------------------------------------------------------------- function ascii_lurker( name ) end +-------------------------------------------------------------------------------- function ascii_hunt( name ) end +-------------------------------------------------------------------------------- function ascii_pc( pccmd ) end +-------------------------------------------------------------------------------- +--http://ascii.co.uk/art/juice +function ascii_juice( name1, name2 ) + local s = "" + if name1 == nil then name1 = "" end + if name2 == nil then name2 = "" end + local l1 = string.len( name1 ) + local l2 = string.len( name2 ) + + if l1 > 5 then + name1 = string.sub( name1, 1, 5 ) + elseif l1 < 5 then + while string.len(name1) < 5 do + name1 = name1 .. ' ' + end + end + + if l2 > 5 then + name2 = string.sub( name2, 1, 5 ) + elseif l2 < 5 then + while string.len( name2 ) < 5 do + name2 = name2 .. ' ' + end + end + + s = s .. [[ + __ + /.- + ______ // + /______'/| + [ ]| + [ ]] .. name1 .. [[ ]| + [ ]] .. name2 .. [[ ]| + [ _\_ ]| + [ ::: ]| + [ :' ]/ + '-------']] + return s +end + +-------------------------------------------------------------------------------- for k,v in ipairs(arg) do if v == "nerd" then print( ascii_nerd( arg[k+1] ) ) @@ -57,5 +104,7 @@ for k,v in ipairs(arg) do print( ascii_goat( arg[k+1] ) ) elseif v == "shoot" then print( ascii_shoot( arg[k+1] ) ) + elseif v == "juice" then + print( ascii_juice( arg[k+1], arg[k+2])) end end -- cgit v1.2.3