Legacy GM Add to one array and increase another

M

MakSM

Guest
i cant have one array change the other

I currently have one array pointing to another array

Code:
global.recipies[1,7] = global.weaponArray[1,3]
.

Is there any way that i could increase global.recipies[1,7] and then that increases global.weaponArray[1,3]

Not sure really how i would do it so the above code is all i've really tried

I am using:

Game Maker Studio Proffessional

GameMaker Language (GML)
 

YoSniper

Member
Please clarify what you mean by "increasing" global.recipies.

Also, I don't think these arrays are pointing to each other like you think. Rather, you are just assigning the same value to two different places. So in order to change both, you would have to reassign both values.

It would also help us help you if you provided a little more context behind the problem.
 
M

MakSM

Guest
Please clarify what you mean by "increasing" global.recipies.

Also, I don't think these arrays are pointing to each other like you think. Rather, you are just assigning the same value to two different places. So in order to change both, you would have to reassign both values.

It would also help us help you if you provided a little more context behind the problem.
i would like to increase global.recipies[1,7] and then have that increase global.weaponarray[1,3] by one

essentially global.weaponArray is ammo and I have a crafting system that is supposed to create ammo depending on the recipe and global.recipies[(something),7] is supposed to be the ammo to add to.

so i want to look at global.recipies and then have it add a certain amount to global.recipies[?,7].
 
S

Soren11112

Guest
Your doing what you are attempting in reverse and incorrectly, you are doing
Code:
global.recipies[1,7] = global.weaponArray[1,3]
When you need to be doing something like
Code:
global.weaponArray[1,3] = global.recipies[1,7] + global.weaponArray[1,3]
Your problem is that you are setting the two to be the same, which you may want but lets assume you don't. You are also defining global.recipies[1,7] as the same as global.weaponArray[1,3] when what you want is the other way around.
 
S

Soren11112

Guest
Or, like you said if you want to increase by one you would do something like
Code:
global.weaponArray[1,3] = global.recipies[1,7] + 1
 
M

MakSM

Guest
Or, like you said if you want to increase by one you would do something like
Code:
global.weaponArray[1,3] = global.recipies[1,7] + 1
if ure saying to add to global.weaponArray that's a problem. The object being created changes depending on the recipe so i cant address the weaponArray directly because it changes depending on what you're crafting.
 

TheouAegis

Member
Maybe I misunderstand, but why not just do something like

global.weaponArray[@ global.recipies[1,7], 3]++;

Where global.recipes[n,7] (or global.recipes[1,n]) would hold the indexing for the weapon it's supposed to supply?
 
Top