Jump to content

Quick Questions, Quick Answers


Mattiewagg

Recommended Posts

Okay, i have no answer to those above as i do little quest modding, but I have yet another question to add to this pool.

 

I have a mod that enable and disables lights in all of skyrim night/day. I have now decided to extend the quest to be affected by rain and snow as well.

Here is the script:

 

 

 

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 BadWeatherCheck()
  RegisterForSingleUpdate(30.0) ; Give us a single update in 30 second
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

Event OnInit()
 
	IF(GetCurrentHourOfDay() > LightsOffTime)
		GoToState("LightsOff")
	Else
		GoToState("LightsOn")
	EndIf
 
EndEvent

Event OnUpdate()
;Checks for bad weather, only updates every 30 seconds to prevent savegame bloating.
	Bool bKeepUpdating = True
		If Weather.GetCurrentWeather().GetClassification() >= 2
			GoToState("LightsOn")
		Else
			GoToState("LightsOff")
		EndIf

	If bKeepUpdating
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent

State LightsOff
 
	Event OnBeginState()
		Disable()
		RegisterForSingleUpdateGameTimeAt(LightsOnTime)
	EndEvent
 
	Event OnUpdateGameTime()
		GoToState("LightsOn")
	EndEvent
 
EndState
 
State LightsOn
 
	Event OnBeginState()
		Enable()
		RegisterForSingleUpdateGameTimeAt(LightsOffTime)
	EndEvent
 
	Event OnUpdateGameTime()
		GoToState("LightsOff")
	EndEvent
 
EndState

 

 

 

I probably need to modify this abit to work properly with my script. found the code snippet on the wiki, i just customized it a little. I actually consider using a script extender for the weather control so one can decide if one want the weather stuff or not when using my mod.

 

the get.classification snip works, tested it in the "OnInit" and it properly changes state to lights on if the weather is bad when you load the game. so i know it's the OnUpdate part of my script that i somehow borked. Compiles just fine.

 

Thanks people! :smile:

What exactly is your question? I think I missed it in there somewhere. What is the script doing that it should not be doing?

 

But if I had to guess... You have a function to check for bad weather which registers for an update and keeps repeating itself every 30 seconds due to nothing changing the governing bool variable. However, nothing is calling the function into play and as such the update event is not being triggered. Furthermore your other registration events are using game time and so you need to use the OnUpdateGameTime event to process those registrations.

Link to comment
Share on other sites

  • Replies 2.6k
  • Created
  • Last Reply

Top Posters In This Topic

 

Okay, i have no answer to those above as i do little quest modding, but I have yet another question to add to this pool.

 

I have a mod that enable and disables lights in all of skyrim night/day. I have now decided to extend the quest to be affected by rain and snow as well.

Here is the script:

 

 

 

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 BadWeatherCheck()
  RegisterForSingleUpdate(30.0) ; Give us a single update in 30 second
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

Event OnInit()
 
	IF(GetCurrentHourOfDay() > LightsOffTime)
		GoToState("LightsOff")
	Else
		GoToState("LightsOn")
	EndIf
 
EndEvent

Event OnUpdate()
;Checks for bad weather, only updates every 30 seconds to prevent savegame bloating.
	Bool bKeepUpdating = True
		If Weather.GetCurrentWeather().GetClassification() >= 2
			GoToState("LightsOn")
		Else
			GoToState("LightsOff")
		EndIf

	If bKeepUpdating
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent

State LightsOff
 
	Event OnBeginState()
		Disable()
		RegisterForSingleUpdateGameTimeAt(LightsOnTime)
	EndEvent
 
	Event OnUpdateGameTime()
		GoToState("LightsOn")
	EndEvent
 
EndState
 
State LightsOn
 
	Event OnBeginState()
		Enable()
		RegisterForSingleUpdateGameTimeAt(LightsOffTime)
	EndEvent
 
	Event OnUpdateGameTime()
		GoToState("LightsOff")
	EndEvent
 
EndState

 

 

 

I probably need to modify this abit to work properly with my script. found the code snippet on the wiki, i just customized it a little. I actually consider using a script extender for the weather control so one can decide if one want the weather stuff or not when using my mod.

 

the get.classification snip works, tested it in the "OnInit" and it properly changes state to lights on if the weather is bad when you load the game. so i know it's the OnUpdate part of my script that i somehow borked. Compiles just fine.

 

