Hi!
Here I am with my over complex issues again.
But, this time I’m kind of stuck on making a Search for my build mode.
How would I do it?
It would search for categories or furniture depending on the attribute
function Building.IndexSearch(Player,SearchContext,Indexed) --SearchConext is explained in the next few lines, this should index the search.
print("Indexing Search Content: "..SearchContext)
if Player.PlayerGui:WaitForChild("?Build"):GetAttribute("MenuOpen") == "Items" then
print("SearchType Items")
else
print("SearchType Categories")
Indexed = false
-------
print("Indexed!")
Indexed = true
end
function Building.DisplaySearch(Player,SearchContext,Indexed)
if Building.IndexSearch(nil,nil,true) then --Pretty sure this wouldn't work
print("Displaying search..")
else
end
end
are you everywhere on the forums?
Can I see an example in the code I would use? My co scripter is asleep I think lol
Because this is in a Module in RepStorage guessing it’s just me
local fruit = {"apple", "pineapple", "banana", "kiwi"}
-- In our example, when we search 'apple' we likely want 'apple' and 'pineapple' to be returned as they contain 'apple'
local search = string.lower("apple") -- Replace "apple" with your search term.
local Return = {}
for _, currentFruit in ipairs(fruit) do
local Lowercase = string.lower(currentFruit) -- Get rid of the pesky upper case letters
local Find = string.find(Lowercase, search) -- Find it
if Find then
table.insert(Return, currentFruit)
end
end
print(Return)
It prints an array with ‘the search term’
Edit: @pyxfluff I updated the code to not require the search term to be lowercase.
Dont know how to make it work with all the functions and stuff, and it’s still kinda early for my co scripter, so idk what’s going on there.
Gonna way for a response.