HypeConditionLinker: Perform actions based on AND/OR conditions without JavaScript code

Interaction based on linked Conditions without scripting.
a testproject

that’s what’s possible:
linking conditions by “and” -> every condition must be met
linking conditions by “or” -> any condition can be met

When the count of triggered (running custombehaviors as hype-behavior) conditions is equal to the count of linked conditions the result will be examined and a predefined hype-custombehavior will be triggered.

////////////////
A scene or file can have several hypeConditionLinker-instances

To setup an instance you’ve got to add some data-attributes to an hypeelement:

data-logic-namespace -> the unique name for the instance
data-logic-if ->  a string that lists some custombehaviornames that are linked eather by "_and_" or "_or_"
data-logic-then -> a string that represents a custombehaviorname to be triggered*
data-logic-else -> a string that represents a custombehaviorname to be triggered

optional
data-documentwide -> a string: true. if set the instance will persist on scene changes

*when linking the instance with "_or_" data-logic-then is obsolete. instead a custom behavior will be called that includes the solved conditions as a name (-> condtionOne_conditionTwo_conditionX)

Feed an instance:
to feed an instance with a condition set up an empty custom behavior whose name includes the namespace of the instance and the current condition divided by a pipe -> namespace | condition
trigger this custom behavior from any in hype possible behavior … (timelinebavior, click, scene load …)

that’s it :slight_smile:

////////////

i guess this seemed more complicated than it is … :slight_smile:

the attached file will show a setup that combines two multiple choice questions to one unit. the result will be displayed in the last scene.

https://www2.aachener-zeitung.de/zva/karlo/test/HypeConditionsLinker/

hope it’ll work! :slight_smile:

HypeConditionsLinker.hype.zip (68.3 KB)

7 Likes

Is there a reason you minified the code? Makes it harder to quickly evaluate it. Is this already production ready? I looked at the logic part and I like the use of a setter and a conditional behavior trigger. As discussed, I’d also like to put this in my export script as most people don’t use them anyway I’d leverage the UI possibility. Do you mind if I add something similar to my current development?

1 Like

When I do not fill out the requisite number of answers in a scene there is no verification happening.

1 Like

you mean hitting next before doing the quiz¿ and then there is no notification at the end?

that’s true. every instance assumes all parts to be completely filled.
i should have blocked the next-buttons until its solved … my bad :slight_smile:

though you could bypass this, if you want, by triggering the expected behaviors on the next-button itsself.

anyway, thx for reporting, because it shows the script-intention:
just doing the logic part and let procedure/functionality to the user

////////////

Edit: i replaced link and file. now the next-buttons are disabled until a quiz is done.

2 Likes

it's been a test of functionality, forgot to switch back ... thx, i'll do so

hey Max, it's a playground! looking forward to it :slight_smile:

2 Likes

A small light-bulb-game.
Built experiences based on linked conditions without custom scripting.

https://www2.aachener-zeitung.de/zva/karlo/test/light-bulb-game/

light-bulb-game.hype.zip (65.4 KB)

6 Likes

there's been a question regarding a parental gate that takes three numbers entered in the right order:

Here is a solution using the HypeConditionLinker
https://www2.aachener-zeitung.de/zva/karlo/test/Parental_gate/

This time it's triggered by a few lines of code. just to show it's extendable.
Parental_gate.hype.zip (28.8 KB)

///////////////////
Note: added a new feature to the script so that it can test for the right order too. to achieve this just add data-logic-mode-strict -> true as additional data-attribute for the instance. <- just avaiable for "and"-conditions ...

1 Like

https://www2.aachener-zeitung.de/zva/karlo/test/senso/

playground for this evening :slight_smile:

based on HypeConditionLinker.

in englisch it’s been called simon: https://en.wikipedia.org/wiki/Simon_(game)
some of you may remember it :slight_smile:

really not well tested. I’ll rework and post it after the holidays :slight_smile:

4 Likes

Hi @h_classen:
I like reviewing all the various forum examples and noticed that you created a Simon game in the past. Would it be possible to have you upload the .hype project file to share?

Thank you!
Patrick McLean

senso.hype.zip (95.4 KB)
it's been a playground for webaudio whose support by browsers may differ ... as far as i can remember it was ok on chrome :slight_smile:

//////////////////////////////
reworked it with howler.js, so it should work on all newer browsers now :slight_smile:
sensofit.hype.zip (192,5 KB)

https://www2.aachener-zeitung.de/zva/karlo/MHA-Charts/2022/sensofit/sensofit.html

2 Likes

Thank you for sharing the example!

Patrick

Hello, Hans @h_classen!
I would like to ask for your support - if it possible - to have the Parental gate functional using also keyboard not only the mouse click.
I don't know how to use the function "number" from keypress...
Thank you!

	document.addEventListener("keydown", function(e){
	
const eventKeys = {

'1' : 'one', 
'2' : 'two',
'3' : 'three',
'4' : 'four',
'5' : 'five',
'6' : 'six'
}

let currKey = eventKeys[e.key];

if(typeof currKey === "undefined") return

	let custombehavior = "parental_gate | " + currKey;
	hypeDocument.triggerCustomBehaviorNamed(custombehavior);
	
	});

you can place it onsceneload

1 Like