Borrowing variable from mygames.js file to drop into stats

hey there. i have the two variables in the above mentioned .js file and would like to pull one to correlate to the other. the first one, i guess people are familiar with is wounds. i am happy to use to the if wounds = this then wounds.text = ‘really hurt’ but i would like it to instead be based on another variable. health. health is a percentage stat and so varies from 0 to 100. so what i would rather is something like this:

*temp wound_text
*if health < = 95
–*set wound_text “unscathed.”
–*goto chart
*elseif health < = 75
–*set wound_text “minor scratches and bruises. aching.”
–*goto chart
*elseif health < = 60
–*set wound_text “infected. effects manageable.”
–*goto chart
*elseif health < = 20
–*set wound_text “infected. some effects manageable.”
–*goto chart
*else
–*set wound_text “infected. little hope.”
*label chart

is there a way of pulling the variable ‘health’ to correlate to this? the reason being because i want the wounds to be more fluid and slightly more detailed. thank you for taking the time to read this. :slight_smile:

Slightly edited post to make it more readable. As for what you’re actually asking, well, I don’t see what your question is. As far as I can tell, you seem to already have the answer listed above.

Thanks @Reaper, those < br/ >'s were making me scratch my head. Btw, those <='s should be >='s or none but the first will trigger.

@_jl Different games use different variables to keep track of health. Global variables like “health” are set in the mygame.js file. Just add it to your list of starting stats. Then put your wound code in choicescript_stats.txt so it will appear every time the player pulls up their stat sheet instead of health. Does that help?

@Reaperoa hey, thank you for that. do you know how to format and highlight code too? i was unsure how to do it.

@P_Tigras i have both health and wounds as well as stress. because of the nature of my game, stress will also affect the players ‘wounds’ so to speak but i forgot to add that in in the initial post.

what i was trying to get was to aggregate stress and health into one stat (wounds) which would indicate overall physical deterioration. i was under the impression i’d actually have to somehow call the .js file to do this but if i can do it simply by including the variable in the .txt file then i guess my problem is solved! :slight_smile: thank you for your responses.

p.s. thanks for letting me know about the greater than/less than signs. i was coding kind of late and completely unsure what i was supposed to have there.

@_jl You can define local variables in a text file with the *temp command that you used at the top of this page. They only exist within that text file, ie. they’re temporary. If you want a variable accessible across different text files than you should define them globally in mygame.js. So in this case, it sounds like you want health (and probably stress as well) to be accessible from all text files, while wounds only needs to be accessible when the player looks at their health. If the only file responsible for displaying character wounds is choicescript_stats.txt than that’s the only file it needs to be defined in and a tempory (aka local) variable works fine.

@P_Tigras but if i want to call global variables, do i need to do any redefintion or calling any classes (or the .js file) to do this or can i create an aggregate from the two globals (stress and health) and then apply them within the choicescript_stats.txt with a local variable i.e. wounds. at the moment, wounds is both global and local haha. so i guess i can remove wounds from the .js file, thinking about what you just said there about it not really being used for anything aside from displaying condition and stats. thank you for your help so far. it’s been useful. :slight_smile:

@_jl You’re welcome. And to answer your question, global variables are used exactly the same way as local variables once they’re defined in mygame.js as part of the stats block.

@P_Tigras thank you for that. :slight_smile: i will implement the algorithm.