Skip to main content

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

So basically you'd want to have counters for each result tracking each time they're picked - so like starting them all at 0 and then adding 1 each time the answer is picked. I like to use sliders for storing numeric values with a constrained range - since you know the maximum value possible is 5 as there's only 5 questions in the hypothetical you'd just need a range from 0 to 5.  You can put the sliders on a hidden card that the player won't ever see. Then let's say you have a button for each answer on a card and and you can put something like this in the "on click"

cardwithsliders.widgets.slider1.value: cardwithsliders.widgets.slider1.value + 1
go["question2"]

And then at the end you'd just need to check which slider has the highest value and go to an appropriate ending page. There may be a smarter way to do this but it's early here so I'd just go with like a bunch of if statements.

if (cardwithsliders.widgets.slider1.value > cardwithsliders.widgets.slider2.value) & 
   (cardwithsliders.widgets.slider1.value > cardwithsliders.widgets.slider3.value) &
   (cardwithsliders.widgets.slider1.value > cardwithsliders.widgets.slider4.value)
 go["ending1"]
elseif #all the other ways around
end

(apologies if any of my code is wonky, I'm just writing this off the top of my head haha)

You may not have much of a programming background but dabbling in stuff like this is a great way to learn! If you can work out the logic in a "do this then do that" and "if this then we do this, otherwise we do that" then it's just a matter of translating it into the syntax you need

(+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.