How do I subtract one of the texts from a global variable?

Get help using Construct 2

Post » Tue Mar 10, 2015 5:31 pm

I am having 25 different sprites, and none of them have instances. I don't have any repeating object at all. My game consists of touching different buttons, which also don't have instances, and each button brings it's sprite in the window, all in the same position. What actions should I add to the event sheet in order to write down only the sprites that where placed in the window? With a button click , after all needed sprites are inside the window, I want a text to be created in a string and write down in it the names of these sprites. Than I do with the string what I need.
Last edited by MangoPolo on Thu Mar 12, 2015 2:12 pm, edited 3 times in total.
B
8
S
2
Posts: 110
Reputation: 923

Post » Tue Mar 10, 2015 10:46 pm

Try this.

I think this is what you want.
You do not have the required permissions to view the files attached to this post.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Mar 11, 2015 2:21 pm

that worked! my great thanks to you, spongehammer!
and two last things. what is the command to erase a name from the global string? in case the sprite is sent back out of the window. and how do I add space or comma between names or even better - how to I make each name written in a new row?
B
8
S
2
Posts: 110
Reputation: 923

Post » Wed Mar 11, 2015 6:20 pm

Check the updated capx.

This shows you how to add a comma and a new line.

If you want to remove the last sprite name from the list you could copy the global variable to a temp variable, add the next sprite name, then if you need to remove the last name just copy the temp back to the global variable. Essentially make sure the temp variable is always one name behind the global variable.
You do not have the required permissions to view the files attached to this post.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Wed Mar 11, 2015 7:25 pm

to make c2 create each a time a temp copy of the global, when a new name is added , is easier than to add a command to the action which removes the sprite off the window?

this is an event which makes the sprite appear and disappear from the window area. which command may I add to the first action in order to remove the name from the text?

first action makes it stay out, second makes it be placed in a specific position inside the playing window.
B
8
S
2
Posts: 110
Reputation: 923

Post » Thu Mar 12, 2015 1:07 pm

here is the modified capx to make a better understanding. what action I add for the Is on Screen condition , for the text name to be erased? I don't believe there is no such function to delete texts from globals!
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 110
Reputation: 923

Post » Thu Mar 12, 2015 1:47 pm

Subtract wouldn't be a way? But I am looking for ways to set it there
B
8
S
2
Posts: 110
Reputation: 923

Post » Thu Mar 12, 2015 5:51 pm

why this doesn't erase the name from the variable??
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 110
Reputation: 923

Post » Thu Mar 12, 2015 6:02 pm

Using a 1D array would be way more easier. You can push and pop as needed then save the Array to the variable. So then it can be deleted in whatever order it needs to be deleted.

I use a function to refresh list only when there has been something changed versus every tick.

FYI Subtract is for integers not strings :)
You do not have the required permissions to view the files attached to this post.
B
23
S
4
G
2
Posts: 362
Reputation: 2,380

Post » Thu Mar 12, 2015 9:59 pm

As I said, you are the HERO of the day, Phoenix!
Thank you very very very much!
B
8
S
2
Posts: 110
Reputation: 923


Return to How do I....?

Who is online

Users browsing this forum: AllanR, rayray, RetroSpock and 10 guests