SkjoldBjorn Posted August 20, 2015 Author Share Posted August 20, 2015 Already tried that and did'nt work so i thought that did not auto-fill working was symptomatic. Mine is an Xmarker. made that the reference and no change.But i found out what was wrong though. I had added Stuff like this: event OnOptionSliderAccept(int option, float value) if (option == LightsOnOID_S) LightsOnTime = value SetSliderOptionValue(LightsOnOID_S, LightsScript.LightsOnTime, "{0} o'clock") and thought i had put everything as it should be, everything compiled like it should. but taking a closer look after you facedpalmed me, i thought, yeah I'm missing something stupid and did this: event OnOptionSliderAccept(int option, float value) if (option == LightsOnOID_S) LightsScript.LightsOnTime = value SetSliderOptionValue(LightsOnOID_S, LightsOnTime, "{0} o'clock") Now it works, i simply forgot to configure the int option properly! /facepalm I tested ingame, it works, but the script have some troubble firing the lights the first time, i had to wait 24 hours to get it to fire properly. This was normal in the mod without any MCM menu. But! Since im talking to scripters of godly skills, is it possible to add something to the script to make it check more often? The lights sometimes just does'nt fire at all if you have left skyrim worldspace to say...dawnguard worldspace and back for example, if i could make it force check a little more often... right now It's using a simple Function RegisterForSingleUpdateGameTimeAt(float GameTime) and float CurrentTime = GetCurrentHourOfDay() If (GameTime < CurrentTime) GameTime += 24 EndIf Link to comment Share on other sites More sharing options...
scrivener07 Posted August 20, 2015 Share Posted August 20, 2015 I dont know, maybe something weird happens with changing worldspaces and game times. You can try a hacky forceful approach. Add this to your config menu to see if that re-jiggers it. lol; @implements SKI_ConfigBase Event OnConfigClose() {Called when the config menu is closed.} LightScript.OnInit() EndEvent edit: I wouldnt leave it like this for a release. It will re-initialize the light script everytime you close the menu. Just use it to see if that helps with moving between worldspaces. Link to comment Share on other sites More sharing options...
SkjoldBjorn Posted August 21, 2015 Author Share Posted August 21, 2015 Function GetCurrentWeather() {Checks the local Weather, bad weather should trigger and enable fires and lights} If Weather.GetCurrentWeather().GetClassification() == 2 GoToState ("LightsOff") Else Weather.GetCurrentWeather().GetClassification() == 3 GoToState ("LightsOff") EndIf EndFunction Thinking about adding bad weather into the mix as well, tried to add this sippet of code to the script, but it did not work like i thought it would. Is it better to add this to an "scriptname extends otherLightscript"?Would be easier to test thing that way at least, keeping the original script as one purpose only and just expand upon that in other scripts. The original for reference: Scriptname ImmersiveContentLightMasterParent extends ObjectReference {Controls a set of lights with a master enable parent marker with this script attached to turn on and off at the times of the day specified by the properties LightsOffTime and LightsOnTime} float Property LightsOffTime = 6.0 auto {The time at which lights should be turned off} float Property LightsOnTime = 20.0 auto {The time at which lights should be turned on} float Function GetCurrentHourOfDay() global {Returns the current time of day in hours since midnight} float Time = Utility.GetCurrentGameTime() Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit Time *= 24 ; Convert from fraction of a day to number of hours Return Time EndFunction Function RegisterForSingleUpdateGameTimeAt(float GameTime) {Registers for a single UpdateGameTime event at the next occurrence of the specified GameTime (in hours since midnight)} float CurrentTime = GetCurrentHourOfDay() If (GameTime < CurrentTime) GameTime += 24 EndIf RegisterForSingleUpdateGameTime(GameTime - CurrentTime) EndFunction State LightsOff Event OnBeginState() Disable() RegisterForSingleUpdateGameTimeAt(LightsOnTime) EndEvent Event OnUpdateGameTime() GoToState("LightsOn") debug.notification("Lights are turning on") EndEvent EndState State LightsOn Event OnBeginState() Enable() RegisterForSingleUpdateGameTimeAt(LightsOffTime) EndEvent Event OnUpdateGameTime() GoToState("LightsOff") debug.notification("Lights are turning off") EndEvent EndState I probably should have made a new thread about that, this thread has probably went far off It's Topic already... Link to comment Share on other sites More sharing options...
scrivener07 Posted August 21, 2015 Share Posted August 21, 2015 I think it would be easier to just put it in the light script. At what point are you calling "GetCurrentWeather()" and where is the OnInit from the original script? Link to comment Share on other sites More sharing options...
SkjoldBjorn Posted August 22, 2015 Author Share Posted August 22, 2015 Once again i stand there like a stump with no answer, you know what, i don't know, i thought calling the function was what i just did, i thought that if i wanted to add something to the excisting script that a function and GoToState ("otherscriptsstate"). I thought I'd first make a property to get the weather from, but since i Only want weather classifiactions and not a specific weather i crossed that off..think the script would be a mess if i did anyway. Okay, so the thought was that it would be practical to disable the weather check through MCM if a player think It's unnecessary. I'm going through a lot of tutorials to understand papyrus a little better than i did. There are some stuff that still don't make a 100% sense to me, like when you stuff things into brackets () etc. but I'm learning. Also, my script runs from an object, what is considered "best practice" here, using a Quest Script Event and just add the objects to the Quest Alias list? The script runs fin as it is on the Xmarker though, no doubt about that. Link to comment Share on other sites More sharing options...
Mattiewagg Posted August 22, 2015 Share Posted August 22, 2015 When you put stuff into brackets, you're giving parameters. A function could be declared like this: Function myFunction(int firstNum, int secondNum, bool stop) ;some stuffEndFunction In order to call myFunction, you have to let it know what those values are found to be (firstNum, secondNum, stop). So: myFunctiom(1, 4, false) Another example, with a function that adds two numbers: Function addNums(int a, int b) Return a + bEndFunction If you wanted to add 7 and 3, you'd call: addNums(7, 3) Make sense? The brackets are there to let the system know where the parameters should be. Link to comment Share on other sites More sharing options...
SkjoldBjorn Posted August 22, 2015 Author Share Posted August 22, 2015 So simply put a parameter in those brackets are an expansion of the function, but not necessarely mandatory? Like a simple debug message: debug.notification("Good Morning!!") Where Good morning is the ("string") parameter of it, but not mandatory for the command to run..but without it, it will show no message, so quite useless. Alright, i think i understand it. But you also have Functions like GetCurrentWeather() that still has brackets at the end, but there are no known parameters for it on the wiki, but you can probably define some yourself as well? I work as an IT-Consultant, so i know how you guys feel when a newbface is having a hard time understanding the stuff you are trying to explain, sorry about that. But I am Really really thankful for the help i get! :smile:Code is intimidating as hell, there is a reason why i have kept myself to basic knowledge and just copy pasting code snippet and compile and test with trial and error. Even Powershell can be quite the pain sometimes for me. >.< Link to comment Share on other sites More sharing options...
Mattiewagg Posted August 22, 2015 Share Posted August 22, 2015 (edited) No, it's required for Debug.Notification. Unless specifically a default parameter, it is required. You can't just add parameters when you're calling a function. You can only put in parameters for declared/defined parameters, so you couldn't define a parameter for GetCurrentWeather(). It's JUST GetCurrentWeather(). Edited August 22, 2015 by Mattiewagg Link to comment Share on other sites More sharing options...
scrivener07 Posted August 22, 2015 Share Posted August 22, 2015 Its no problem at all. We have all been there before, it is quite intimidating at first. Most of us have endless patience as long as the OP is demonstrating a desire to learn and puts their own efforts towards it. There is such a thing as optional parameters but normally they are all required. Maybe I should go over the anatomy of a Function for you.A function is a type of procedure that executes a series of commands, often calling other functions. Functions typically accept an input value and output a result value. int Function Sum(int aiFirst, int aiSecond) return aiFirst + aiSecond EndFunction This function accepts two input values of type integer and outputs and integer result. The result is called the 'return value' and the inputs are called the 'parameters'. The return value must always be of the type specified in the functions 'signature', by that I mean its shape. In this case the signature looks like "int Function(int, int)" where the return type prefixes the signature. Functions dont do anything on their own. They must be called/invoked in some way. This invocation is always done from other functions or "calling code". Using the example above some calling code my look like this. Event OnTutorial() ; I am the calling code int iResult = Sum(1, 2) Debug.MessageBox("1 + 2 is equal to '" + iResult + "'") EndEvent int Function Sum(int aiFirst, int aiSecond) return aiFirst + aiSecond EndFunction You can see in the calling code I have called the function by supplying two input values and got a return value of 3. But what about these optional parameters? You must be wondering why there are some functions that have many parameters but only require some of them. These are the optional parameters and they are created by providing the input value built into the functions signature. Event OnTutorial() int iResult1 = Sum(1, 2) Debug.MessageBox("1 + 2 is equal to '" + iResult1 + "'") int iResult2 = Sum(1) Debug.MessageBox("1 + 10 is equal to '" + iResult2 + "'") ; int iResult3 = Sum() ; ERROR! This will not compile. It has been commented out. EndEvent int Function Sum(int aiFirst, int aiSecond = 10) return aiFirst + aiSecond EndFunction So the rule holds true. ALL parameters declared in the functions signature must be provided a value. In the case of optional parameters the provided value in built into the signature and will be used automatically unless overridden with a value from the calling code. I think Ill stop here before this post gets to lengthy but feel free for follow up questions. Link to comment Share on other sites More sharing options...
Mattiewagg Posted August 22, 2015 Share Posted August 22, 2015 I was on my phone when I wrote mine and was going to come back for wall of text, but Scrivener did an admirable job, so I'll just let that stand on its own. :) Link to comment Share on other sites More sharing options...
Recommended Posts