How do I check a key input sequence with midpoint fails?
So right now, the PlayerActor is basically on rails, and there's a queue of obstacles.
I want to require the player to input a key sequence to destroy the obstacle, but have it vary by obstacle.
If the player botches the sequence, they should take damage.
But I have no idea how the step-by-step validation would be structured in Game Salad.
Like, I want the player to need to hit Up then Down for the first door, but Up Up Down for the next door without it having been pre-loaded by the inputs for the prior door. Right now I'm controlling that with the Collision behavior, so that only the door which the player is next to watches the input sequence.
But, I'm drawing blank on how to check a sequence.
My brain is saying "Have a Step1Complete Boolean you turn on and/or a Step1Wrong Boolean to trigger the health loss" but then I'm getting confused with how to break that up across the Do/Else in a single ruleset. As best I can tell, if I put each step in its own rule, it's going to check each point of the sequence on each key input. I've looked at some Simon-esque stuff, but I don't have the same degree of compartmentalization as the four different actors provide.
Is there something with hidden actors I could do?
Comments
@Moik,
fill an attribute with the actions, each added to the beginning.
ActionsPressed = NewAction..ActionsPressed
Then at the relevant door, use the text functions to check if the first n characters(Actions) correspond to the key.
So:
User presses U, D, U, U, D
The string ActionsPressed will contain "DUUDU"
Lets say the KeyValue is "DUU" (note:reverse order since actions get added to the beginning. This makes the check below simpler.)
Now use
textSubStr(ActionsPressed,1,textLength(KeyValue))
to get the relevant characters and see if they contain the key.
If it does, unlock door and remember to empty the ActionsPressed string.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch Okay, yeah. I for sure would never have thought of any of that. This is my first experience with the text options.
(Q1) I've gotten as far as the setup for the textSubStr; but I'm not sure where I use it.
My gut says its supposed to go into the Conditions with the Key-Press and Collision, but checking the pattern there would cause a fail right off the bat. Unless, does this only check somehow based off inputs since the last destroy/since the collision began?
I guess part of where I'm getting lost is it sounds like ActionsPressed could contain hundreds or thousands of letters after a long play session. Is there a point where it resets on its own? Is there a place I can reset it? Does the function go off the same whether or not the ActionsPressed has been blanked? (I don't know how to blank it. Just leave the other part of Change Attribute un-edited?)
(Q2) Probably the other part I'm getting lost on is; what does that system use as reference to check the correct pattern? I'm assuming I can just store them in a table somewhere, and the active door simply pulls the cell value into a holding attribute for checking.
Thanks for the help! The forum needs a Gild option like reddit.
@Moik
(Q1) Yes, it goes in a rule:
(text expression) textSubStr(....) contains KeyValue
(Q2) The pattern corresponding to a specific door/obstacle can be stored in a table. So the KeyValue for door 2 might be
tableCellValue(T_KeyValues,doorNumber,1)
Clearing out the attribute: I mentioned above that the ActionesPressed attribute should be cleared once a valid sequence was found.
Whether it should be cleared out more often very much depends on the details of your game:
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
So basically attached is what I've done. These are all on the first Door actor.
The flow isn't meshing in my head. I'm not sure where I would toss in the stuff to Destroy Actor. Normally I would put it in the Do section, but all the Pattern stuff is going on there. Is this what you were suggesting, or have I botched the sequence?
@Moik
how does the player know what to press? Does the game show the sequence?
If it is like a quicktime event we may be able to make it even easier.
Would the following be the way you intended?:
The Key is lets say "add"
So the player starts off pressing "d", which is wrong and takes damage.
Now the player presses "a", which is good.
Next "d", also good.
Next "a", wrong and takes damage.
Next "d", good, sequence completed and moves on.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
The game won't show the sequence on a case-by-case basis, the Help will show which obstacles use which pattern. The player needs to memorize them and pass through a number of the obstacles quickly, almost like a hurdles race where the hurdles need different kinds of jumps.
What you described about a fault-tolerant/progress-retaining pattern would make sense in the game's themes since it's more of a 'breaking down the wall' kind of obstacle. It does seem more like what I'm trying to get as an end effect. Resetting the pattern midway wouldn't make as much sense. If you need "add" but go "ada", it would be weird to keep the player still needing to "ad" again.
@Moik,
to be clear, as per your last example, if the player pressed "ada", he would only need to add a "d" to complete the sequence?
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Correct.
@Moik, ok gimmy a few minutes.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Moik, still there?
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch Yup!
[Edit: Actually, half hour difference. Maybe that doesn't count any more.]
@Moik, made a demo project, do you want to hop on skype to walk you through it?
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Shore!
@Moik I will PM you my skype id
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com