TangerineDog Posted October 25, 2017 Share Posted October 25, 2017 (edited) I'm trying to get this script to compile: Scriptname SleepCounterScript extends ActiveMagicEffectFloat WellRestedOverSpell Property pAbilityToRemove AutoFloat fSleepStartTimeFloat fWellRestedTimeFloat fWellRestedStartTimeFloat fSleepStopTimeEVENT OnEffectStart()RegisterForSleep()ENDEVENTEVENT OnUpdateGameTime()Game.GetPlayer().RemoveSpell(pAbilityToRemove)WellRestedOver = 1ENDEVENTEVENT OnSleepStart()fSleepStartTime = Utility.GetCurrentGameTime()ENDEVENTEVENT OnSleepStop()if (WellRestedOver == 1)fWellRestedTime = ((fSleepStopTime-fSleepStartTime)*24)RegisterForSingleUpdateGameTime(fWellRestedTime)WellRestedOver = 0fWellRestedStartTime = fSleepStopTimeelsefWellRestedTime = ((fSleepStopTime-fSleepStartTime)*24+fWellRestedTime-(fSleepStartTime-fWellRestedStartTime)*24)RegisterForSingleUpdateGameTime(fWellRestedTime)fWellRestedStartTime = fSleepStopTimeendifENDEVENT but all I get is this error message: E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\SleepCounterScript.psc(10,0): the parameter types of function oneffectstart in the empty state on script sleepcounterscript do not match the parent script activemagiceffectE:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\SleepCounterScript.psc(19,0): the parameter types of function onsleepstart in the empty state on script sleepcounterscript do not match the parent script activemagiceffectE:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\SleepCounterScript.psc(23,0): the parameter types of function onsleepstop in the empty state on script sleepcounterscript do not match the parent script activemagiceffectNo output generated for E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\SleepCounterScript.psc, compilation failed. So I guess I'm using the commands wrong... but why? EDIT: This compiles - will test it now. Scriptname SleepCounterScript extends ActiveMagicEffectFloat WellRestedOverSpell Property pAbilityToRemove AutoFloat fSleepStartTimeFloat fWellRestedTimeFloat fWellRestedStartTimeFloat fSleepStopTimeFUNCTION OnInit()RegisterForSleep()WellRestedOver = 1ENDFUNCTIONEVENT OnUpdateGameTime()Game.GetPlayer().RemoveSpell(pAbilityToRemove)WellRestedOver = 1ENDEVENTEVENT OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)fSleepStartTime = Utility.GetCurrentGameTime()ENDEVENTEVENT OnSleepStop(bool abInterrupted)if (WellRestedOver == 1)fWellRestedTime = ((fSleepStopTime-fSleepStartTime)*24)RegisterForSingleUpdateGameTime(fWellRestedTime)WellRestedOver = 0fWellRestedStartTime = fSleepStopTimeelsefWellRestedTime = ((fSleepStopTime-fSleepStartTime)*24+fWellRestedTime-(fSleepStartTime-fWellRestedStartTime)*24)RegisterForSingleUpdateGameTime(fWellRestedTime)fWellRestedStartTime = fSleepStopTimeendifENDEVENT Edited October 25, 2017 by TangerineDog Link to comment Share on other sites More sharing options...
JonathanOstrus Posted October 25, 2017 Share Posted October 25, 2017 I'm trying to follow the logic of the script to figure out what you're trying to do. From a glance it looks like you're trying to detect sleep and determine if the player slept long enough to get well rested? If so I think you have your logic wrong. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted October 25, 2017 Share Posted October 25, 2017 I think you should have a look in the vanilla script "ActiveMagicEffect.psc" to see what is a valid event. Scriptname SleepCounterScript extends ActiveMagicEffect ; Event received when this effect is first started (OnInit may not have been run yet!) Event OnEffectStart(Actor akTarget, Actor akCaster) EndEvent ; Event received when this effect is finished (effect may already be deleted, calling functions on this effect will fail) Event OnEffectFinish(Actor akTarget, Actor akCaster) EndEvent Link to comment Share on other sites More sharing options...
cdcooley Posted October 25, 2017 Share Posted October 25, 2017 That script has problems because it's in the OnSleepStop that you need to get the current time. The OnSleepStart gives you the current time as a parameter. Here's my rewrite which also eliminates your status variable and moves another that doesn't have to be global. I really like this idea. Scriptname SleepCounterScript extends ActiveMagicEffect Spell Property pAbilityToRemove Auto Float fSleepStartTime Float fWellRestedStartTime Float fWellRestedTime FUNCTION OnInit() RegisterForSleep() ENDFUNCTION EVENT OnUpdateGameTime() Game.GetPlayer().RemoveSpell(pAbilityToRemove) fWellRestedTime = 0.0 ENDEVENT EVENT OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime) fSleepStartTime = afSleepStartTime ENDEVENT EVENT OnSleepStop(bool abInterrupted) Float fSleepStopTime = Utility.GetCurrentGameTime() if fWellRestedTime > 0.0 fWellRestedTime = ((fSleepStopTime-fSleepStartTime)*24.0) + (fWellRestedTime-(fSleepStartTime-fWellRestedStartTime)*24.0) else fWellRestedTime = ((fSleepStopTime-fSleepStartTime)*24.0) endif RegisterForSingleUpdateGameTime(fWellRestedTime) fWellRestedStartTime = fSleepStopTime ENDEVENT Link to comment Share on other sites More sharing options...
Recommended Posts