Thanks people! :smile:

What exactly is your question? I think I missed it in there somewhere. What is the script doing that it should not be doing?

 

But if I had to guess... You have a function to check for bad weather which registers for an update and keeps repeating itself every 30 seconds due to nothing changing the governing bool variable. However, nothing is calling the function into play and as such the update event is not being triggered. Furthermore your other registration events are using game time and so you need to use the OnUpdateGameTime event to process those registrations.

 

 

You guessed it right currently the functions of the script disable and enable lights, this works as intended, but i want the lights to turn on if the weather is bad during the day too, I thought i called the function when I used the

Event OnUpdate()
;Checks for bad weather, only updates every 30 seconds to prevent savegame bloating.
	Bool bKeepUpdating = True
		If Weather.GetCurrentWeather().GetClassification() >= 2
			GoToState("LightsOn")
		Else
			GoToState("LightsOff")
		EndIf

	If bKeepUpdating
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent

The other stuff runs as it should though, no problems there. Lights go on and off when they should :smile:

Link to comment
Share on other sites

So I'm working on a custom spell. I've made the spell itself, a spell tome that teaches the spell, and added the spell tome to level list so it can be found as loot or bought... However, when I get in game and buy the spell tome, the message appears saying that I've learned the spell; but when I go to find it in my spellbook, it's not there.

Any ideas what could cause this, and how to fix it?

It is possible your spell is not configured properly. Perhaps "EquipType" (ETYP), or the Cast Type (part of SPIT).

Link to comment
Share on other sites

 

 

 

 

Okay, i have no answer to those above as i do little quest modding, but I have yet another question to add to this pool.

 

I have a mod that enable and disables lights in all of skyrim night/day. I have now decided to extend the quest to be affected by rain and snow as well.

Here is the script:

 

 

 

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 BadWeatherCheck()
  RegisterForSingleUpdate(30.0) ; Give us a single update in 30 second
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

Event OnInit()
 
	IF(GetCurrentHourOfDay() > LightsOffTime)
		GoToState("LightsOff")
	Else
		GoToState("LightsOn")
	EndIf
 
EndEvent

Event OnUpdate()
;Checks for bad weather, only updates every 30 seconds to prevent savegame bloating.
	Bool bKeepUpdating = True
		If Weather.GetCurrentWeather().GetClassification() >= 2
			GoToState("LightsOn")
		Else
			GoToState("LightsOff")
		EndIf

	If bKeepUpdating
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent

State LightsOff
 
	Event OnBeginState()
		Disable()
		RegisterForSingleUpdateGameTimeAt(LightsOnTime)
	EndEvent
 
	Event OnUpdateGameTime()
		GoToState("LightsOn")
	EndEvent
 
EndState
 
State LightsOn
 
	Event OnBeginState()
		Enable()
		RegisterForSingleUpdateGameTimeAt(LightsOffTime)
	EndEvent
 
	Event OnUpdateGameTime()
		GoToState("LightsOff")
	EndEvent
 
EndState

 

 

 

I probably need to modify this abit to work properly with my script. found the code snippet on the wiki, i just customized it a little. I actually consider using a script extender for the weather control so one can decide if one want the weather stuff or not when using my mod.

 

the get.classification snip works, tested it in the "OnInit" and it properly changes state to lights on if the weather is bad when you load the game. so i know it's the OnUpdate part of my script that i somehow borked. Compiles just fine.

 

Thanks people! :smile:

What exactly is your question? I think I missed it in there somewhere. What is the script doing that it should not be doing?

 

But if I had to guess... You have a function to check for bad weather which registers for an update and keeps repeating itself every 30 seconds due to nothing changing the governing bool variable. However, nothing is calling the function into play and as such the update event is not being triggered. Furthermore your other registration events are using game time and so you need to use the OnUpdateGameTime event to process those registrations.

 

 

You guessed it right currently the functions of the script disable and enable lights, this works as intended, but i want the lights to turn on if the weather is bad during the day too, I thought i called the function when I used the

Event OnUpdate()
;Checks for bad weather, only updates every 30 seconds to prevent savegame bloating.
	Bool bKeepUpdating = True
		If Weather.GetCurrentWeather().GetClassification() >= 2
			GoToState("LightsOn")
		Else
			GoToState("LightsOff")
		EndIf

	If bKeepUpdating
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent

The other stuff runs as it should though, no problems there. Lights go on and off when they should :smile:

 

 

 

