Reputation: 43
I'm new on the moon and I wonder how I can take a function check if the value contained is on a table.
local extraItem = {
Interior = {from = {1602; 2064; 2070; 2108};
to = {1808; 2065; 2079; 2119};
id = {2034; 2180; 2192; 2594}}
}
local function onOptionChange(widget, optText, optData)
if optData >= 16 then
print(optText)
for a, v in ipairs(extraItem.optText.from) do
for i = extraItem.optText.from[a], extraItem.optText.to[a] do
local widget = g_ui.createWidget('PaletteItem', paletteList)
local itemid = g_things.getItemType(i)
widget:setItemId(itemid:getClientId())
end
end
for a, v in ipairs(extraItem.optText.id) do
local widget = g_ui.createWidget('PaletteItem', paletteList)
local itemid = g_things.getItemType(v)
widget:setItemId(itemid:getClientId())
end
end
end
the print(optText)
print Interior
and extraItem.optText.from
return nul
, how fix it?
Upvotes: 4
Views: 120
Reputation: 72412
Use extraItem[optText]
instead of extraItem.optText
.
extraItem.optText
is equivalent to extraItem["optText"]
.
Upvotes: 2