diff options
author | FreeArtMan <=> | 2015-06-10 12:29:34 +0300 |
---|---|---|
committer | FreeArtMan <=> | 2015-06-10 12:29:34 +0300 |
commit | 0486a9092d73a485c676deef10ca4cd89da8ad41 (patch) | |
tree | 17a55b23ce5620928d5f276126d1b4fd818da4db /cowsay/cowsay.lua | |
parent | aa75f3ac6562c2e46b700ef769f3c8ab9206bedd (diff) | |
download | code-snippets-0486a9092d73a485c676deef10ca4cd89da8ad41.tar.gz code-snippets-0486a9092d73a485c676deef10ca4cd89da8ad41.zip |
update cowsay
Diffstat (limited to 'cowsay/cowsay.lua')
-rw-r--r-- | cowsay/cowsay.lua | 49 |
1 files changed, 49 insertions, 0 deletions
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 |