kflip101 Posted July 6, 2018 Share Posted July 6, 2018 Hi everyone, First off, im new to papyrus scripting, so there's a good chance im doing obviously wrong and am completely blind to it. My goal is to create a terminal that when pressing a menu item, changes a global variable based on a formula. So I create a papyrus fragment for that menu item. After some fiddling around and learning papyrus syntax and functions, I got it to compile without errors. Here's the script: ;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment Scriptname Fragments:Terminals:TERM_SPECIALsUpgraded_Termin_04004C50 Extends Terminal Hidden Const ;BEGIN FRAGMENT Fragment_Terminal_01 Function Fragment_Terminal_01(ObjectReference akTerminalRef) ;BEGIN CODE If (Game.GetPlayer().GetLevel() <= ((SPECIALsUpgraded_MaxUpgrades.GetValueInt() * 2) + 1 )) SPECIALsUpgraded_UpgradesAvailable.SetValue(SPECIALsUpgraded_UpgradesUsed.GetValueInt() - Math.Floor((Game.GetPlayer().GetLevel() - 1) / SPECIALsUpgraded_LevelsPerUpgrades.GetValueInt()) as float) EndIf ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment GlobalVariable Property SPECIALsUpgraded_UpgradesAvailable Auto Const Mandatory GlobalVariable Property SPECIALsUpgraded_UpgradesUsed Auto Const Mandatory GlobalVariable Property SPECIALsUpgraded_MaxUpgrades Auto Const Mandatory GlobalVariable Property SPECIALsUpgraded_LevelsPerUpgrades Auto Const Mandatory Now I had to go in game and test to see if it worked. The terminal loads, menu item appears, response text appears when clicking the menu item, global variable does not change......... :dry:I wasn't sure if my logic was correct or not so I changed the fragment to be this instead: SPECIALsUpgraded_UpgradesAvailable.SetValue(2) Exact same thing happens, global does not change....... :wallbash: (<----sums up my current emotions) So I have no idea why this is not working. I hoping someone will know and help me out :ohdear: Link to comment Share on other sites More sharing options...
Magicockerel Posted July 6, 2018 Share Posted July 6, 2018 Enable logging and add the following to your fragment (before and after): Debug.Trace("Value = " + SPECIALsUpgraded_UpgradesAvailable.GetValue())Or don't enable logging and use Debug.Notification or Debug.MessageBox. If it doesn't show up, then you're not running the fragment. If it does and it doesn't change, then take a look at your equation. By the sounds of things, the equation isn't the issue. I'd also make sure that you've assigned your properties, and they're not just blank. If you haven't, then that's why the values aren't changing. That is, open the property window next to the list of scripts. Auto-fill will work if the form names are the property names, otherwise you'll have to manually assign them. Link to comment Share on other sites More sharing options...
kflip101 Posted July 6, 2018 Author Share Posted July 6, 2018 Thanks!Checked the properties, all are linking to the correct global variables. Ran the debug, only showed one occurrence regarding my mod: Cannot open store for class "Fragments:Terminals:TERM_SPECIALsUpgraded_Termin_04004C50", missing file? This just made me even more clueless than before....again new to papyrus scripting XD Checked the folders where my script is : M:\SteamLibrary\steamapps\common\Fallout 4\Data\Scripts\Fragments\Terminals\TERM_SPECIALsUpgraded_Termin_04004C50.pex Link to comment Share on other sites More sharing options...
SKKmods Posted July 6, 2018 Share Posted July 6, 2018 Have you a) been editing the code in the tiny little editing window on the terminal form, or b) externally in a text editor ? Your symptoms are similar to b) "Do not edit anything between this and the end comment" Link to comment Share on other sites More sharing options...
werr92 Posted July 6, 2018 Share Posted July 6, 2018 (edited) Does your GlobalVariable has a "Const" flag? I'm talking not about a property flag, but about the GlobalVariable as CK object. If so, untick it, because the value of a variable with the "Const" flag can't be changed through script. Although it will compile with no probs, the actual value won't be touched. p.s. Do you have bInvalidateOlderFiles = 1 in Fallout4.ini file? Edited July 6, 2018 by werr92 Link to comment Share on other sites More sharing options...
kflip101 Posted July 6, 2018 Author Share Posted July 6, 2018 Thanks everyone for your help! Found the problem, Fallout4.ini file did not have bInvalidateOlderFiles = 1. I now remember having to reset all my inis due to another issue and forgot to re-add that entry :sweat: Lesson learned to always check the basics.Everything's working perfect now, thanks guys! :laugh: Link to comment Share on other sites More sharing options...
Magicockerel Posted July 6, 2018 Share Posted July 6, 2018 I'd recommend using BethINI to edit your config files, as it allows you to quickly edit settings and a simple GUI to see what you have and haven't got enabled. There are occasions when I still need to manually edit the config files, but they are few and far between. It's especially useful when you're new to tampering with your config files. To enable mods with BethINI, all you have to do is check a box - same with enabling logging, etc. Link to comment Share on other sites More sharing options...
Recommended Posts