Create a temp var that is not a temp

I have fatigue, and as it drops it will affect other stats such as health. Tracking the drop is simple enough. However, if they recover with rest I need to remove the changes.


*label fatigue_1
*if (tm_1_fatigue>=90)
 *gosub fat_adj_1
 *set fat_1 "I'm full of pep and vigor"
 *return
*if (tm_1_fatigue>=80)
 *gosub fat_adj_1
 *set fat_1 "I'm still full of pep"
 *return
*if (tm_1_fatigue>=70)
 *gosub fat_adj_1
 *set fat_1 "Still plenty of vigor left"
 *return
*if (tm_1_fatigue>=60)
 *gosub fat_adj_1
 *set fat_1 "I'm a little worn down but still good"
 *return
*if (tm_1_fatigue>=50)
 *gosub fat_adj_1
 *set fat_1 "This starting to look like a long day"
 *return
*if (tm_1_fatigue>=40)
 *gosub fat_adj_1
 *set fat_1 "I may need a break soon"
 *return
*if (tm_1_fatigue>=30)
 *gosub fat_adj_1
 *set fat_1 "How about a break boss man?"
 *return
*if (tm_1_fatigue>=20)
 *gosub fat_adj_1
 *set fat_1 "I don't feel so hot"
 *return
*if (tm_1_fatigue>=10)
 *gosub fat_adj_1
 *set fat_1 "I feel sick to my stomach"
 *return
*if (tm_1_fatigue>=1)
 *gosub fat_adj_1
 *set fat_1 "My head hurts and the room is trying to spin"
 *return
*if (team_set)
 *set phy_1 "You have not picked your team yet.
 *return
*if (tm_1_fatigue<=0)
 *gosub fat_adj_1
 *set fat_1 "I hope you caught me as I pass out"
 *return
 
*label fat_adj_1
*comment this is where I will track the changes
*comment so if they are under 40 then they will drop in hp 5 and fear will go up 7
*comment but if they recover then I need to remove the 5 and the 7
*comment I cannot use a temp var as this crosses over many goto_scenes.
*comment any thoughts how to handle this.
*comment thanks

Can you not track the other stats or set it to a default value along with fatigue when you rest?

@hahaha01357
Since the other number are in flux I cannot set them to a default number. As heath may go up 1 or 2 points with rest, but with out medical attention the number will not reset. But I wont to remove the modified number from resting and restoring fatigue.

*edit I think I have a thought will post if it works.

**edit


*label fat_adj_1
*if (tm_1_fatigue>=40)
 *gosub fat_check
 *return
*if (tm_1_fatigue>=20)
 *set fat_check true
 *set hp_temp tm_1_heart
 *set fear_temp tm_1_fear
 *temp hp_rand 0
 *temp fear_rand 0
 *rand hp_rand 1 8
 *rand fear_rand 1 12
 *set tm_1_heart -hp_rand
 *set tm_1_fear -fear_rand
 *return
*if (tm_1_fatigue>=1)
 *set fat_check true
 *set hp_temp tm_1_heart
 *set fear_temp tm_1_fear
 *temp hp_rand 0
 *temp fear_rand 0
 *rand hp_rand 4 11
 *rand fear_rand 4 16
 *set tm_1_heart -hp_rand
 *set tm_1_fear -fear_rand
 *return
*if (tm_1_fatigue<=0)
 *goto passed_out_1
 
*label fat_check
*if (fat_check)
 *set tm_1_heart hp_temp
 *set tm_1_fear fear_temp
*else
 *return

This should work for now, but if someone comes up with a better method please let me know. Thanks :slight_smile:

Why can’t you just use a global?

Because I not sure how to lol @CJW

Global variables are the ones you *create in startup.txt

@Nocturnal_Stillness I see, still using mygame,js Dislike the cluttered feeling I get using startup.txt to create the var. Silly I am sure. ^^

So… Why not just add this to mygame.js along w your other global variables?

Yeah they are global when in mygame.js too

@Havenstone and @Nocturnal_Stillness
Ok not following sorry slow at times. So are you saying something like
*global_var
In a sense I did this with the hp_temp and fear_temp var

Define the variable in mygame.js then it won’t disappear between scenes.

@CJW I did, just was not sure how to loop the information so the data could be retrieved with out setting it to a default number. I have now manage this with the last code I posted. I think we are on the same page just my not grasping what was being said. :slight_smile:

@CJW My Dyslexia gets the better of me sometimes, it just clicked what you are saying. I worded it poorly I guess. Yes I made a global but I needed to treat it as a temp. The code seems to work well so I should be ok thanks.

If you want a global to act like a temp, make it a temp. If you want a temp to act like a global, make it a global. I don’t understand your confusion :stuck_out_tongue:

@CJW temp is only good for that page correct. So when I leave the page the temp is reset. Well I need the temp to hold the number even when switching pages.

*edit I guess the problem lies in me calling it a temp, but it is a temporary number with a global state if that makes sense.

@lordirishdas I do see what you mean so I’ll stay out of this one. :smiley:

An aside though: fat_check probably won’t work properly without a slight change -


*label fat_check
*if (fat_check)
  *set tm_1_heart hp_temp
  *set tm_1_fear fear_temp
  *return ***this line is missing in your sample code***
*else
  *return

Alternatively, just remove the *else in this case, since it serves no real purpose, and don’t indent the *return so it will fall to that line whether or not fat_check is true, i.e.


*label fat_check
*if (fat_check)
  *set tm_1_heart hp_temp
  *set tm_1_fear fear_temp
*return

@Vendetta thanks :smiley: