My adventure game has a part where the player has to answer a few random questions in order to proceed.
As I have imagined it, I need to create a loop: a "play speech" action where a question is stated, leading to a "start conversation" action with the possible answers (as conversation options), then going back to the "play speech" action as long as the player answers correctly. The speech and the conversation actions must refresh on each loop, picking new content each time from an external file, since there will be tens, maybe hundreds of questions.
Ideally, I'd also like to randomise the order of the conversation options, but this is not 100% necessary.
I searched in the scripting guide a bit but didn't find a straightforward way of editing action contents.
Any leads?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Actions can be modified through use of ActionList parameters, but the Dialogue: Start conversation Action is just a means to activate a Conversation present in the scene. If you want to modify the options available, you'll want to do so by updating the Conversation at runtime - not the Action.
What kind of data are we looking at, exactly, to load in from an external file?
You can modify the Conversation's labels easily enough, but more complex would be the need to update which option is the correct one. I'd imagine the best way would be to rely on an Integer variable (could be Component, could be Global), that is used to record the correct option index - and then each option checks this against itself when run.
Going back to ActionList parameters, you can use these to update the speech Actions with the answers pulled in from the external file.
I'll try to give steps to show what I mean - this'll be for a question with 3 answers.
Here, the speech Actions to show the question and the answers are set to show the parameters created in step 3. Each answer then checks its own index against the Integer parameter to see if it was correct or not.
What we now need is to set:
To set a Global integer variable's value, call:
To set a Conversation's option labels, call:
And to set parameter values, call:
You 're the best! I'm so glad I've paid full price for this asset, I'd feel bad if I hadn't
In case anyone needs to implement the same thing, here's my external code (called via Object: Send Message, just before displaying the question) :