How do I Append Forward and Backwards

0 favourites
  • 11 posts
From the Asset Store
* Fully animated rat four directional game sprite *
  • Weird title (as I know we cannot *de-pend*), but what I'm trying to do is write a profile for a character that is based on various ratings. Each ratings type (happiness, intelligence, etc.) has a number that's generated, and based on that number, I create a paragraph pulling a sentence from each ratings category.

    This works really well by appending the phrases together, but as the character's ratings change, appending just keeps adding but never subtracting.

    So how would I go from "This character is really happy. They are super smart!" to "This character is miserable. They are super smart!" without it coming out as "This character is really happy. They are super smart! This character is miserable."?

    I hope that makes sense. It might also help to clarify that I want all of this to appear in one text box, not a series of text boxes, as I want it to read like a paragraph and not like a bulleted list.

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You would concatenate the entire paragraph each time it updates instead of appending.

  • Could you please help me understand how to do that? Is concatenate a built-in action?

  • "string 1" & ", " & "string 2"

    Ect.

  • Do I need to put the strings in " "? Sorry, I'm not a coder. I have this, and while it's pulling in the two strings next to each other, it's not creating a space in between.

    WriteUpOverall & " " & WriteUpDraftHype

  • That looks correct to me, and indeed how you would add a space between the two.

  • Another option is to use replace() expression and custom tags. For example:

    Variable template=This character is {rating}.
    Variable characterRating=super smart
    
    Set text to replace(template, "{rating}", characterRating)
    

    You can nest multiple replace() inside one another:

    Variable template=This character is {rating}. They are {mood}!
    Variable characterRating=super smart
    Variable characterMood=very happy
    
    Set text to replace(replace(template, "{rating}", characterRating), "{mood}", characterMood)
    
  • That looks correct to me, and indeed how you would add a space between the two.

    Yeah, I dunno! I swear it worked before, but how you can see how the sentences are not spacing out in that little player writeup part.

  • Could it be because I'm using dictionary? Remember, total noob here :)

  • The last action looks correct, there should be a space between the two sentences. Maybe you have some other event which merges the same two strings without a space?

  • Yep it was an error later on in the actions. Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)