Help building a condition-based logic generator
Hi everyone, just getting to grips with Perchance, love the functionality and simplicity. Not a coder, so coming at this as a newbie.
I'm trying to build a dental patient generator for students to practice diagnosis on. I've got a simple version working: https://perchance.org/91ba5azokj But I need some condition-based logic so that the relevant variables only apply to the front or back tooth.
Front tooth If UL1 or LR2, it can link with:
• Mesial, Distal, Buccal or Lingual/Palatal • Composite or Glass Ionomer Cement • Any medical history • Any presenting complaint • Any ‘other’ item
Back tooth If UR6, UR4, LL6 or LR7, it can link with:
• MO, DO, MOD • Amalgam or Composite • Any medical history • Any presenting complaint • Any ‘other’ item
I can't see how to build this with the plug-ins I've explored and having read the tutorials (a few times!). Any tips? I've got the information for the medical history, presenting complaints and other items to add later.
https://perchance.org/91ba5azokjOpen linkView original on lemmy.world
Here is a modified generator.
So first, we store the selection from the
toothlist in a variable calledx. We use.evaluateItemon thetoothso we can have the 'string' / evaluated form of the item i.e. a text without the perchance syntax.What we have on the
surfacelist is what we call Dynamic Odds. Basically, it modifies the odds of the items in the list depending on the 'condition' that is on the odds. Essentially a 'If/Else' statement to control the odds/probability of an item to be chosen.In this case, we use the value on the variable
xand check if it 'includes' a certain string, which would be your conditions 'UL1' and 'LR2'.On the first three items:
We use the native JavaScript method
.includes()to check if the value onxincludes a certain string, in this case it is checking for 'UL1' and 'LR2'. However, we are using the!or 'NOT' notation to invert it, so we are checking if the string doesn't contain the following strings. We then use the&&or 'AND' notation to only return a 'true' statement if and only if BOTH conditions are true.In this case, it would be true if
xdoesn't includeUL1ANDLR2. Which means other thanUL1andLR2, the engine wouldn't be able to 'pick' those first three items unlessxdoesn't includesUL1andLR2On the last items:
We do the opposite, we only allow the engine to select those items ONLY if
xhasUL1ORLR2. The||is the OR operator in which it would return 'true' if only one of the items are 'true'.I also added on the generator my 'debugging' utilities in which you can see the how the 'odds' are on the items depending on the value on
x.Here are some resources to read:
.includes()Thank you VioneT and allo for taking the time to help me with this. Very much appreciated, and for the supporting resources.
https://perchance.org/hmz8js3o3v
i'd say Vione's is basically 'the right way' and i made a noob one, but maybe my noob one will help :)
it isn't really condition based logic like in real time like you are implying and vioneT answered. It's more just splitting your types of things in to a box for each type of thing. Also I noticed you had all your lists referenced only in output, but you can reference a list in a list as you see i did with how tooth then is either a back or front tooth and then back tooth has it's lists and front tooth has it's lists and they are different from each other. edit: touch edit to see what i did. idk teeth so i made up my own surface types and such.