aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorGiuseppe Gadola <giusgadola@gmail.com>2023-02-09 01:15:25 +0100
committerGiuseppe Gadola <giusgadola@gmail.com>2023-02-10 16:05:59 +0100
commitae8e68bc4abbd726e0aed587f22b60a80da546a3 (patch)
tree2f47267c3a9e9e4e86df5ed26bb182ac6258b336 /lua
parentrefactor: removed old ShowPet function (diff)
docs: added some basic comments to explain functions
Diffstat (limited to 'lua')
-rw-r--r--lua/pets.lua1
-rw-r--r--lua/pets/animations.lua1
-rw-r--r--lua/pets/pet.lua4
-rw-r--r--lua/pets/utils.lua2
4 files changed, 8 insertions, 0 deletions
diff --git a/lua/pets.lua b/lua/pets.lua
index f8ddb5a..6d984a0 100644
--- a/lua/pets.lua
+++ b/lua/pets.lua
@@ -22,6 +22,7 @@ function M.setup(options)
require("pets.commands") -- init autocommands
end
+-- create a Pet object and add it to the pets table
function M.create_pet(name, type, style)
local pet = require("pets.pet").Pet.new(name, type, style)
local popup = require("pets.popup").popup
diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua
index cdeaefd..bb0fb5a 100644
--- a/lua/pets/animations.lua
+++ b/lua/pets/animations.lua
@@ -2,6 +2,7 @@ local M = {}
M.Animation = {}
M.Animation.__index = M.Animation
+-- lines to insert in the buffer to avoid image stretching
local lines = {}
local string = ""
for _ = 0, 150 do
diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua
index 30e3461..f1f04c3 100644
--- a/lua/pets/pet.lua
+++ b/lua/pets/pet.lua
@@ -2,6 +2,10 @@ local M = {}
M.Pet = {}
M.Pet.__index = M.Pet
+-- @param name the actual name for the pet
+-- @param type the species of the pet e.g. cat
+-- @param style the color/style of the pet e.g. brown
+-- @return a new Pet instance
function M.Pet.new(name, type, style)
local instance = setmetatable({}, M.Pet)
instance.name = name
diff --git a/lua/pets/utils.lua b/lua/pets/utils.lua
index d436ecd..70548f1 100644
--- a/lua/pets/utils.lua
+++ b/lua/pets/utils.lua
@@ -1,5 +1,7 @@
local M = {}
+-- list all files in a directory
+-- source: https://stackoverflow.com/a/11130774
function M.listdir(directory)
local i, t, popen = 0, {}, io.popen
local pfile = popen('/bin/ls -a "' .. directory .. '"')