Gwendolyne Posted June 27, 2013 Posted June 27, 2013 I am trying to introduce a food variable in my mod : You will have to feed your characters during the adventure. Everytime you eat something, 5 variables are increased (Water, Calorie, Sugar, Protein and Lipid). Every 8 hours, a spell substracts one third of the average daily needs (Effet Script: Set/Modify Local Variable [309]). I checked the food items in a save game with ShadowKeeper : the LOCALS values can be negative. But before going further, I was just wandering if it was possible to work on negative values within scripts : I have never seen that in all the scripts I have checked. But as there are more than 300 mods, I didn't study all of them...
argent77 Posted June 27, 2013 Posted June 27, 2013 There shouldn't be any problems. Both triggers and actions work correctly with negative local variables.
Gwendolyne Posted June 27, 2013 Author Posted June 27, 2013 Thanks for this precision. I was not sure it was possible. I will keep on coding the scripts.
Gwendolyne Posted June 29, 2013 Author Posted June 29, 2013 OK, it works without any problem and I can assign negative values to my variables. Almost... For exemple, I am using this effect with value = 350 and Type = 1. Result checked in save game : variable GWCALORI = 350 But the effect also creates a GLOBAL variable named GWCALORI and sets it to 350. It seems to be normal : http://forums.gibber...?showtopic=3619 But if I use a second charge of the same item : The LOCALS variable is increased by 350 and becomes 700 : OK. THE GLOBAL variable is set to 350 and is not increased. If I use two items : the first increasing the variable by 100, the second decreasing it by 50, I get this : LOCALS = 50 --> OK GLOBAL = -50. If I change the order (-50 and +100), I get this : LOCALS = 50 --> OK GLOBAL = 100. It is really confusing : it seems that 1°. Effect 309 creates two variables with the same name (one LOCALS and one GLOBAL). 2°. The Type modifier applies only to the LOCALS variable, the GLOBAL one being treated as if I had used the SetGlobal("Variable";"GLOBALS";value) action, and not the IncrementGlobal("Variable";"GLOBAL";value) one.
argent77 Posted June 29, 2013 Posted June 29, 2013 Yeah, modifying a local variable by effect opcode #309 has a few side effects. If you only want to set a local variable by spell, you can use effect opcode #187 (Store Local Variable) instead. It doesn't have those side effects, but you can't modify variables that way. This is also the default opcode used by script actions to store local variables.
Gwendolyne Posted June 29, 2013 Author Posted June 29, 2013 If I have well understood, effect opcode #187 stores a local variable but doesn't allow to modify (increase or decrease) it. So I can't use it : I need to manage the local variables to check if you have feeded yourself enough. In case you did not, I imagined a few surprises for you... If there is no other ways, I will keep on working with #309 : in fact, as I only check the local variables, I don't care of the global ones. I was just a bit upset because I did not understand all its stupid side effects !
Avenger Posted July 7, 2013 Posted July 7, 2013 This sounds like a bug, apparently they forgot to properly implement the incrementing part? I wonder if BGEE has this bug too.
Gwendolyne Posted July 7, 2013 Author Posted July 7, 2013 I can't tell you : I am pretty reluctant with BGEE... But if anyone else would try, it would be interesting to check if this glitch has been soved.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.