Your BadWeatherCheck() is obviously not being called inside the Update event. Yes, it does check for bad weather but you need the registration to be triggered first. Either call the BadWeatherCheck() function inside your OnInit() event or register for the single update directly. This would kick off the non game time update loop.

 

EDIT: wrapped the quoted posts in spoiler to reduce post length

Edited by IsharaMeradin
Link to comment
Share on other sites

Alright, I seriously thought i actually called it further down, but i guess that i need to call for it to update first *facepalm*

 

something like this?

 

 

Scriptname ImmersiveCLightMasterWeatherControl extends ImmersiveContentLightMasterParent

Function BadWeatherCheck()
	RegisterForSingleUpdate(30.0)
End Function

Event OnInit()
	RegisterForSingleUpdate(30.0)
EndEvent

Event OnUpdate()
;Checks for bad weather, only updates every 30 seconds to prevent savegame bloating.
	Bool bKeepUpdating = True
		If Weather.GetCurrentWeather().GetClassification() >= 2
			GoToState("LightsOn")
		Else
			GoToState("LightsOff")
		EndIf

	If bKeepUpdating
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent

 

 

 

Now, it does say that this code snippet is safe to use with OnUpdate(), but I can't see where it ends, would'nt logic say that there should be an "else" statement in there or a "bKeepUpdating = false"? for example the bKeepUpdating = false when the lights are on anyway to keep it from polling more than necessary?

Link to comment
Share on other sites

The way you currently have it set, yes it will keep polling indefinitely. The only saving grace is that you are using the single update chain as opposed to the plain update loop. The single update chain will be stopped after the game is loaded with the mod removed. Whereas the plain update loop would continue trying to process for the length of the timer.

 

I would try something like this. Then again, I'm not sure how exactly it needs to tie into the rest of your project.

 

 

Scriptname ImmersiveCLightMasterWeatherControl extends ImmersiveContentLightMasterParent

Bool bAreLightsOn = false
Bool bBadWeather = false

Bool Function BadWeatherCheck()
	;this function determines if the weather is bad and returns that as a true/false value
	If Weather.GetCurrentWeather().GetClassification() >= 2
		bBadWeather = true
	Else
		bBadWeather = false
	EndIf
	Return bBadWeather
EndFunction

Event OnInit()
	RegisterForSingleUpdate(0.5) ;have the update event triggered 1/2 of a second after the object has been initialized
EndEvent

Event OnUpdate()
	If BadWeatherCheck == true
		;if weather is bad - go turn the lights on
		GoToState("LightsOn")
		;be sure to set bAreLightsOn to true inside a function in the LightsOn state
	Else
		;if weather is not bad - go turn the lights off
		GoToState("LightsOff")
		;be sure to set bAreLightsOn to false inside a function in the LightsOff state
		;also RegisterForSingleUpdate to poll for bad weather while the lights are off
	EndIf

	;since weather can change on a dime - we keep checking every 30 seconds real time while the lights are out
	;this will give an error when the mod is uninstalled, but it will only do it for the first load after mod removal
	If bAreLightsOn  == false
		RegisterForSingleUpdate(30.0)
	EndIf
EndEvent 

 

 

 

 

Link to comment
Share on other sites

So in other words, it's easier to just incorporate this snippet inside the original script, no need to use an extended script. The only reason why i thought about it was to somehow make it possible to enable or disable the weather script function in an MCM menu. Not sure if I will do it that way though. Thanks for all the help :) I still don't get how to call from a function. Will need to educate myself more :)

Link to comment
Share on other sites

I want to make an AOE knockdown spell centered on myself. I can't do this from basic CK materials, as if I go to a spell type that has an explosion spell, there's nothing there with a knockdown effect. I have no idea how to start with scripting my own spells and the CK website did not cover scripting spells. Instead of giving me the script that I probably have to write for it, I'd some pointers to where I can learn to find these things out myself.

Link to comment
Share on other sites

Hi there guys, I'm probably missing something basic but I'm still new to making quests. Basically, I'm trying to get it so that my follower will agree to follow you if you perform a shout for her, any shout, not a specific one. I tried to pick apart the main quest when you first absorb a dragon soul in the watch tower and you have an optional "use your new shout power", to try to mirror it and use it to advance my quest, but I can't for the life of me figure out even where it says it in the main quest's tab. Any tips? Thanks!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...