How do I do to "subtract" appended text?

  • I'm using "append" to add sprite's IID to a text objet when the sprite was touched and I need to remove the appended text when the players return his finger to previous sprite.

    Touch > is in touch
    _____Touch > is touching sprite > text  append str(sprite.IID)
    _____System > Trigger once
    
    [/code:1u198616] 
    
    Thanks in advance for any help.
  • You don't.

    You just set the text to what it was previously.

  • Using variables I presume. I don't imagine how to set the new and the old text and mainly how to control when the finger returns to the previous sprite. Could explain to me how can I do it?

  • I simulated this condition in a capx and I hope someone can help me to solve it. Thanks in advance.

    https://www.dropbox.com/s/e6eru93spgm5h ... .capx?dl=0

  • no help?

  • What you did seems fine to me.

    Then again I have no idea what you mean by removing text.

    You can't subtract from a string unless you do something like use the replace() expression, and replace the text with ""

    https://www.scirra.com/manual/126/system-expressions

    I don't really suggest using text to do comparisons, but whatever floats your boat.

    Likewise I really don't suggest using object id's.

    Assigned variables, or its index is a better way to go.

  • Touch > is in touch
    _____Touch > is touching sprite > set text to "It's a fish "str(sprite.IID)
    _____Else > set text to "It's a fish!"[/code:6a0l5vhg]
    
    If that's not helpful, maybe you could go into a bit more depth on the goal? When you say the player slides back to a previous sprite, does the text revert to neutral (per my example) or change again depending on which sprite is pushed? In which case I recommend a callback from an instance variable.
  • you know its a bit weird that we can append text but cant go reverse I've alway wonder why. I guess its based on Time always moves forward.

  • "Append" by definition means to add. =) It's just a way to alter text without overwriting any existing text, just like a word-processor.

  • Well they were going to add an expression for it, but depends was taken.

  • Set text to left(text,len(text)-len(appendedtext)?

  • Touch > is in touch
    _____Touch > is touching sprite > set text to "It's a fish "str(sprite.IID)
    _____Else > set text to "It's a fish!"[/code:3iiyjm57]
    
    If that's not helpful, maybe you could go into a bit more depth on the goal? When you say the player slides back to a previous sprite, does the text revert to neutral (per my example) or change again depending on which sprite is pushed? In which case I recommend a callback from an instance variable.
    

    Thanks for the suggestion. I think I need something more embracing like a callback as you mentioned: as the player go back to each previous sprite, the IID must be removed from the text object, in the original order. I tried to use variables and add to/subtract to actions (Add sprite.IID) but it didn't work. Could you tell me more about the solution you suggest? Thanks.

    you know its a bit weird that we can append text but cant go reverse I've alway wonder why. I guess its based on Time always moves forward.

    Same here!

  • Set text to left(text,len(text)-len(appendedtext)?

    Could you give me more details?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • sequence_test.capx

    WOW! Genial!!! Thank you Always helpful!

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