Paste: error() Usage
Author: | Takuma |
Mode: | lua |
Date: | Sat, 12 Jan 2019 19:48:58 |
Plain Text |
local Samaritan = {
Spell = {},
Prediction = {},
Extension = {}
}
function Samaritan.Spell.IsSpell(spell)
local result = {value = true, output = nil}
local validProperties = {"slot", "type", "delay", "width", "range", "speed", "collision"}
if type(spell) ~= "table" then
result.value = false
result.output = "Spell must be table."
return result
end
for _, property in pairs(validProperties) do
if not spell[property] then
result.value = false
result.output = string.format("Spell doesn't have %s property.", property)
return result
end
end
return result
end
function Samaritan.Spell:Initialize(spell)
local _ = {}
setmetatable(_, self)
self.__index = self
local isSpell = self.IsSpell(spell)
if not isSpell.value then
print(isSpell.output)
error("bla bla")
end
self = spell
return self
end
function Samaritan:Initialize()
local _ = {}
setmetatable(_, self)
self.__index = self
self.__NAME = "Samaritan"
self.__VERSION = "0.1a"
self.__AUTHOR = "Takuma"
self:PrintLoadMessage()
return self
end
function Samaritan:PrintLoadMessage()
local output = string.format("%s loaded v%s by %s.", self.__NAME, self.__VERSION, self.__AUTHOR)
print(output)
end
local samaritan = Samaritan:Initialize()
local spell =
samaritan.Spell:Initialize(
{
slaot = 0,
type = "linear",
delay = 0.25,
range = 975,
speed = 1850,
width = 60,
collision = {hero = true, minion = true, wall = true}
}
)
print(spell.width)
return samaritan
New Annotation