Jump to content

Quick Questions, Quick Answers


Mattiewagg

Recommended Posts

  • Replies 2.6k
  • Created
  • Last Reply

Top Posters In This Topic

Just tell me I'm not the only one who is horrifyingly intimidated and in awe of how complex Skyrim Modding is? Some of you make it look easy but after 3+ years of modding this game I still feel like a newbie.

You're not alone man, you're not alone!

 

What's the easiest way to implement a hotkey for something in a mod? Like, say I wanted to be able to activate a menu when I hit 'K'; what would the easiest way of doing this be?

Edited by Darkxenoth
Link to comment
Share on other sites

What's the easiest way to implement a hotkey for something in a mod? Like, say I wanted to be able to activate a menu when I hit 'K'; what would the easiest way of doing this be?

You just need a script that registers for a key. And even making it configurable with MCM isn't too much harder.

 

Technically the easiest way would be:

ScriptName SimpleKeyWatcherScript extends Quest

Event OnInit()
	RegisterForKey(37) ; K
EndEvent

Function OnKeyDown(int keyCode)
	if !Utility.IsInMenuMode()
		; Do something interesting
	endif
EndFunction

 

But don't do it that way because you can only have the script process one key (even if you change your mind later) and the user can't change it.

 

I would do it with a quest script like this:

 

 

ScriptName KeyWatcherScript extends Quest

Event OnInit()
	WatchedKey = 37 ; K
EndEvent

Function OnKeyDown(int keyCode)
	if keyCode == WatchedKey_var && !Utility.IsInMenuMode()
		; Do something interesting
	endif
EndFunction

; full property to set or view the current key code
int Property WatchedKey Hidden

	Function set(int code)
		if WatchedKey_var > 0
			UnregisterForKey(WatchedKey_var)
		endif
		WatchedKey_var = code
		if WatchedKey_var > 0
			RegisterForKey(WatchedKey_var)
		endif
	EndFunction

	int Function get()
		return WatchedKey_var
	EndFunction

EndProperty

int WatchedKey_var ; storage for the current keycode

 

 

And then (assuming you attach that script to a quest named "KeyWatcher") users can change the key used from the console with a command like:

setpqv KeyWatcher WatchedKey 45

or you can make it even easier for them by using an MCM script like this:

 

 

ScriptName KeyWatcherMCMScript extends SKI_ConfigBase

KeyWatcherScript Property KeyWatcher Auto
{This property is used to access and change the key mapping in the main script.}

Event OnPageReset(string a_page)
	; Show the current key mapping and allow it to be changed or even unmapped.
	AddKeyMapOptionST("WatchedKeyState", "The Watched Key", KeyWatcher.WatchedKey, OPTION_FLAG_WITH_UNMAP)
EndEvent


State WatchedKeyState

	Event OnHighlightST()
		; fill the bottom box with some descriptive text
		SetInfoText("Pressing the watched key will do something interesting.")
	EndEvent

	Event OnDefaultST()
		; if the user chooses the default option, change it
		OnKeyMapChangeST(37,"","") ; K is the default
	EndEvent

	Event OnKeyMapChangeST(int keyCode, string conflictControl, string conflictName)
		; set and register the new key value in the main script
		KeyWatcher.WatchedKey = keyCode
		; update the MCM button graphic to match the selected key
		SetKeyMapOptionValueST(keyCode, false, "")
	EndEvent

EndState

 

 

Link to comment
Share on other sites

I'm looking to create etchings that glow but I don't want to do any modelling, I only want to use textures. I've already got the glow done and working but it doesn't have quite the effect I want so I'm wondering, is it possible to create a texture glow map that produces rays similar to how sunbeams shine through tree branches?

Link to comment
Share on other sites

 

What's the easiest way to implement a hotkey for something in a mod? Like, say I wanted to be able to activate a menu when I hit 'K'; what would the easiest way of doing this be?

You just need a script that registers for a key. And even making it configurable with MCM isn't too much harder.

 

Technically the easiest way would be:

ScriptName SimpleKeyWatcherScript extends Quest

Event OnInit()
	RegisterForKey(37) ; K
EndEvent

Function OnKeyDown(int keyCode)
	if !Utility.IsInMenuMode()
		; Do something interesting
	endif
EndFunction

