ID:1695602
 
Keywords: library, search
I want to create a way of searching a library or a list of items. Something like an advanced search box that would display items based on relevance of the input. Not sure where to start. It would implemented into the interface. though.
mob
proc
FindUser()
var/resultList = list()
var/myInput = input("Who are you looking for?") as null
for(var/mob/M in world)
if(findtext(M.name, myInput))
resultList += M

var/mob/ChooseMob = input("Are these people who you are looking for?") in list (resultList)
ChooseMob << "[src] was looking for you."


mob/Login()
FindUser()



Just a lazy example. Although, looping through all of the mobs in the world is generally considered bad practice. Basically, what this does is check to see if what you typed will fit into the names of any mob in the world. If so, store it into a list that you can select from.
I'm sure you could use an SQLite database to really efficiently get search results. I'm not experienced with SQLite or how DM uses it, but you could look up SQLite text search examples somewhere else on the internet.
I want to output the list of results on the screen like in an output.
In response to LongCat666
good example give me something to start with