What does loop in gettable mean? Because I get this in my script
-- Module
local Embed = {}
Embed.__index = Embed
Embed.__call = function(t, ...) return Embed end
Embed.ClassName = "Embed"
function Embed.new(data)
local self = {}
self.__index = self
self.rawdata = {}
return setmetatable(self, Embed)
end
function Embed:addField(name, value, inline)
_ScanParam({"name", name}, {"string"}, true, true, {1, 256})
_ScanParam({"value", value}, {"string"}, true, true, {1, 1024})
_ScanParam({"inline", inline}, {"boolean"}, false, true)
if not (self.rawdata.fields) then
self.rawdata.fields = {}
end
local field = {}
field.name = name
field.value = value
field.inline = inline
table.insert(self.rawdata.fields, field)
return self
end
function Embed:addFields(...)
local fields = {...}
for _, field in ipairs(fields) do
_ScanParam({"field", field}, {"table"}, false, true)
Embed:addField(field.name, field.value, field.inline)
end
return self
end
return setmetatable(Embed, Embed)
-- Script
local new = mod.new()
:addField("Name", "Value", true)
:addFields(
{name = "Name", value = "Value"},
{name = "Name", value = "Value", inline = true}
);
But if I make like this
local Embed = {}
Embed.__index = Embed
Embed.__call = function(t, ...) return Embed end
Embed.ClassName = "Embed"
function Embed.new(data)
local self = {}
self.__index = self
self.rawdata = {}
function self.addField(name, value, inline)
_ScanParam({"name", name}, {"string"}, true, true, {1, 256})
_ScanParam({"value", value}, {"string"}, true, true, {1, 1024})
_ScanParam({"inline", inline}, {"boolean"}, false, true)
if not (self.rawdata.fields) then
self.rawdata.fields = {}
end
local field = {}
field.name = name
field.value = value
field.inline = inline
table.insert(self.rawdata.fields, field)
return self
end
function self.addFields(...)
local fields = {...}
for _, field in next, fields do
_ScanParam({"field", field}, {"table"}, false, true)
self.addField(field.name, field.value, field.inline)
end
return self
end
return setmetatable(self, Embed)
end
return setmetatable(Embed, Embed)
with script
local new = mod.new()
new.addField("Name", "Value", true)
new.addFields(
{name = "Name", value = "Value"},
{name = "Name", value = "Value", inline = true}
);
it doesn’t give error, does anyone know why?