diff --git a/client/creation.lua b/client/creation.lua index 6b7c3e0..533b5d9 100644 --- a/client/creation.lua +++ b/client/creation.lua @@ -21,6 +21,7 @@ local function IsBlacklistedString(text) return false end + for _, v in pairs(items) do if not IsBlacklistedString(v.name) then table.insert(item_select, { @@ -243,33 +244,62 @@ local function openCraftingTable(id) description = "Create new item for this crafting table.", icon = 'circle', onSelect = function() + local FilterData = { + useFilter = false, + filteredData = {} + } + :: BackToFilter :: + local showedItems = {} + if FilterData.useFilter then + for _, filterWorld in pairs(FilterData.filteredData) do + for _, item in pairs(item_select) do + if string.find(string.lower(item.label), string.lower(filterWorld)) then + table.insert(showedItems, item) + end + end + end + else + showedItems = item_select + FilterData.filteredData = {} + end local input = lib.inputDialog('Select item and ingedience', { - { type = 'select', label = "Main item", description = "This is the item you want to crafting.",required = true, options = item_select, clearable = true }, - { type = 'multi-select', label = "Ingedience", description = "Required",required = true, options = item_select, clearable = true }, + { type = 'textarea', label = "Filter - Filled search / Unfilled saves", description = "Write the labels of the items you want to filter. Separate them with ,",required = false, placeholder = "Meat, Fish, Bone", clearable = true }, + { type = 'select', label = "Main item", description = "This is the item you want to crafting.",required = true, options = showedItems, clearable = true }, + { type = 'multi-select', label = "Ingedience", description = "Required",required = true, options = showedItems, clearable = true }, }) - if input then - - local defineIngedience = {} - for _, selectedIngedience in pairs(input[2]) do - table.insert(defineIngedience, { - itemName = selectedIngedience, + if tostring(input[1]) ~= "" then + local searched_value = tostring(input[1]) + FilterData.useFilter = true + for word in searched_value:gmatch("[^,%s]+") do + table.insert(FilterData.filteredData, word) + end + goto BackToFilter + end + if input[1] == "" then + if input then + + local defineIngedience = {} + for _, selectedIngedience in pairs(input[3]) do + table.insert(defineIngedience, { + itemName = selectedIngedience, + itemCount = 1, + }) + end + + local newTable = { + itemName = input[2], itemCount = 1, + ingedience = defineIngedience + } + table.insert(selectedJob.craftings[id].items, newTable) + TriggerSecureEvent("pls_jobsystem:server:saveJob", selectedJob) + lib.notify({ + title="New recipe created", + description="Congrats! New recepie has been created.", + type="success" }) + openCraftingTable(cached.crafting_table_id) end - - local newTable = { - itemName = input[1], - itemCount = 1, - ingedience = defineIngedience - } - table.insert(selectedJob.craftings[id].items, newTable) - TriggerSecureEvent("pls_jobsystem:server:saveJob", selectedJob) - lib.notify({ - title="New recipe created", - description="Congrats! New recepie has been created.", - type="success" - }) - openCraftingTable(cached.crafting_table_id) end end, })