GRock84 Posted March 12, 2018 Share Posted March 12, 2018 (edited) Why is this a thing?? Whenever I try to add a new property the "const" box is checked and greyed out. I have a script that needs to get the value of and set a global variable in order for certain other features to work. I have tried deleting the fragment and moving the script elsewhere out of the folder, renaming the script, everything I can think of. Is there a file I can edit to change this or another way to get the value of a global variable AND be able to set it? I searched the wiki and the internet to see if terminal properties are just supposed to be constant but nothing I can find says that. I get the feeling I've messed up a while back and just now realizing it, but I can't for the life of me figure out where I went wrong. Any advice would be greatly appreciated! Scriptname GlitchBusterHoloMenuPlayerHP Extends Terminal Hidden ;BEGIN FRAGMENT Fragment_Terminal_01 Function Fragment_Terminal_01(ObjectReference akTerminalRef) ;BEGIN CODE Self.check_player_hp() ;END CODE EndFunction ;END FRAGMENT ;BEGIN FRAGMENT Fragment_Terminal_02 Function Fragment_Terminal_02(ObjectReference akTerminalRef) ;BEGIN CODE Self.fix_player_hp() ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment Function check_player_hp() float BaseEnd = (Game.GetPlayer().GetBaseValue("Endurance")) int playerlevel = Game.GetPlayer().GetLevel() float CurBasePlayerHealth = (Game.GetPlayer().GetValue("Health")) float FixedBasePlayerHealth = (80 + (BaseEnd * 5) + (playerlevel - 1) * (BaseEnd/2 + 2.5)) if CurBasePlayerHealth == FixedBasePlayerHealth Player_Health_Broken.SetValue(2) Debug.Notification("Player HP is OK. current: " + CurBasePlayerHealth as int + " expected: " + FixedBasePlayerHealth as int) else Player_Health_Broken.SetValue(1) Debug.Notification("Player HP is not OK. current: " + CurBasePlayerHealth as int + " expected: " + FixedBasePlayerHealth as int) endif EndFunction Function fix_player_hp() float CurBasePlayerHealth = (Game.GetPlayer().GetValue("Health")) float BaseEnd = (Game.GetPlayer().GetBaseValue("Endurance")) int playerlevel = Game.GetPlayer().GetLevel() float FixedBasePlayerHealth = (80 + (BaseEnd * 5) + (playerlevel - 1) * (BaseEnd/2 + 2.5)) Game.GetPlayer().SetValue(PlayerHealth, FixedBasePlayerHealth) float CurBasePlayerHealth2 = (Game.GetPlayer().GetValue("Health")) Debug.Notification("Player HP is fixed. current: " + CurBasePlayerHealth2 as int + " expected: " + FixedBasePlayerHealth as int) EndFunction GlobalVariable Property Player_Health_Broken Auto Const ;<--- this needs can't be constantEdited: Ugh... sorry for the duplicate posts... stupid internet.... Edited March 13, 2018 by GRock84 Link to comment Share on other sites More sharing options...
shavkacagarikia Posted March 13, 2018 Share Posted March 13, 2018 yes, terminal scripts can have only constant type properties. if you want to detect terminal entry selection and have non constant property, add script directly on terminal form and use OnMenuItemRun event. https://www.creationkit.com/fallout4/index.php?title=OnMenuItemRun_-_Terminal Link to comment Share on other sites More sharing options...
JonathanOstrus Posted March 13, 2018 Share Posted March 13, 2018 I think maybe someone is misunderstanding how const would affect a GlobalVariable property. Or rather how it won't. To do as it sounds like you described would work perfectly fine without it being const. The only purpose that having it const would provide, is that if you change *which* global the property points to in CK then the fragment would use the newly pointed to global. I don't remember if terminal fragment scripts are instanced each time they're run, like dialogue info topics are, or if they're instanced once and then reused. But either way, unless you change which global the property points to as the assignment of the property then it won't matter whether it's const or not. Link to comment Share on other sites More sharing options...
shavkacagarikia Posted March 13, 2018 Share Posted March 13, 2018 You cannot make fragment script properties non constant Link to comment Share on other sites More sharing options...
GRock84 Posted March 13, 2018 Author Share Posted March 13, 2018 (edited) Thank you all for the responses. I have updated my script to use OnMenuItemRun as shavkacagarikia suggested. It works great! But now I have uncovered another problem. When I try to display the value of my global var with "debug.notification" it literally returns "GlobalVariable". :huh: Possibly more, but I think there is a character limit or something. I'm not entirely sure. Function check_player_hp() float BaseEnd = (Game.GetPlayer().GetBaseValue(Endurance)) int playerlevel = Game.GetPlayer().GetLevel() float CurBasePlayerHealth = (Game.GetPlayer().GetValue(Health)) float FixedBasePlayerHealth = (80 + (BaseEnd * 5) + (playerlevel - 1) * (BaseEnd/2 + 2.5)) if (CurBasePlayerHealth == FixedBasePlayerHealth) Player_Health_Broken.SetValue(2) Debug.Notification("Player HP is OK. current: " + CurBasePlayerHealth as int + " expected: " + FixedBasePlayerHealth as int + " Player_Health_Broken: " + Player_Health_Broken) ; <--- this is where things get weird... else Player_Health_Broken.SetValue(1) Debug.Notification("Player HP is not OK. current: " + CurBasePlayerHealth as int + " expected: " + FixedBasePlayerHealth as int + " Player_Health_Broken: " + Player_Health_Broken) endif EndFunction GlobalVariable Property Player_Health_Broken Auto This is how it is declared in script. Edited March 13, 2018 by GRock84 Link to comment Share on other sites More sharing options...
shavkacagarikia Posted March 13, 2018 Share Posted March 13, 2018 You need to call getvalue method on your global variable and it will return its float value.Like,float val = myglobalproperty.getvalue() Link to comment Share on other sites More sharing options...
Recommended Posts