A lightweight Lua library that lets you create and manage arrays with configuration options including type enforcement, size limits, and custom access patterns.
local loader = require("Task")
Arr = initialize()
Arr.arrayCreate({
name = "school",
type = "string",
deleteExceeds = false,
showIndex = true,
value = {"students", "principal", "teacher", "school owner"}
})
print(Arr.school["rand"])- Type:
string - Description: The identifier for your array, used to access it globally
- Example:
Arr.arrayCreate({ name = "school" })
-- Access via: Arr.school- Type:
table(Lua array) - Description: Initial values to populate the array
- Example:
value = {"student", "principal", "teacher"}- Type:
"string" | "number" | "boolean" - Default:
nil(no type checking) - Description: Enforces all items to match a specific data type
- Example:
type = "string"
-- Arr.school[1] = 123 will error: expected string, got number- Type:
number - Default:
nil(unlimited) - Description: Sets maximum capacity for the array
- Example:
itemsize = 3
-- Array can only hold up to 3 items- Type:
boolean - Default:
false - Description: Controls behavior when array exceeds
itemsizefalse→ Throws errortrue→ Silently ignores/removes extra items
- Example:
deleteExceeds = true
-- Safely truncates excess items instead of crashing- Type:
boolean - Default:
false - Description: When
true, returns values with their index appended - Example:
showIndex = true
print(Arr.school[1])
-- Output: student - index of 1Returns a random item from the array.
print(Arr.school["rand"])
-- Returns a random element"rand" as a string key, not a variable name.
Arr.arrayCreate({
name = "school",
type = "string",
deleteExceeds = false,
showIndex = true,
value = {"students", "principal", "teacher", "school owner"}
})
-- Access specific item
print(Arr.school[1]) -- students - index of 1
-- Get random item
print(Arr.school["rand"]) -- random school member
-- Check array size
print(#Arr.school) -- 4✅ Type enforcement
✅ Size constraints
✅ Random element access
✅ Custom output formatting
✅ Lightweight and simple
- Lua 5.1+
- Termux or VS Code (or any Lua environment)