Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+5)

Supposing you have several sliders on a card:


The easiest way to find the slider with the highest value would be to write a query which sorts the sliders by value (descending) and then extract their names:

extract value..name orderby value..value desc from likesDogs,likesCats,likesFish,likesChickens

In the above example, this would yield a list of widget names like so:

("likesChickens","likesDogs","likesFish","likesCats")

The "first" of such a list would be the highest-ranked (with ties naturally broken in order of appearance).

(+3)

Thank you both for the reply. I honestly was completely defeated by these responses and felt way in over my head with the programming, but I’m going to try again with your feedback.

(+2)

If you find yourself struggling to apply these ideas, let us know what you've tried and I can create a more complete example for you to study and tinker with. There are a fair number of concepts at play, but you don't need to learn everything at once. :)

(1 edit) (+1)

I’ve actually had the structure in place for some time. I have each question on a separate card, a counter card with the sliders that count up based on the answers, as well as a button (btnResult) on the final question that (on click) runs the query you recommended.

The problem is, I don’t really know how to finalize it. How would I take the highest value returned by clicking the button and use that result to navigate to the intended “quiz result” card?

(+2)

You could make a dictionary that maps slider names to result cards and "go[]" to the card corresponding to the top-ranked result:

on click do
 sliders:likesDogs,likesCats,likesFish,likesChickens
 order:extract value..name orderby value..value desc from sliders
 results.likesDogs:"TheDogCard"
 results.likesCats:"TheCatCard"
 results.likesFish:"TheFishCard"
 results.likesChickens:"TheChickensCard"
 go[results[first order]]
end

If your quiz result cards are named to correspond to the sliders, you could skip the dictionary and "go[]" to a card by name:

on click do
 sliders:likesDogs,likesCats,likesFish,likesChickens
 order:extract value..name orderby value..value desc from sliders
 go[first order]
end

(Using consistent naming conventions for cards and widgets can often make scripts a good bit simpler!)

If the sliders aren't on the same card as the result-calculating button, you'll need to reference them through their container card. Say the card with the counters is named "counters":

on click do
 sliders:counters.widgets.likesDogs,
         counters.widgets.likesCats,
         counters.widgets.likesFish,
         counters.widgets.likesChickens
 order:extract value..name orderby value..value desc from sliders
 go[first order]
end

Or- more concisely-

on click do
 sliders:counters.widgets @ "likesDogs","likesCats","likesFish","likesChickens"
 order:extract value..name orderby value..value desc from sliders
 go[first order]
end

Or, if the sliders are the only widgets on that card:

on click do
 sliders:range counters.widgets
 order:extract value..name orderby value..value desc from sliders
 go[first order]
end

Does that help at all?

(1 edit) (+3)

Oh my god, thank you! That first one is exactly what I needed. I was missing the “results” part of each line but had figured the rest out. I really appreciate your help; the documentation for the coding language is great, it’s just very overwhelming to me for whatever reason.

I will try these solutions tonight and report back.