Help with some text expression editor
jay_
Member, BASIC Posts: 5
Hi guys,
I have some logic in place at the moment that works pretty well which basically detects when a player has successfully reached a certain point with no mistakes, however its quite weighty with stacks of rules. All I want is when player reaches a point display text saying x2, x4, etc. I'm pretty sure there is a way of doing the whole with expression editor in the text behaviour. It could look something like this " i know this is wrong but need help fixing it" (game.score≥5 and ≤10)and("x2")or(0),(game.score≥11 and ≤20)and("x4")or(0) ...
any ideas would be great thanks
Comments
Can you provide a screenshot of your current rule(s) for this? I'm unclear whether you're asking how to create a rule condition or how to display text using a complex expression.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Yeah sorry could of worded this better, the rules I have in place just display text, i.e
when game score is ≥ 10
when game score is ≤ 20
Display text "x2"
if i did this for x4,x6,x8 its a lot of rules
I would prefer to do this all with the display text expression editor i'm just bit stuck with the math. This is what i tried buts its not working...
What are the conditions for x4, x6 and x8 ?
If you are asking whether you can have the conditions and result in one and the same expression box, then the short answer is no.
Doing it for x4, x6 and x8 means three sets of rules? That doesn't seem like particularly that much...
If there is a mathematical relationship between the conditions and the result then you could encapsulate that in a single expression. (if I understand the question)
Yes, that is true. If it isn't arbitrarily set, but there is a mathematical relationship between the two, it's possible.
ok so if I can only use one condition in the text expression, say.. the x2. in my example I attached, It only says when the score = 5, i've tried inputing an in-between like ≥10 ≤20, but I can't seem to get the math right this is what I write but I have no luck with it.
(game.comboStreak=≥10≤20)and("2")or("0"))
Is it possible to do this ?
If it is possible, then the maths will be specific to your particular set up.
What are the conditions for x4, x6 and x8 ?
If it is set arbitrarily, then no, you need the separate conditions (Rules). I still don't understand what your problem is to have several of them.
What you can do in the expression editor, is to use a mathematical relationship.
For example --
set: game.multiplier to: floor(game.comboStreak/10)*2
This will give you a x2 multiplier for 10-19 Streak, a x4 multiplier for 20-29 Streak, a x6 multiplier for 30-39 Streak, etc.
What you can do is set up a table with rows like this:
[text]
x2
x4
x6
x8
...
Then in your Display Text expression figure out a mathematical way to determine which row to use in a tableCellValue function. @pHghost's example right above might do the trick.
In that example, it might look something like this:
Display Text: tableCellValue(tableName, floor(game.comboStreak/10), 1)
Edit: and if all you actually need to display is "x2" or "x4" and nothing else, you don't even need a table:
Display Text: "x"..floor(game.comboStreak/10)
I guess that's what @pHghost was suggesting with game.multiplier which would then go in your Display Text expression.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@jay_
Yes you can do this. The expression would be something like:
Change Attribute: game.myDisplayText To: (((game.score>5)and(game.score<10))and"x2")or((( game.score >11)and(game.score <20))and"x4")or"0"
Be sure to use the pull down menu to specify game.score. (Don't just type it in. And don't copy/paste the above expression.)
Hopefully you can extrapolate what you want from the above expression. But if not, just give us the intended logic and I am sure we will be able to build a functional expression for you.
Edit:
I could not get GameSalad to accept the symbols "≤" or "≥" (at least on my keyboard). You may be stuck using "<" and ">" instead.
This might help.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support