i0Bjhansen0 Posted May 30, 2020 Share Posted May 30, 2020 I'm new to scripting and am having troubles trying to get a script to work. Or it's an issue with game settings.Here's the full script Scriptname PreservedPie_AddPerkPoint extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) int min = Game.GetGameSettingInt("iPPPPerkMinAmount") int max = Game.GetGameSettingInt("iPPPPerkMaxAmount") float total = 1.0 if (min > max) Game.AddPerkPoints(1) elseif (min == 0 || max == 0) Game.AddPerkPoints(1) elseif (min == max) Game.AddPerkPoints(min) total = min else int random = Utility.RandomInt(min,max) Game.AddPerkPoints(random) total = random endif Pie.Show(total) endEvent Message Property Pie Auto Const {Thanks to the wonderfully preserved nature of this pie, you have gained a perk point. Spend it wisely.} What it's supposed to do is get a random number between the "iPPPPerkMinAmount" game setting and "iPPPPerkMaxAmount" game setting and give perk points based on that number, while showing a message saying you got <number> perk points. The first 2 are error handlers (if min > max and if min or max equals 0 (which i'll probably change to be the non-zero number, but that's not for now). The third is if min equals max so it's just that number. But anyway, what it ends up doing is always giving one perk point and the message shows it gave 1 point. I tried GetGS iPPPPerkMaxAmount in the console and it gave me "NOT FOUND". It's in the mod and it's spelled correctly. It also is an int. I tried making it a property but there's no "game setting" or "setting" property. I pretty much wanted to make it so the user can easily change how many perk points they want, and if they want it to be random. What I didn't want to do was to have to make a ton of different scripts just to give everyone the values/ranges they want. Link to comment Share on other sites More sharing options...
dylbill Posted May 30, 2020 Share Posted May 30, 2020 (edited) Looks like your script should be working. If it's always giving 1 perk point, it probably means those game settings aren't registering. Instead you could use global variables. Scriptname PreservedPie_AddPerkPoint extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) int min = iPPPPerkMinAmount.GetValue() as int int max = iPPPPerkMaxAmount.GetValue() as int float total = 1.0 if (min > max) Game.AddPerkPoints(1) elseif (min == 0 || max == 0) Game.AddPerkPoints(1) elseif (min == max) Game.AddPerkPoints(min) total = min else int random = Utility.RandomInt(min,max) Game.AddPerkPoints(random) total = random endif Pie.Show(total) endEvent GlobalVariable Property iPPPPerkMinAmount Auto GlobalVariable Property iPPPPerkMaxAmount Auto Message Property Pie Auto Const {Thanks to the wonderfully preserved nature of this pie, you have gained a perk point. Spend it wisely.}Then you can make a config consumable or holotape to set the global variables. Or tell users to use the console command "Set iPPPPerkMinAmount To XX " to change the settings. Edited May 30, 2020 by dylbill Link to comment Share on other sites More sharing options...
i0Bjhansen0 Posted May 30, 2020 Author Share Posted May 30, 2020 [snip] It probably isn't registering because the console can't "find" them. I'm not sure why though, they are in the plugin. I tried with the FormID but that didn't work either. I was thinking of adding an ActorValue instead which would still require the console. I have no idea how to make a configurable consumable/holotape. [EDIT] I re-read your post. I kind of glanced over "Global Variable" since I'm not familiar with the term (I'm really not familiar with any aspect of papyrus). But I think I kind of understand what it means. Scriptname PreservedPie_AddPerkPoint extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) int min = PPPPerkMinValue.GetValue() as int int max = PPPPerkMaxValue.GetValue() as int int final = 1 if (min > 0 && max < 100) final = Utility.RandomInt(min,max) else final = 1 endif float total = final Game.AddPerkPoints(final) Pie.Show(total) endEvent Message Property Pie Auto Const {Thanks to the wonderfully preserved nature of this pie, you have gained a perk point. Spend it wisely.} GlobalVariable Property PPPPerkMinValue Auto Const GlobalVariable Property PPPPerkMaxValue Auto Const Here's my optimized version. I was wondering if it would be possible somehow to get rid of "float total = final" somehow. But "Show()" doesn't accept ints as the argument.[Edit] I ended up answering my own question. I looked up "casting" and tried "Pie.Show(final as float)" and that ended up working for the compiler. Link to comment Share on other sites More sharing options...
i0Bjhansen0 Posted May 30, 2020 Author Share Posted May 30, 2020 Ok so doing a global variable is working. But I can't seem to figure out how to edit it from the console. I tried a couple different ways but either they didn't have the intended effect or they came with an error. Link to comment Share on other sites More sharing options...
dylbill Posted May 30, 2020 Share Posted May 30, 2020 (edited) To get rid of float total = final, just use a debug.messagbox or debug.notification instead of the message. Scriptname PreservedPie_AddPerkPoint extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) int min = PPPPerkMinValue.GetValue() as int int max = PPPPerkMaxValue.GetValue() as int int final = 1 if (min > 0 && max < 100) final = Utility.RandomInt(min,max) else final = 1 endif Game.AddPerkPoints(final) Debug.Notification("Thanks to the wonderfully preserved nature of this pie, you have gained " + final + " perk points. Spend it wisely.") endEvent Message Property Pie Auto ;Const {Thanks to the wonderfully preserved nature of this pie, you have gained a perk point. Spend it wisely.} GlobalVariable Property PPPPerkMinValue Auto GlobalVariable Property PPPPerkMaxValue Auto To add a consumable config, you basically do the same thing you're doing with the pie and use an OnEffectStart script with a message. Make sure your config message has the MessageBox option checked in the CK. Add button text options for different configs. The script would look something like this: Scriptname PreservedPie_Config extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) Menu() ;open menu Game.GetPlayer().AddItem(PieConfigConsumable, 1) ;adds the config consumable back to the player after they consume it. endEvent Function Menu() Int Button = PieConfig.Show() If Button == 0 ;Increase minmum by 1 PPPPerkMinValue.Mod(1) Elseif Button == 1 ;Increase minmum by 5 PPPPerkMinValue.Mod(5) Elseif Button == 2 ;Decrease minmum by 1 PPPPerkMinValue.Mod(-1) Elseif Button == 3 ;Decrease minmum by 5 PPPPerkMinValue.Mod(-5) ElseIf Button == 4 ;Increase Maximum by 1 PPPPerkMaxValue.Mod(1) Elseif Button == 5 ;Increase Maximum by 5 PPPPerkMaxValue.Mod(5) Elseif Button == 6 ;Decrease Maximum by 1 PPPPerkMaxValue.Mod(-1) Elseif Button == 7 ;Decrease Maximum by 5 PPPPerkMaxValue.Mod(-5) Endif If PPPPerkMinValue.GetValue() < 0 PPPPerkMinValue.SetValue(0) Endif If PPPPerkMaxValue.GetValue() < 0 PPPPerkMaxValue.SetValue(0) Endif If PPPPerkMinValue.GetValue() > PPPPerkMaxValue.GetValue() PPPPerkMinValue.SetValue(PPPPerkMaxValue.GetValue()) Endif If Button < 8 ;re-open menu. Set button 8 in the message to close or cancel Menu() Endif EndFunction Potion Property PieConfigConsumable Auto Message Property PieConfig Auto Const GlobalVariable Property PPPPerkMinValue Auto GlobalVariable Property PPPPerkMaxValue Auto Edited May 30, 2020 by dylbill Link to comment Share on other sites More sharing options...
i0Bjhansen0 Posted May 30, 2020 Author Share Posted May 30, 2020 [snip] I ended up figuring out how to get rid of that part. I just didn't want to put the text in the script in case I needed to edit the message but didn't want to go through the Creation Kit.I'll try to figure out the consumable sometime tomorrow. I still have a couple things I need to fix but thanks a lot for the help. Still curious as to why the game setting wasn't actually working. Link to comment Share on other sites More sharing options...
Recommended Posts