How do I do to "subtract" appended text?

Get help using Construct 2

Post » Thu Apr 28, 2016 11:19 am

Set text to left(text,len(text)-len(appendedtext)?
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Apr 28, 2016 12:47 pm

Davemon wrote:
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.


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.


Gearworkdragon wrote: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!
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Thu Apr 28, 2016 12:53 pm

oosyrag wrote:Set text to left(text,len(text)-len(appendedtext)?


Could you give me more details?
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Thu Apr 28, 2016 12:54 pm

Image
B
65
S
23
G
7
Posts: 1,504
Reputation: 10,894

Post » Thu Apr 28, 2016 1:04 pm

korbaach wrote:Image

Image

sequence_test.capx


WOW! Genial!!! Thank you @korbacach. Always helpful!
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Thu Apr 28, 2016 1:24 pm

oosyrag wrote:Set text to left(text,len(text)-len(appendedtext)?


Thanks @oosyrag. Now I understand your suggestion through the korbaach's example.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Sun May 01, 2016 11:00 pm

@korbaach: I'm using more than 9 squares and after that if I selected the tenth or anyone after, I cannot deselect it when I return to the previous one. Could you explain why it happens? Thanks.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Mon May 02, 2016 11:41 pm

Could someone explain me this issue?
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Tue May 03, 2016 6:47 am

If you use more than 9, then you can't write variable like this
sequence =0348
because it is now impossible to determine your squares IID
0348=
0-3-4-8
0-34-8
0-3-48

so,, you need to use separator between numbers..and if you use separator ,
you need to use tokenat

tokenat(src, index, separator)
Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

tokencount(src, separator)
Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.



I think it is much better&easier to do with arrays..but for now..

sequence_tokenat.capx

Edit:

sequence_Arrays.capx
Image
B
65
S
23
G
7
Posts: 1,504
Reputation: 10,894

Post » Tue May 03, 2016 2:39 pm

@korbaach

I though to use tokenat but I really didn't understood where was the problem. Now I understand why it happened. I intend to use the tokenat solution. It's simpler for me to implement it. Thank you for help me to understand it.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Previous

Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu and 12 guests