How do I do to "subtract" appended text?

Get help using Construct 2

Post » Tue Apr 26, 2016 4:31 pm

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.

Code: Select all

Touch > is in touch
_____Touch > is touching sprite > text  append str(sprite.IID)
_____System > Trigger once



Thanks in advance for any help.
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Tue Apr 26, 2016 5:00 pm

You don't.
You just set the text to what it was previously.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Tue Apr 26, 2016 5:14 pm

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?
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Wed Apr 27, 2016 11:19 am

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
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Wed Apr 27, 2016 8:00 pm

no help?
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Wed Apr 27, 2016 8:27 pm

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.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Thu Apr 28, 2016 1:05 am

Code: Select all
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!"


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.
B
17
S
7
Posts: 21
Reputation: 1,711

Post » Thu Apr 28, 2016 1:28 am

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.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Thu Apr 28, 2016 1:30 am

"Append" by definition means to add. =) It's just a way to alter text without overwriting any existing text, just like a word-processor.
B
17
S
7
Posts: 21
Reputation: 1,711

Post » Thu Apr 28, 2016 2:02 am

Well they were going to add an expression for it, but depends was taken.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests