If in
import "std.zh" global script PleaseDrainCR_LIFEUntilZero { void run() { if (Game->Counter[CR_LIFE]>0) { Game->DCounter[CR_LIFE] -= 4; } } }
I change if to while then my game freezes.
Posted 07 June 2018 - 08:03 PM
If in
import "std.zh" global script PleaseDrainCR_LIFEUntilZero { void run() { if (Game->Counter[CR_LIFE]>0) { Game->DCounter[CR_LIFE] -= 4; } } }
I change if to while then my game freezes.
Posted 07 June 2018 - 10:34 PM
Your if statement needs to be in the while loop so that the code is executed each frame.
Also, with the way your code is written, the counter for life will drain faster every frame.
This code fixes these issues:
import "std.zh" global script PleaseDrainCR_LIFEUntilZero { void run() { while (true) { if (Game->Counter[CR_LIFE]>0) { Game->DCounter[CR_LIFE] = -4; } Waitframe(); } } }
Posted 08 June 2018 - 09:09 PM
Your if statement needs to be in the while loop so that the code is executed each frame.
Also, with the way your code is written, the counter for life will drain faster every frame.
This code fixes these issues:
import "std.zh" global script PleaseDrainCR_LIFEUntilZero { void run() { while (true) { if (Game->Counter[CR_LIFE]>0) { Game->DCounter[CR_LIFE] = -4; } Waitframe(); } } }
Game->DCounter[]; only needs to be set once. So you do not need a loop to make it drain each frame.
Example: Game->DCounter[CR_LIFE] = -16;
This will drain 1 life each frame until 16 (1 heart) has been taken.
In your code there all your doing is setting the drain amount back to 4 each frame, not draining by 4 each frame. And if the loop were to break the code will take an extra 4hp from Link.
If you want to drain Link's HP by 4 each frame then you need to do this:
import "std.zh" global script PleaseDrainCR_LIFEUntilZero { void run() { while (true) { if (Game->Counter[CR_LIFE]>0) { Game->Counter[CR_LIFE] -= 4; } Waitframe(); } } }
0 members, 1 guests, 0 anonymous users