Jump to content

Really Simple Script Problem Plus A Rant


demidekidasu

Recommended Posts

Hi everyone,

 

I've been having troubles with a script attached to an amulet so I have been cutting it down to try and isolate the problem. Each test is run on a clean save to eliminate any problems related to that.

 

Anywho, I have ended up cutting it right down to this -

Scriptname DDDmedallionScript01 extends ObjectReference  

Event OnEquipped(Actor akActor)
	Debug.notification("Medallion equiped")
RegisterForSingleUpdate(1.0)
EndEvent

Event OnUpdate()
	Debug.notification("Script update")
	RegisterForSingleUpdate(1.0)
EndEvent

 

I get the message "Medallion equiped" but I am not getting the "Script update" message, ever.

 

WHAT THE TOM JONES?!?!?

 

As I said, testing is done on a clean save from before I started working on this.

 

Sometimes scripts work and other times they don't - even instances when the scripts do pretty much the same damn thing as a script that seems to work but in a different context. For no apparent reason!

 

I'm pretty sure this happens with other people too. Some users of my "Millview" house mod reported that they don't get the front door key when they read the deed which has the following script attached to it - even though for myself and other people it DOES work.

Scriptname MILLVIEWdeedScript extends ObjectReference  

Key property MillviewKey auto
ObjectReference property MillviewHouseEXTdoor auto
Actor property PlayerREF auto

Event OnRead()
PlayerREF.AddKeyIfNeeded(MillviewHouseEXTdoor)
EndEvent

 

If I can't get something as pathetically simple as the top script to work, I'm quitting modding for good. I'm absolutely sick of this rubbish randomly happening whenever I decide to make something just for fun... This is one of the reasons I rage-quit from modding a few months ago.

Link to comment
Share on other sites

One of the things I have noticed, especially when it comes to scripting, is that changes are made in an update which deprecate some calls and create new calls in other cases. Have you tried the regular RegisterForUpdate(1.0) and Unregister within the update event to see if that works?
Link to comment
Share on other sites

Too late, I've already binned it. Don't see any reason to mess around all day with something that should work but won't.

 

And if Bethesda have changed how "RegisterForSingleUpdate" works, I'm at a loss for words.

Link to comment
Share on other sites

From the wiki:

"Subsequent calls to ResisterForSingleUpdate will override previous ones - i.e. calling it back to back will result in the second registered update occurring, but not the first. It will not interfere with updates started by RegisterForUpdate however. " Could this causing weird behavior since you essentially have an infinite loop of updates?

Link to comment
Share on other sites

I could be completely offbase here, but does RegisterForSingleUpdate even work with ObjectReference (vs. aliases, ActiveMagicEffect, etc.)? When I've used it (working fine), it's been off a quest alias or an applied enchantment.
Link to comment
Share on other sites

@Mujoro: That could be the problem perhaps. But that does not explain my overall complaints in this thread about other scripts which don't work right. See my second example in the OP, and my reply to Arron below...

 

 

 

@Arron Dominion: That just means you can't register for 2 updates at once, with something like this:

Event OnInit()
 	RegisterForSingleUpdate(1.0)
 	*Something Else*
 	RegisterForSingleUpdate(1.0)
EndEvent

 

My second update does not occur until after the first update.

 

I appreciate you trying to help me, and I thank you for that, but it's something I have done in countless scripts before. If I were to try it again with the exact same lines but in a different script and a different mod it will probably work.

 

This is essentially why I am so annoyed - sometimes things work and other times they just don't.

 

 

An example...

 

During my work on LTC I wrote a script which just refuses to behave. Essentially I put in some error message boxes that will notify me if the script fails to move to a different state, telling me where it fails and in what script.

 

The first script works. In the second script, however, which is pretty much just a copy-paste of the first but with a few minor changes, it gives me these error messages even though the script IS moving to the other states correctly just like the first one.

 

It's an absolute joke.

Link to comment
Share on other sites

@demidekidasu Re your 2nd script, by all accounts, it should work. I've read a number of posts about how scripts tied to ObjectReference don't always perform consistently, with alleged causes ranging from CK glitches to how a mod gets packaged (BSA vs. loose PEX for scripts) to NMM failing to install properly. I don't believe there's any definitive causal "proof", but after reading so many posts on this, I ended up taking a "workaround" approach for stuff I needed to do (and, fortunately, no glitches reported yet from these particular scripts). What I ended up doing was creating a quest wrapper for the objects, with the associated scripts not doing anything besides setting quest stages to track progress (e.g., player has read the book). The consequences of reading the book (e.g., giving the player an item) get handled in the quest framework instead of directly by reading the book. This approach requires a bit more work up-front, but may be a bit more reliable. It also gives you/your users a secondary option if the book doesn't work as intended (e.g., you can do a simple quest setstage to get to the point you need).
Link to comment
Share on other sites

Admittedly, I have been very ignorant of quest creation, and it is without any doubt my weakest area. I suppose I will have to look into it.

 

But surely you can see why I get annoyed when modders are forced to make these workarounds for things that are supposed to work. In the past I have written missions in ArmA which involved plenty of scripting, but never once did I see things inexplicably refuse to work like what you see in Skyrim (well, I don't remember it ever happening).

 

I know, different game, different engine, but my point is that Papyrus is clearly not reliable enough for a game to use as it's main scripting language - never mind a game as complex as Skyrim...

Edited by demidekidasu
Link to comment
Share on other sites

I think the problem in your first (now binned) script stems from this:

 

When an object is equipped it is inside a container, which means that you cannot call Member Functions on it. (Unless it is a persistent reference)

 

From the CK wiki.

 

So the moment you equip your item, it fires the onequipped event, after that for all intents and purposes it is inside a container.

 

In defense of papyrus, while it has frequently infuriated me, 100% of those issues were caused by my lack of knowledge on the subject, and if used correctly it seems to be pretty reliable. Of course, using it correctly has often been beyond me :tongue:

 

even instances when the scripts do pretty much the same damn thing as a script that seems to work but in a different context

 

But the context is very important :)

Edited by acidzebra
Link to comment
Share on other sites

I would recommend you to use the tracking system instead of notification. Logs are more accurate and precise. Sometime, when two or more debug.notification() are called, not all the message on top-left screen are shown.

 

This mean that your script should works anyway even if message is not shown.

Edited by mannygt
Link to comment
Share on other sites

  • Recently Browsing   0 members

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