Variable-related event

I'm trying to create an event where you can subtract one variable and store that data and add that to another variable.


For example, I set up Variable X to receive a random number i.e (0..6) and Variable Y is set to 0, Variable X got 4 and Variable Y remained 0. I then set another event that will


subtract Variable X randomly i.e  (1..2) and Variable X is left with 3. Now I want to create an event where the 1 in 4 is added in Variable Y. Now Variable Y is equal to 1...


I have tried some things like Subtract randomly to Variable X and add randomly to Variable Y, hoping that they got the


same number, but it didn't work in the long run. Any suggestions regarding this topic? 
Show us screenshots of the event pages you have so far, and make an explanation of what you really want to use the variables for.


Your explanation is a bit confusing, but mathematics need to be exact.


Control variable can be used for any mathematical operation without problems - the only limit is that it always has only one result and one operand, so for some kinds of mathematical operations you'll need an additional temporary variable to store steps of the calculation.
Show us screenshots of the event pages you have so far, and make an explanation of what you really want to use the variables for.


Your explanation is a bit confusing, but mathematics need to be exact.


Control variable can be used for any mathematical operation without problems - the only limit is that it always has only one result and one operand, so for some kinds of mathematical operations you'll need an additional temporary variable to store steps of the calculation.

I hope you can understand this. Page 1 is on the left and the other one is on the right

Spoiler
scr.png/monthly_2016_09/scr2.png.9d270367eeea6c03eda2916677e6742e.png
@Webby: No, that is not what I asked you to give.


I don't want you to write the same thing you wrote in an event, I want to see where you want to use those calculations and what you want to do with it - it is the context that I'm after, not a simple rewrite. And you didn't even give full event screenshots but cropped away half of the event (the event properties). That doesn't matter here, but you have to learn that an event is more than just its contents to prevent errors later.


That said, you even made mistakes in that rewrite. Read the second comment below label 2 and the directly following comment under lable 3.


At the first you said that Y should get 0 and remain 0, and then you're claiming that the 0 you get is wrong when you said yourself in the line above that it had to be zero?


EDIT: and please, don't make comments about assumptions - the computer cannot give other results than those it is commanded to. so don't assume but let the event run and check the results.
@Webby: No, that is not what I asked you to give.


I don't want you to write the same thing you wrote in an event, I want to see where you want to use those calculations and what you want to do with it - it is the context that I'm after, not a simple rewrite. And you didn't even give full event screenshots but cropped away half of the event (the event properties). That doesn't matter here, but you have to learn that an event is more than just its contents to prevent errors later.


That said, you even made mistakes in that rewrite. Read the second comment below label 2 and the directly following comment under lable 3.


At the first you said that Y should get 0 and remain 0, and then you're claiming that the 0 you get is wrong when you said yourself in the line above that it had to be zero?


EDIT: and please, don't make comments about assumptions - the computer cannot give other results than those it is commanded to. so don't assume but let the event run and check the results.

I swear this is the last time I'm ever touching on this subject so I'm going to answer all of your questions and sorry about the rewrite.


Firstly, the reason why I'm asking about this is because I'm trying to create a simulation game using only switches and variables that can "simulate".


An example: Every 10 secs. X (representing humans) will be subtracted by an random number, so X - A random number


Another example: A zombie apocalypse where you have X people in a building, you rescued Y people and left X people.


X= 10


10 - 6= 4


Y being 6 people you rescued and 4 remained in X.


Second, the reason why I cropped that event page is because there is nothing on the conditions bar and trigger. If you still want the details, then you can contact me about it


Lastly, Hypothesis #2 was the correct method. I don't know why I discussed about this, I guess trial and error best works and thanks to you I realized that method.


So you can close this question, I mostly answered it myself. I'm really sorry to waste your time about this and thank you for responding.
The reason it didn't work is the call to random(0...2) picks a different random number each time. So you need to store that random number into another variable, then subtract that variable from the other variables.

Original thread: https://forums.rpgmakerweb.com/threads/variable-related-event.68637/