SOLVED///How do I add a value to a inst. var from a string?

Get help using Construct 2

Post » Wed Apr 15, 2015 12:30 am

I have a global variable where certain numbers and texts are added from different actions like:
Set Global1 to Global1&object1.name&object1.points&object1.weight etc...
In the global they show up like this:
NAME 12 50
When I create an action like:
Object2.points Add to Object1.points no changes happen Object1 values from the Global1.
Another set of actions are like that:
Add Object1.points to Global2 and It is working good. Numbers are calculated as totals. But how do I make them to be added to the first global as well? They do not add... How do I make math work on values already written in the 1st string? without having to reset it...

In simple words, how to add a value to an instance variable who's value is already in a string and make this change in that value in the string , not only to the object in general? I just need to keep their order, during adding values, that's why I am asking such a thing...
Last edited by MangoPolo on Mon Apr 20, 2015 5:24 pm, edited 1 time in total.
B
8
S
2
Posts: 110
Reputation: 923

Post » Wed Apr 15, 2015 9:04 am

Could you try explaining why you want to do this this way.
It really seems to me you'd like an explanation on how to do things in a not very effective way.

Setting a string variable can be done in the same way as setting a text-object's text.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 9:31 am

It is not about Setting a string, but Adding a value. I am doing math there... Array is a much better solution, but I will have to confess I am a total incompetent in them. I am working on a project now and want to finish it's first version in any way. After that I am planning to study the Array functions and simplify my work. But the start doesn't allow me to pause now... I am just a learner now.
Here is the simple capx with a meaningful explanation:
drive.google.com/file/d/0B09lLdP7JoIAZFY4clA4V1lRV3c/view?usp=sharing
B
8
S
2
Posts: 110
Reputation: 923

Post » Wed Apr 15, 2015 2:19 pm

Anybody, please?...
B
8
S
2
Posts: 110
Reputation: 923

Post » Wed Apr 15, 2015 2:41 pm

I'm not sure if I'm right, but it seems to me you are trying to do mathemetics while setting the string.

I would choose to seperate numbers from strings and first perform the mathematics and use the the string to display the result.
This would also give you better control over the numbers if you were to change them.

something like:
Add a new objectvariable and call it Totalpoints
if x2 set totalpoints to 2*points
if totalpoints is not 0 use it in the string
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 3:00 pm

If you could see, I already a second string where math is being performed, with a total of points from pressed objects. But in the first string it is a set of Sprite.names but each followed by it's particular score. And when x2 is pressed under one object, not only it's score is added to the second string, doing the total, but also replaces the value in the first string, of that object. It is not possible?
B
8
S
2
Posts: 110
Reputation: 923

Post » Wed Apr 15, 2015 3:13 pm

I did see the capx.

points is a number variable and not a text variable.
points is also calculated before setting the text to points, which is the way I suggested above.

So like I said:
Calculate the value in a number variable and use the calculated value in the string.
You are already doing that with points, so why not with the other variables?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 3:15 pm

so...you have...

TEXT 1: varable name (Green)___________TEXT 2: Global points(30)
..............variable points (30)

on Touchet "2X" you add variable points(30) only to Global points...

so...you have...

TEXT 1: varable name (Green)___________TEXT 2: Global points(60)
..............variable points (30)
Image
B
61
S
23
G
7
Posts: 1,461
Reputation: 10,686

Post » Wed Apr 15, 2015 4:40 pm

I undersrtand the logics... but I can't quite reinterpretate them now... I don't know what actions to use to make Global points be added to a specific object value in another string. I will play now with the events, and try to figure it out...
Last edited by MangoPolo on Wed Apr 15, 2015 4:48 pm, edited 1 time in total.
B
8
S
2
Posts: 110
Reputation: 923

Post » Wed Apr 15, 2015 4:44 pm

pressing x2 doesn't double all the numbers from the Number Global. it doubles only the value of the selected object. Maaan, I am so stuck now :))) I hope I will figure it out , as it is the last step of my whole project.
B
8
S
2
Posts: 110
Reputation: 923

Next

Return to How do I....?

Who is online

Users browsing this forum: just2pale and 5 guests