Jump to content

Script doesn't seem to be doing anything; not even OnInit() is called


Recommended Posts

Posted

Hi, I'm trying to make a mod that modifies SexLab Defeat.  Basically, I have a script attached to the Defeat Gag object that makes the actor that equips it essential, and returns them to their previous "essentialness" when it's unequipped.  The purpose behind this is to prevent my followers from killing my victim before I have a chance to do anything with them.

Right now, I'm having a pretty big problem.  None of the code in the scripts seems to run...at all.  None of the events are even getting triggered.  Here is my code.

Scriptname FALC_DefeatGagScript extends ObjectReference  

	bool wasEssential = false

	Event OnInit()
		Debug.Notification("Initialized.  Hello world.")
	endEvent

	Event OnEquipped(Actor akActor)
		Debug.Notification("Equipped")
		wasEssential = akActor.IsEssential()
		akActor.GetActorBase().SetEssential(true)
	endEvent

	Event OnUnequipped(Actor akActor)
		Debug.Notification("Unequipped")
		akActor.GetActorBase().SetEssential(wasEssential)
	endEvent

I have also attached my ESP file, as I'm pretty sure I made the mistake in Creation Kit, rather than in the code.FALC Defeat Tied-Up Enemies Essential.esp

 

Obviously, this esp requires Defeat and SexLab.

Posted

Yup you did. Instead of overwriting the record (the gag) you created a new one which doesn't work. That's why SL - Defeat is not in the master list and that's why none of your events are going to work.

 

Also you have to make the Bool wasEssential a property else on saving the game it will lose its value.

 

Edit: What you might have done wrong is the fact that the CK doesn't add esp's as master. You would have to add the masterfile (Defeat.esp) in TES5Edit and then you can attach the script to the gag in the CK and it will create an override record instead of a new one.

 

Edit2: Almost forgot: Delete the master dependency of SexLab. Your plugin doesn't need it.

Posted

I tried adding Defeat as a master file in TES5Edit, but it still created the duplicate when I loaded it back into creation kit to check it.  Is there a step-by-step process I can follow to ensure that I'm doing things in the right order?

Posted

Thanks for the help!  I've managed to solve this problem by creating an ESM of SexLabDefeat using Wrye Bash, which I then used in the Creation Kit.  Then when I was ready to test the mod, I used TES5Edit to change my mod's dependency from SexLabDefeat.esm to SexLabDefeat.esp.  That worked wonders.

Now, I have a separate problem.  I'm trying to make the victim's health constantly refill, but unfortunately RegisterForUpdate() doesn't seem to be doing anything.  Again, here is my code and my ESP.

Scriptname JBT_DefeatGagScript extends ObjectReference  

	bool Property wasEssential = False auto hidden

	bool Property shouldUpdate = False auto hidden

	Actor Property wearer auto hidden

	Event OnEquipped(Actor akActor)
		Debug.Notification("Victim is now essential while tied up.")

		wasEssential = akActor.IsEssential()
		wearer = akActor

		RegisterForUpdate(0.5)
		shouldUpdate = True

		akActor.GetActorBase().SetEssential(true)
	endEvent

	Event OnUnequipped(Actor akActor)
		Debug.Notification("Victim has returned to their original essential value.")

		akActor.GetActorBase().SetEssential(wasEssential)

		wearer = None
		shouldUpdate = False
	endEvent

	Event OnUpdate()
		Debug.Notification("Update Event")
		if (shouldUpdate)
			Debug.Notification("Registering for another update")

			;Refill the victim to full health
			wearer.ForceActorValue("health", wearer.GetBaseActorValue("health"))

			;RegisterForSingleUpdate(0.5)
		endIf
	endEvent

SexLab Defeat Tied-up Essential.7z

Posted

For future reference:

 

The file extension (.esp, .esm) doesn't matter. The only thing that counts is the master flag in the file. Using Wrye Bash to flip this flag with "esmify" is enough for the plugin to be treated as a master and to become a dependency for other mods.

 

The important thing to remember is that esmified plugins must be restored to esps when you are done in creation kit as they will likely do unspeakable things to your game otherwise. My preferred method for this is to simply restore the esps from original downloads/backups as you can be certain then that it is uncorrupted by the process.

 

Perhaps even more important is that whenever you open your mod in Creation Kit in future you must have the esp dependencies esmified again first. If the mod is saved with un-esmified dependencies then that's it, the mod is toast, delete it and restore from a back up... you are keeping backups, right?

 

 

Couple of things about the code:

 

You have RegisterForUpdate() in your OnEquipped event. This should never be used under any circumstances as it can lead to serious instability. Always use chained RegisterForSingleUpdate() instead so that the next update only occurs once the last update has finished everything it needs to do.

 

I haven't actually tested your mod but there are circumstances when in-game notifications will not display, such as the HUD being disabled or the same message being repeated too often. Use trace as well as notification to make sure.

Posted

Thanks for catching that!  I hadn't realized I had used both a RegisterForUpdate *and* a RegisterForSingleUpdate.  Whoops.

 

It turns out that wasn't the problem, though.  Apparently, "ghosts" of old versions of my script were left behind in the save file I was testing with, so that messed things up.  When I created a clean save, it worked perfectly.  Thanks for all of the help, guys!

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...