Hi! I’ve found out about CoG 4 days ago and decided to try it out without any coding experience whatsoever. While testing the *stat_chart command I’ve run in to some issues I haven’t been able to figure out.
So a quick overview of what is happening in game:
At the start of the game you get to choose your race, each of which has their own default stat attributes. After choosing your race, you get to choose your class; either a warrior, an archer or a mage. This choice affects your stats. So in the example I’m trying to test, I choose to be a Western Human, which has 100 health by default and I choose the warrior class giving me +10 health and a total of 110 health.
This is the code I’ve used for that:
in startup.txt:
And you are a..?
*fake_choice
#Warrior
*set class 1
*set currentHealth +10
*set maxHealth +10
*set strength +5
*set iron_sword "unlocked"
*set potion_of_health +1
in choicescript_stats.txt
Stats:
*stat_chart
percent percentHealth Health
When testing this in game, there is a part where one of the choices makes you lose 90 points of health. I’ve written this as follows in the scene: *set currentHealth -90
Now when I check the stats after losing those 90 points of health, it still shows the bar at 100%. I’ve tried numerous things to fix this but all I can manage to do is either have the bar go to 0% completely after losing 90 out of 110 health, or have it at 1% permanently.
Can anyone guide me in the right direction to fix this, because I have run out of ideas.
But percentHealth is stated as being (round(currentHealth/maxHealth)*100), so shouldn’t it use the latest value set to currentHealth to calculate percentHealth, to then show the value percentHealth has calculated in the stats? Or am I mistaken?
What I mean is, if you want your calculation to run every time you open the stats page, you’ll need to put your *set percentHealth (round(currentHealth/maxHealth)*100) piece in the choicescript_stats.txt.
Okay I tried that, but it still shows my health to be at 0% after losing 90 out of 110 health. Do I also have to adjust anything in the stat_chart command or can I leave that as is when I put *set percentHealth (round(currentHealth/maxHealth)*100) above the stat_chart command in choicescript_stats.txt?
Well I do really appreciate your help tho. It does kind of make sense that if the stats page calculates everytime I open it, I should run the calculation there every time. So I learned something at least
I’m not sure about the timing/placement of the code, but I don’t think your formula is formatted correctly. Someone can correct me if I’m wrong, but this might work better. No promises.