But don't do it that way because you can only have the script process one key (even if you change your mind later) and the user can't change it.

 

I would do it with a quest script like this:

 

ScriptName KeyWatcherScript extends Quest

Event OnInit()
	WatchedKey = 37 ; K
EndEvent

Function OnKeyDown(int keyCode)
	if keyCode == WatchedKey_var && !Utility.IsInMenuMode()
		; Do something interesting
	endif
EndFunction

; full property to set or view the current key code
int Property WatchedKey Hidden

	Function set(int code)
		if WatchedKey_var > 0
			UnregisterForKey(WatchedKey_var)
		endif
		WatchedKey_var = code
		if WatchedKey_var > 0
			RegisterForKey(WatchedKey_var)
		endif
	EndFunction

	int Function get()
		return WatchedKey_var
	EndFunction

EndProperty

int WatchedKey_var ; storage for the current keycode

 

And then (assuming you attach that script to a quest named "KeyWatcher") users can change the key used from the console with a command like:

setpqv KeyWatcher WatchedKey 45
or you can make it even easier for them by using an MCM script like this:

 

ScriptName KeyWatcherMCMScript extends SKI_ConfigBase

KeyWatcherScript Property KeyWatcher Auto
{This property is used to access and change the key mapping in the main script.}

Event OnPageReset(string a_page)
	; Show the current key mapping and allow it to be changed or even unmapped.
	AddKeyMapOptionST("WatchedKeyState", "The Watched Key", KeyWatcher.WatchedKey, OPTION_FLAG_WITH_UNMAP)
EndEvent


State WatchedKeyState

	Event OnHighlightST()
		; fill the bottom box with some descriptive text
		SetInfoText("Pressing the watched key will do something interesting.")
	EndEvent

	Event OnDefaultST()
		; if the user chooses the default option, change it
		OnKeyMapChangeST(37,"","") ; K is the default
	EndEvent

	Event OnKeyMapChangeST(int keyCode, string conflictControl, string conflictName)
		; set and register the new key value in the main script
		KeyWatcher.WatchedKey = keyCode
		; update the MCM button graphic to match the selected key
		SetKeyMapOptionValueST(keyCode, false, "")
	EndEvent

EndState

I never knew Setpqv was a thing. :O That's cool.

 

MCMs are better though. :P

Link to comment
Share on other sites

Hm, I am trying to make a custom voicetype, so that I could use custom power attack grunt sound files.

 

However, it is way more convoluted as it should be. I don't really understand where I can find the entries in the CK.

 

CLosest thing I found, is a quest called DialogueCombatEncounterTypes. It has some of the taunts that are being said to the player (but never by the player) under the rider "combat". Seems like the player is excluded here due to nonplayer factions being used as conditions.

 

Anyway, even with those infos, I don't see where the actual sound files are attached.

 

edit:

 

Basically what I want to do is a) use custom sounds for the power attack grunt, preferably a variation and b) have the player say/grunt other sound files while attacking -> best case just by using dialogue/voice sytem, preferably to scripts

Edited by BigBizkit
Link to comment
Share on other sites

 

I never knew Setpqv was a thing. :O That's cool.

 

MCMs are better though. :tongue:

Some people have a pathological aversion to SkyUI so giving them a way to configure it without SkyUI is nice. And if the mod itself doesn't require SKSE functions then being able to configure it from the console is even more important since some people still refuse to use SKSE.

 

For all of the people who complain that MCM doesn't preserve settings across games this gives them the option to store their preferred settings in a BAT file that they can run instead of individually tweaking each MCM control for each new game they start.

 

Making it configurable from the console via a property means it is easier to write the matching MCM so there's really no reason not to implement it that way. (And the MCM page is usually the very last thing I add to a mod, so I need to be able to change things manually during development and early testing.)

Link to comment
Share on other sites

I want to set something up that seems like it would be complex so I'm looking for a little insight.

 

I want to create an object in game, a book, that grants the player a permanent Magic Effect when read. I also want to write a script that runs whenever a save game is loaded. The script should look for that Magic Effect and if the player has it the script should apply a glow map to certain textures. Is this possible?

 

My original idea was to write a script that checked to see if you were a member of a specific faction and then did the same thing but it occurred to me that it's possible to get kicked out or leave some factions and I wouldn't want that to stop the textures from glowing.

Edited by Biohazard186
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...