Magnusen2 Posted October 3, 2016 Share Posted October 3, 2016 (edited) Scriptname xxxGiantScaleScript Extends Actor Race Property NordRace Auto EVENT OnInit() Race NPCRace = GetRace() if NPCRace == NordRace float RandomScale = Utility.RandomFloat(2.40, 2.60) setScale(RandomScale) ;debug.notification("Giant Scale Modified") endif endEVENT The script above is attached to a actor (which pulls the traits/models/animations from a leveled list) and it is supposed to change their scale if the actor is from the Nord Race, but it doesn't get applied when the actor spawned is a Nord. Any help on this? Edited October 3, 2016 by Magnusen2 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 3, 2016 Share Posted October 3, 2016 You have to call GetRace() on an actor. Right now it is trying to use Self by default but Self is a script. Change it to: Race NPCRace = (Self as Actor).GetRace()See if that works for you. Link to comment Share on other sites More sharing options...
lofgren Posted October 3, 2016 Share Posted October 3, 2016 You have to call GetRace() on an actor. Right now it is trying to use Self by default but Self is a script. Change it to: Race NPCRace = (Self as Actor).GetRace()See if that works for you. Self refers to the object that the script is attached to, so in this case self is an actor. Self is never a script. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 3, 2016 Share Posted October 3, 2016 Self refers to the object that the script is attached to, so in this case self is an actor. Self is never a script. Maybe my memory is faulty. I could have sworn that I couldn't get some functions that should have ran on the type of object I was using without first casting Self into that object type.In any event, it wouldn't hurt as a quick test yielded that Self.GetName() and (Self as ReferenceAlias).GetName() have the same result for a reference alias on a quest. I suppose if it is not a casting issue, if could be possible that the OnInit() event is processing before the actor is fully loaded. And for some things, that can be an issue. To test for that, you can register for a single update and run the code in the update event instead. Link to comment Share on other sites More sharing options...
thumbincubation Posted October 4, 2016 Share Posted October 4, 2016 HI again. Working on a small mod to give Kharjo a few followers of his own. Right now, I have them on an AI package to follow, and in the khajiit caravan faction. If their package just uses Kharjo as the reference link to be followed, will that conflict with other mods that affect Kharjo? Or am I safe as long as I don't change him directly? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 4, 2016 Share Posted October 4, 2016 HI again. Working on a small mod to give Kharjo a few followers of his own. Right now, I have them on an AI package to follow, and in the khajiit caravan faction. If their package just uses Kharjo as the reference link to be followed, will that conflict with other mods that affect Kharjo? Or am I safe as long as I don't change him directly?I don't think it would be an issue. Then again, I've never done anything like that. Wouldn't hurt to test it out. Make a second temporary mod that changes Kharjo and see how it affects your actual mod. Link to comment Share on other sites More sharing options...
Magnusen2 Posted October 4, 2016 Share Posted October 4, 2016 Thanks.Still didn't work. I got another issue.What i'm trying to do:A set of sliders in which the user can determine the scale of actors when they spawn. The problem:As soon as one of the actors that has the script is spawned, they are "invisible". They can still taunt (in the case of enemies) and followers/summons attack them. I suspect that their scale was set to a very small value (even though i set it to be normal size) due to my lack of knowledge when dealing with floats.Here's the MCM code snippet: GlobalVariable Property xxxNPCHeightMin Auto ;global that controls the minimum scale GlobalVariable Property xxxNPCHeightMax Auto ;global that controls the maximum scale ;OnOptionSliderOpen event elseif (a_option == _NPCHeightMin) SetSliderDialogStartValue(xxxNPCHeightMin.GetValue() as float) SetSliderDialogDefaultValue(0.93) SetSliderDialogRange(0.70, 1.50) SetSliderDialogInterval(0.01) elseif (a_option == _NPCHeightMax) SetSliderDialogStartValue(xxxNPCHeightMax.GetValue() as float) SetSliderDialogDefaultValue(1.07) SetSliderDialogRange(0.70, 1.50) SetSliderDialogInterval(0.01) ;OnOptionSliderAccept event elseif (a_option == _NPCHeightMin) xxxNPCHeightMin.SetValue(a_value) SetSliderOptionValue(a_option, a_value) ValidateNPCHeightMin() ;calls a function that checks if the minimum value is greater than the maximum. If so, make the minimum match the maximum value elseif (a_option == _NPCHeightMax) xxxNPCHeightMax.SetValue(a_value) SetSliderOptionValue(a_option, a_value) ValidateNPCHeightMax() ;calls a function that checks if the maximum value is smaller than the minimum. If so, make the maximum match the minimum value ;validation functions Function ValidateNPCHeightMin() if (xxxNPCHeightMin.GetValue() as float > xxxNPCHeightMax.GetValue() as float) xxxNPCHeightMin.SetValue(xxxNPCHeightMax.GetValue() as float) setSliderOptionValue(_NPCHeightMin, xxxNPCHeightMin.GetValue() as float) endif EndFunction Function ValidateNPCHeightMax() if (xxxNPCHeightMax.GetValue() as float < xxxNPCHeightMin.GetValue() as float) xxxNPCHeightMax.SetValue(xxxNPCHeightMin.GetValue() as float) setSliderOptionValue(_NPCHeightMax, xxxNPCHeightMax.GetValue() as float) endif EndFunction And here's the code attached to the actor: Scriptname xxxNPCScaleScript Extends Actor GlobalVariable Property xxxNPCHeightMin Auto ;global that controls the minimum scale GlobalVariable Property xxxNPCHeightMax Auto ;global that controls the maximum scale EVENT OnInit() float Min = xxxNPCHeightMin.GetValue() as float float Max = xxxNPCHeightMax.GetValue() as float float RandomScale = Utility.RandomFloat(Min, Max) setScale(RandomScale) ;debug.notification("NPC Scale Modified") endEVENT So the questions:1. Before i got the idea of a MCM i attached the script above but instead of using Globals to get the values for the RandomFloat i used numbers (e.g. Utility.RandomFloat(0.93, 1.07)). Everything worked perfectly. Why it doesn't work now? 2. In the log i get lots of "Cannot call GetValue() on a None object". Why? 3. When i open the MCM, the slider values are working as intended. But as soon as i modify one and accept, the float values are "reset" to a whole number (e.g. 1.07 becomes 1). This continues no matter what value is set. Only when the menu is reopened that the values appears as float again. Looking at the code above, why is this happening? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 4, 2016 Share Posted October 4, 2016 #2Are you assigning the global variable properties in the Creation Kit? An error of 'cannot call GetValue() on a None object' typically indicates that the property variable intended to contain the global variable does not have a global variable assigned to it. Why are you using things like: SomeVar.GetValue() as floatGetValue() automatically returns a float. You do not need to cast it. As far as questions 1 or 3. Those can't really be answered with just the snippets that are there. MCM scripts are very interconnected with parts for each option spread throughout the script. A little less spread out if using the State method, but still spread out. Link to comment Share on other sites More sharing options...
Magnusen2 Posted October 5, 2016 Share Posted October 5, 2016 (edited) Are you assigning the global variable properties in the Creation Kit? An error of 'cannot call GetValue() on a None object' typically indicates that the property variable intended to contain the global variable does not have a global variable assigned to it.Yes. With every actor that have the script (about 40+). But the log still gets spammed with errors.The NPCs still are invisible.Why are you using things like: SomeVar.GetValue() as floatGetValue() automatically returns a float. You do not need to cast it.Sorry. I didn't know.As far as questions 1 or 3. Those can't really be answered with just the snippets that are there. MCM scripts are very interconnected with parts for each option spread throughout the script. A little less spread out if using the State method, but still spread out.I was able to fix Issue #3 by replacing:This: SetSliderOptionValue(a_option, a_value) With this: SetSliderOptionValue(a_option, a_value, "{2}") Now when the slider is set 2 extra decimals appear.Below is the code with more structure. scriptname xxxMCMScript extends SKI_ConfigBase import Game import Utility String ModName GlobalVariable Property xxxNPCHeightMin Auto ;global that controls the minimum scale GlobalVariable Property xxxNPCHeightMax Auto ;global that controls the maximum scale ;Slider ints int _NPCHeightMin int _NPCHeightMax Event OnConfigInit() Pages = new String[2] Pages[0] = "$SDO_Page1" Pages[1] = "$SDO_Page2" EndEvent event OnPageReset(string page) ;{Called when a new page is selected, including the initial empty page} SetCursorFillMode(TOP_TO_BOTTOM) ;sets what appears when no page is selected If page == "" LoadCustomContent("logo.dds") Return Else UnloadCustomContent() EndIf if page == "$SDO_Page1" AddHeaderOption("$SDO_Height") _NPCHeightMin = AddSliderOption("$SDO_NPCHeightMin", xxxNPCHeightMin.GetValue(), "{2}") _NPCHeightMax = AddSliderOption("$SDO_NPCHeightMax", xxxNPCHeightMax.GetValue(), "{2}") elseif page == "$SDO_Page2" AddHeaderOption("$SDO_Page2") _Debug = AddTextOption("$SDO_Page2", "") AddEmptyOption() _Uninstall = AddTextOption("$SDO_Uninstall", "") endif EndEvent event OnOptionSliderOpen(int a_option) if (a_option == _NPCHeightMin) SetSliderDialogStartValue(xxxNPCHeightMin.GetValue()) SetSliderDialogDefaultValue(0.93) SetSliderDialogRange(0.70, 1.50) SetSliderDialogInterval(0.01) elseif (a_option == _NPCHeightMax) SetSliderDialogStartValue(xxxNPCHeightMax.GetValue()) SetSliderDialogDefaultValue(1.07) SetSliderDialogRange(0.70, 1.50) SetSliderDialogInterval(0.01) endif EndEvent Event OnOptionSliderAccept(int a_option, float a_value) {Called when the user accepts a new slider value} if (a_option == _NPCHeightMin) xxxNPCHeightMin.SetValue(a_value) SetSliderOptionValue(a_option, a_value) ValidateNPCHeightMin() ;calls a function that checks if the minimum value is greater than the maximum. If so, make the minimum match the maximum value elseif (a_option == _NPCHeightMax) xxxNPCHeightMax.SetValue(a_value) SetSliderOptionValue(a_option, a_value) ValidateNPCHeightMax() ;calls a function that checks if the maximum value is smaller than the minimum. If so, make the maximum match the minimum value endif EndEvent ;============================================================= ; Height validation functions. ;============================================================= ; If the minimum height is set by the user to a value ; bigger than the maximum height, sets the minimum ; height to the maximum height value. ;============================================================= ; If the maximum height is set by the user to a value ; smaller than the minimum height, sets the maximum ; height to the minimum height value. ;============================================================= Function ValidateNPCHeightMin() if (xxxNPCHeightMin.GetValue() > xxxNPCHeightMax.GetValue()) xxxNPCHeightMin.SetValue(xxxNPCHeightMax.GetValue()) setSliderOptionValue(_NPCHeightMin, xxxNPCHeightMin.GetValue()) endif EndFunction Function ValidateNPCHeightMax() if (xxxNPCHeightMax.GetValue() < xxxNPCHeightMin.GetValue()) xxxNPCHeightMax.SetValue(xxxNPCHeightMin.GetValue()) setSliderOptionValue(_NPCHeightMax, xxxNPCHeightMax.GetValue()) endif EndFunction Maybe this is happening because the script attached extends as Actor? Edited October 5, 2016 by Magnusen2 Link to comment Share on other sites More sharing options...
thumbincubation Posted October 5, 2016 Share Posted October 5, 2016 I don't think it would be an issue. Then again, I've never done anything like that. Wouldn't hurt to test it out. Make a second temporary mod that changes Kharjo and see how it affects your actual mod. Awesome. I should have thought of that. Sorry. Am going to give it a shot. Link to comment Share on other sites More sharing options...
Recommended Posts