Forum rules - please read before posting.

Trying to create a "reorder the words" correctly functionality

edited November 2017 in Technical Q&A
Hello everyone

I'm new to both Unity and AC, trying to create an educational game.

What will be the best way to go about this:

Some words appear on the screen and need to be reordered so as to make a sentence.

Example :     Australian      I      am .

How I am currently doing it is , I created multiple (in this sentence -three) conversations. If the correct word is selected, the next conversation starts, else the skip option is chosen, that is the same conversation restarts. The sentence starts to form , in the first dialog of the next conversation, everytime the correct word is chosen it gets added (manually) to the first dialog of the next conversation and it is removed from the dialog options. 

Conversation1
Australian
I
am

Conversation2
I
Australian
am

Conversation3
I am
Australian


Play dialogue : I am Australian


Is this a good way to do this or is there a better way?


image of how i am doing it currently

Thanks




Comments

  • edited November 2017
    Welcome to the community, @rushk01.

    Presumably this would be just one of many such sequences in your game, so you'd want the Actions involved to be as simple as possible, and ideally rely on just one Conversation.

    If it's necessary to have the first line of the next Conversation show the "already chosen" words, you'd probably be best off by just re-writing the conversation labels as you go.  This can be done with the Dialogue: Rename option Action.  You can also hide options from view with Dialogue: Toggle option.

    I'd say generally this kind of thing would be made much easier by incorporating some simple scripting.  Building sentences like this isn't totally aligned with what Conversations are intended for, so trying to achieve this with AC on its own could well be more trouble than its worth.

    If the intention is for the "sentence" to be added upon with each label the user picks, you should consider storing the sentence in a String Global Variable, which you can then display in a character's speech using the [var:X] token (see the "Custom tokens" chapter in the Manual).  Adding a Conversation's label to a string doesn't take much code:

    using UnityEngine;
    using System.Collections;

    public class AddLabelToVar : MonoBehaviour
    {

        AC.Conversation myConversation;
        int stringVariableID;

        public void AddLabelToStringVariable (int dialogOptionIndex)
        {
            string chosenLabel = myConversation.options[dialogOptionIndex].label;
            string stringValue = AC.GlobalVariables.GetStringValue (stringVariableID);
            AC.GlobalVariables.SetStringValue (stringVariableID, stringValue + " " + chosenLabel);
        }

    }


    You can add that to a GameObject in your scene, and use the Object: Send message Action to call it's "AddLabelToStringVariable" function, passing the chosen option index value as a parameter.

    For more on using scripting to work with AC, see the Scripting Guide.
  • Hi, thanks I am really having a great time using AC, I do not have any background in coding, my regular work is taxation and accounting. Before AC I read the Unity Manual, tried other Assets, watched some videos, took a small C# course but everything seemed so inaccessible.
    When I saw the 2D tutorial of AC, unity became much more clearer. 



    The intention is not for the sentence to be added upon with each label the user picks. The sentence should be added to ,only when the correct label is picked. If a wrong label is picked nothing happens, so that the player tries another word, Eventually they will end up forming the sentence correctly. 


    It seems to be working with the original method of creating multiple conversations, however in my game, I am thinking of creating many scenes, because each sentence has a different image (like a comic , where 1 scene is one panel). So , is this method of creating multiple conversations for each scene unadvisable?

    I tried the Dialogue:Rename and Dialogue:Toggle Options too and that is also working.

    1. Which one of the above is more advisable?in the end there will be a thousand sentences. I am also very interested in trying out code if that is better.

    2. In the example the correct order is I  am Australian (1 2 3)
    But i have ordered them as , Australian I am.  (3  1 2)
    So maybe I should create, different permutations and then reuse these for the next sentences ? Or is there a better way to do this ?

    3. Is there a way , that once a sentence is solved, it remains on the screen? Is there a way that it remain on screen even after scene changes and then this scene is revisited ?

    4. I also tried sending the completed sentence to  another new menu I created. This menu has element : input box and I set this to display the completed sentence. However this too disappears after displaying. 


    Sorry for so many questions and thanks for making such a fun to use software.





  • 1. If you're looking into a thousand sentences, then you certainly want to minimise the number of Conversations / work involved for each one.  This may involve custom coding in parts, but smart use of variables and ActionList parameters may also help here.

    ActionList parameters allow you to "recycle" Actions by changing their fields at runtime (a tutorial can be found here), however I would recommend first simplifying your first sentence before tackling this.

    2. This is similar in behaviour to a "keycoded lock safe" then.  A number of threads on this can be found by searching the forum, but essentially it works by increasing a "score" variable each time the user presses the right option and the right time.  A couple of examples:

    https://www.adventurecreator.org/forum/discussion/5145/puzzle-type
    https://www.adventurecreator.org/forum/discussion/550/need-help-with-coded-lock

    You should be able to use this in conjunction with the same Conversation object to create such a sequence.  I'd recommend getting the win/lose logic set up first before tackling the actual display labels.

    3. A sentence can be displayed on screen forever with the [hold] token (see "Text tokens" in the Manual).  This doesn't survive scene changes, however.  For that, you would have to manually re-show it via your scene's OnStart cutscene.

    4. Disappears when after displaying?  Is it showing correctly in your Variables Manager at runtime?  I think it'll be necessary to see related screenshots here.
  • edited November 2017
    I tried it  using local variables and referencing these variables when using toggle and rename options and it is better now. 

    However I wanted to try a different approach of setting these variables  in the text field of the Button Element of new Menus I created. So that I can scatter the words across the scene, thus solving two problems , that is random order of the words and may look nicer.

    But Button Text cannot use local variables ? Or am I missing something?


    Will also try out the other methods suggested above
  • Buttons cannot currenly use variable tokens - only labels.  However, I think this would be a good addition so I'll address this in the next update.
  • Thanks 


    I have been trying some methods to achieve the rearrange the words function, there is some progress but still lots to learn. I am trying out a combination of action list assets with parameters and it feels really close to the solution now.  I I have a few  other questions, will post  as separate threads as they are about different different functions.


    4. Disappears when after displaying?  Is it showing correctly in your Variables Manager at runtime?  I think it'll be necessary to see related screenshots here. 
       This was a mistake from my end it is ok now.


  • Buttons now accept tokens in the current update - v1.60.4.
  • Thanks, that was fast!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.