Possible to create a search function?

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • So, is there a way to build a search bar into a game? Say a player collects tons of items, maybe instead of scrolling through all the items they could use a search bar to find the item they're looking for? Or even further, a keyword search that could show items with certain words contained in the description?

    I know it sounds odd, but I'd like to know if this is possible in C2. Thanks.

  • Yes, search functions are possible... but I think perhaps only with NWjs?

    I've used C2 with NWjs before to make some Point of Sale (POS) software - which has a search feature to find products in the database, or customer information etc.

    I'm not entirely sure if any search can easily be done without using NWjs, though I'm also probably wrong about that. lol


  • You can do it with any exporter if you use the "find()" expression with some specific keyword.

    It all depends on what data structure you are using (arrays ? dictionaries ?...), cycle through them with a function and try to find(keyword).

    Find() is a text system expression.

    So yes it is possible to create a search function, whatever the export you use is.

    It nevertheless depends on the type of data structure you are using and so depends on the implementation of your project.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you are using Arrays for your item collection...you could use the Actions

    "Contains value"

    This searches the entire array to check if any of the elements contains the given value. For example, you can use this to test if the string "sword" is stored anywhere in the array.

    "For each element"

    A repeating condition that runs once for each element in the array. This therefore runs width x height x depth times.


    "Compare current value"

    Only valid in a For each element loop, either as a following condition or in a sub-event.

    These actions might help you..using a Textbox for search input

    Event---> Textbox >On text changed-->

    Action1--> Array>For each element -->

    Action2--> Compare current value (Textbox.text)

    Event--> Array.CurValue = (Textbox.text)

    Action--> whatever you want to happen

    or something like that

  • Great I will do some tests. Thank you!

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)