Now what I want is for the VoidlingHealth Variable to display as the subtracted number when i use it in another line of code.
VoidlingHealth has a value of 20, iceboltDmg has a value of 5. So it displays the voidling as having 15HP after I run it which is great but when I write the VoidlingHealth variable in a new line of code it goes back to the original value of 20 how can I make it so that the variable changes when I subtract the iceboltDmg
Expressions in a line of code are evaluated but the resultant value is copied into a temporary value then discarded. What you wrote isn't displaying the current value of VoidlingHealth, it's displaying the value of the expression Voidlinghealth - iceboltDmg, which is 15. The health variable is still 20. If you want to store the resultant value for use later you need to store it in another variable, or you can use a compound arithmetic operator. Something like this:
VoidlingHealth -= icebolDmg;
If you want to use that instead you might have to use parentheses around the expression to make sure it evaluates properly however, since it might output the health variable before the expression is evaluated. Associativity is a tricky subject. :) You could do it like this:
If you want to keep track of the original health of the voidling you'll either have to use a seperate variable like VoidlingMaxHealth, or use a variable to store the current health of it and use that variable in place of VoidlingHealth.
Thanks so much for the Help~
We've only taken two classes so far and so the teacher has yet to explain aloot of this things
This is meant to be a simple homework i which we just have to Add, subtract, multiply and divide Variables which is extremely simple so i decided to do it sort of like a text based game.