More array Questions

Get help using Construct 2

Post » Fri Sep 09, 2016 6:32 am

Ok two question.

One Is it possible to select a range of array to be update with a simple formula such as this array.curvalue+(5*level) and that level is in the array spot of 1,10.

Ive tried to manually update teh array through a simple expression using for each x,y of the array. And then each current value to be +5 ....this doesnt work I do not know why.

apparently the contruct two array value will not update through expression of math but just straight first value of what ever it is.

And 2nd question is that Can I use the arrays in a way to auto update itself when leveled or do i need to make a shit ton of variable to be call back n forth like dumb pirates on a sea lol

The idea here is that Once i update the array i can use the value from it for calculating the battle scene such as if you attack first check your own player power level and combine it with your own ability and then hit the enemy but wait let check the enemy array defense value to reduce the damg done.

Ive done it before not using array but id like to do so in a smallish functional way without doing hundreds of events. So far with oosyrag help ive figured out how to choose the monster and have it updated the stats on the battlefield for a base stats but now i want to update its stats in relation to the chosen level.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Fri Sep 09, 2016 10:14 am

i think this need a good experience with array and is very complex...
i have the same problem with you before month.. i fix it with no array
one by one event by event.. with ability per level passive per level.. and we talk 20-30 ability per level and max level 25..with alot item equip ans combat system who play first what ability,area effect,health system combat, auto combat monster etc etc..

i know meaby with array is faster way but i dont have this experience yet.. so i fix it with old schooled method..
B
15
S
7
G
7
Posts: 201
Reputation: 5,277

Post » Fri Sep 09, 2016 11:48 am

Image
Maybe this can help you. I'm sorry if it's not that. I'm not very good at English. :)
Hi I am Samuel :)

My google play
B
40
S
10
G
1
Posts: 125
Reputation: 3,206

Post » Fri Sep 09, 2016 1:30 pm

Gearworkdragon wrote:Ive done it before not using array but id like to do so in a smallish functional way without doing hundreds of events. So far with oosyrag help ive figured out how to choose the monster and have it updated the stats on the battlefield for a base stats but now i want to update its stats in relation to the chosen level.


An array is not more then a list of variables.

Now. When using instances and instance variables, you in fact have a 'list of variables'. Because instance variables are personal, owned by a certain instance. Therefor, dat is in fact an array.

You can handle every instance of an object with one line of code. So, that is not piling up lines of code.

I understand that you have base value for things, that changes in relation to a value depending on the level. You can make an array for that. But you can also make 1 object, lets call it 'LevelDirector'. Make it global. And bring 1 in each level. Now if you work with factors, its pretty easy. Bring those in instance variables on 'LevelDirector'.

By example. The enemys range in level 2 is twice (factor) that of in level 1. Set the variable LevelDirector.RangeFactor in level one = 1. In level 2 = 2, in the properties for that object on the left, in the layout.

Now this is always true, on each level, in every eventsheet.

Enemy.range = Enemy.BaseRange * LevelDirector.RangeFactor

1 line to update for the new level.

Hope you understand what i try to say.
B
33
S
18
G
28
Posts: 2,477
Reputation: 20,918

Post » Fri Sep 09, 2016 11:55 pm

Yeah i get that but when i try to do that with the array it will alway use the first value and never the added math.

so for your example it would just use Enemy.baseRange

Cause my current not working formula would be something like after chosen level has been selected

For each X/Y
System compare two value which is alway curx = 1 cause there is one enemy at any given time for this formula

But things gets a little hairy cause the first value is the name of the monster so id like to skip this and start on cury 2 and then move forward until Y9 and for each value id like to update it 2 point per level so Id would have thought it would be like set at array at X=1 and then CurY to (Curvalue + (2*Array,at(1,10))

for example the forumla would end up looking like this 21 + (2*2) which would equal to 25 for level 2 and then 3 would be 27.

Ok new update is that I can do it through just a simple math without using array callback and it did work but Why doesnt it listen for teh update math. One would think it would just be curvalue +number .....but apparently it wont even do that.

Unless if function being weird that i have to include parameter for such simple math ?
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Sat Sep 10, 2016 4:51 pm

Gearworkdragon wrote:Ok two question.

One Is it possible to select a range of array to be update with a simple formula such as this array.curvalue+(5*level) and that level is in the array spot of 1,10.

Ive tried to manually update teh array through a simple expression using for each x,y of the array. And then each current value to be +5 ....this doesnt work I do not know why.

apparently the contruct two array value will not update through expression of math but just straight first value of what ever it is.

And 2nd question is that Can I use the arrays in a way to auto update itself when leveled or do i need to make a shit ton of variable to be call back n forth like dumb pirates on a sea lol

The idea here is that Once i update the array i can use the value from it for calculating the battle scene such as if you attack first check your own player power level and combine it with your own ability and then hit the enemy but wait let check the enemy array defense value to reduce the damg done.

Ive done it before not using array but id like to do so in a smallish functional way without doing hundreds of events. So far with oosyrag help ive figured out how to choose the monster and have it updated the stats on the battlefield for a base stats but now i want to update its stats in relation to the chosen level.


You can set values in an array using math operators just like any other variable. Although you have to remember that array can store strings and numbers so make sure the value is a number.
EX: array.curvalue + 5 * (array.at(1,10)
This is correct. If its not returning any number then I'm pretty sure one of these expressions is not returning a number. And if it's returning just the first value and "ignoring" the math then the second expression is not returning a number. Always try to debug your expressions before anything by just replicating it on a text so you can easily see what is returning.

The second question I don't know If I understood correctly but no array or variables auto update itself like that. You have to store the new value in there. But that's all you have to do. Once updated, you just need to do math using those values updated, like the action> subtract "do Math to calculate damage using formula fed by array values
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Sep 10, 2016 7:49 pm

Ok well i found my stupid little problem you guys were right that it is being used as a text. This Is madness cause im using Rex(csv to array) plugin apparently it parsed every value in the CSV to a text format into the array.....WTF how in the hell am i suppose to fix that.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Sat Sep 10, 2016 8:28 pm

Gearworkdragon wrote:Ok well i found my stupid little problem you guys were right that it is being used as a text. This Is madness cause im using Rex(csv to array) plugin apparently it parsed every value in the CSV to a text format into the array.....WTF how in the hell am i suppose to fix that.


Just use int expression(for integer) or float (for float numbers) Like this:

int(array.curvalue) + 5 * int(array.at(1,10))
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sun Sep 11, 2016 12:39 am

Omg thx you @kossglobal that solved everything

This is solved so yes if you are using rex(csv to array ) and need to update value use Int(value).

Also for the range problem id figure out that its the system For loop start index is where you need it to start and end is where you need it to actually end

Oh and id recommend using function for this.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Sun Sep 11, 2016 1:34 am

Gearworkdragon wrote:Omg thx you @kossglobal that solved everything

This is solved so yes if you are using rex(csv to array ) and need to update value use Int(value).

Also for the range problem id figure out that its the system For loop start index is where you need it to start and end is where you need it to actually end

Oh and id recommend using function for this.


Bear in mind that they are 0 based, so if you have a loop that runs 5 times, its starting index is 0 and the last index is 4, not 5.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests