Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+3)

I really like the slider suggestion. A nice thing about it is that you can go to that card and manipulate the sliders yourself to test your logic, or hop over while going through your quiz to see that the sliders are as you expect.

Here's a card. If you copy this and paste it into a deck, it'll add a new card with three sliders, a personality field, and a grid of tests and results:

%%CRD0{"c":{"name":"home","script":"on quiz do\n on f t do eval[t (\"cat\",\"dog\",\"duck\") dict (cat,dog,duck)..value] end\n p:first extract result where (f@test)..value from logic.value\n personality.text:\"\" fuse \"You \", p\nend","widgets":{"cat":{"type":"slider","size":[100,25],"pos":[80,32],"script":"on change val do\n quiz[]\nend","interval":[0,5],"format":"cat: %f","style":"bar"},"dog":{"type":"slider","size":[100,25],"pos":[80,64],"script":"on change val do\n quiz[]\nend","interval":[0,5],"format":"dog: %f","style":"bar"},"duck":{"type":"slider","size":[100,25],"pos":[80,96],"script":"on change val do\n quiz[]\nend","interval":[0,5],"format":"duck: %f","style":"bar"},"personality":{"type":"field","size":[192,16],"pos":[224,64],"value":"You are an animal hater?!"},"logic":{"type":"grid","size":[448,160],"pos":[32,160],"bycell":1,"format":"ss","value":{"test":["0=cat+dog+duck","(0,0,1)~0=cat,dog,duck","(0,1,0)~0=cat,dog,duck","(0,1,1)~0=cat,dog,duck","(1,0,0)~0=cat,dog,duck","(1,0,1)~0=cat,dog,duck","(1,1,0)~0=cat,dog,duck","15=cat+dog+duck","1"],"result":["are an animal hater?!","only like mammals","only dislike dogs","only like cats","only dislike cats","only like dogs","only like ducks","are a true friend to all creatures","have unexpected tastes! Sorry!"]},"row":6,"col":1}}},"d":{}}

Room for improvement: if you like all the animals just a little, like 1,1,1, then the personality is "You have unexpected tastes! Sorry!". Also, if you change the logic table so that three different tests all pass, then you still only get the first result. You could check the number and do something about ambiguous results like that.

Or, maybe that quiz code is too clever. Here's something else that still uses that logic grid:

on quiz do
 vars.cat:cat.value
 vars.dog:dog.value
 vars.duck:duck.value
 i:0
 while i < count logic.value
  test:logic.value[i].test
  if eval[test vars].value then
   personality.text:"" fuse "You ", logic.value[i].result
   i:count logic.value # stop here
  end
  i:i+1
 end
end

And, here's a totally different way to do it:

%%CRD0{"c":{"name":"card1","script":"on quiz do\n personality.text:\"You have unexpected tastes! Sorry!\"\n (extract value where \"button\"=typeof@value from card.widgets)..event[\"click\"]\nend","widgets":{"cat":{"type":"slider","size":[100,25],"pos":[80,32],"script":"on change val do\n quiz[]\nend","interval":[0,5],"format":"cat: %f","style":"bar"},"dog":{"type":"slider","size":[100,25],"pos":[80,64],"script":"on change val do\n quiz[]\nend","interval":[0,5],"format":"dog: %f","style":"bar"},"duck":{"type":"slider","size":[100,25],"pos":[80,96],"script":"on change val do\n quiz[]\nend","interval":[0,5],"value":5,"format":"duck: %f","style":"bar"},"personality":{"type":"field","size":[192,16],"pos":[224,64],"value":"You only like ducks"},"button1":{"type":"button","size":[96,32],"pos":[32,160],"script":"on click do\n if me.value:0=sum (cat,dog,duck)..value then\n  personality.text:\"You're an animal hater?!\"\n end\nend","text":"likes none","style":"check","value":0},"button2":{"type":"button","size":[96,32],"pos":[144,160],"script":"on click do\n if me.value:(1,0,0)~((cat,dog,duck)..value)>0 then\n  personality.text:\"You only like cats\"\n end\nend","text":"only cats","style":"check","value":0},"button3":{"type":"button","size":[96,32],"pos":[32,208],"script":"on click do\n if me.value:15=sum (cat,dog,duck)..value then\n  personality.text:\"You're a true friend to all creatures\"\n end\nend","text":"loves all","style":"check","value":0},"button4":{"type":"button","size":[96,32],"pos":[144,208],"script":"on click do\n if me.value:(0,1,0)~((cat,dog,duck)..value)>0 then\n  personality.text:\"You only like dogs\"\n end\nend","text":"only dogs","style":"check","value":0},"button5":{"type":"button","size":[96,32],"pos":[144,256],"script":"on click do\n if me.value:(0,0,1)~((cat,dog,duck)..value)>0 then\n  personality.text:\"You only like ducks\"\n end\nend","text":"only ducks","style":"check","value":1},"button6":{"type":"button","size":[96,32],"pos":[256,160],"script":"on click do\n if me.value:(0,1,1)~((cat,dog,duck)..value)>0 then\n  personality.text:\"You only dislike cats\"\n end\nend","text":"all but cats","style":"check","value":0},"button7":{"type":"button","size":[96,32],"pos":[256,208],"script":"on click do\n if me.value:(1,0,1)~((cat,dog,duck)..value)>0 then\n  personality.text:\"You only dislike dogs\"\n end\nend","text":"all but dogs","style":"check","value":0},"button8":{"type":"button","size":[96,32],"pos":[256,256],"script":"on click do\n if me.value:(1,1,0)~((cat,dog,duck)..value)>0 then\n  personality.text:\"You only like mammals\"\n end\nend","text":"all but ducks","style":"check","value":0}}},"d":{}}

This has the same sliders and personality field, but the 'quiz' just clicks every button on the card. Each button is a checkbox that sets itself to the value of a test and sets the personality if that value is true. This method makes the logic a little harder to see, as it's in each individual button, but when messing with sliders you can directly see what tests succeed or not, and with meaningful button names you could have other cards perform logic based on what's checked so far in the quiz

Thank you so much. These have been most helpful to me, as I’m a “see something already implemented and then tweak” kindof learner.