Making a searchable database

Hello!

I am currently trying to port over a game I made to Gdevelop. It is a detective mystery game.

One feature of the game is the Police Database. It allows players to look up names and see where to go next.

You can see it in action here: www.mystery.city/police

Essentially, it’s a switch case. If name = PersonA, then print ResultA

I’m sure there is an easy way to do this in Gdevelop. The only way I have tried so far was to compare the text in the search box. However, that is case sensitive and it will take me forever to do the whole list of names.

Does anyone have any good ideas?

I am thinking about using structure variables for this:

http://wiki.compilgames.net/doku.php/gdevelop5/all-features/variables#structure

Right click your scene, go to Scene variables.

Inside the scene variables add a variable called “PoliceDatabase” or anything. Next, click the wrench/spanner icon and choose convert to structure

Now you can use the plus icon to add child variables to the database. The name of the child variable can be the search term. The value of the variable can be the text you want that search to return.

When the user click search, you can lookup value of the child variable based on the text of your search box.

To remove case sensitivity, there is a function under text manipulation (the button next to the values boxes labelled “ABC” in the event editor) called “lowercase the text”. You can use that to change the search text to all lowercase letters no matter what. As long as you only use lower case letters inside your child variable names, to the player it will seem like the search is not case sensitive

1 Like

Thank you! I’ll give it a go!

I already have it written up in Javascript (you can see it at www.mystery.city/police) but I couldn’t figure out how to properly integrate it. You wouldn’t have any ideas for that, would you?

How have you made it in JavaScript? Where and how is that database stored on that version?