Hoamaii Posted February 10, 2017 Share Posted February 10, 2017 Hi guys, Trying to use function RegisterForMenuOpenCloseEvent(string asMenuName) in a MagicEffect script. Native function right? (that's what the Wiki implies anyway) The script compiles fine, but it doesn't work in game and Papyrus log gives me this error: "Cannot register unbound script to receive menu events" I saw on the Wiki that this function is a "ScriptObject" function and since I'm not sure I properly understand this new concept of ScriptObject, I'm probably using it wrong. Been trying to detect Pipboy Menu btw (tab). Many thanks to anyone who can enlighten me about that :D Link to comment Share on other sites More sharing options...
Reneer Posted February 10, 2017 Share Posted February 10, 2017 You will probably need to post your entire script if you want detailed help. :) Link to comment Share on other sites More sharing options...
Hoamaii Posted February 10, 2017 Author Share Posted February 10, 2017 Alright, here it goes: Idle Property MyIdle Auto Message Property NoIdlePlayingMsg Auto Actor Property PlayerRef Auto Event OnEffectStart(Actor akTarget, actor akCaster) If PlayerRef.IsInCombat() || PlayerRef.GetSitState() != 0 || PlayerRef.IsSneaking() || PlayerRef.IsInPowerArmor() NoIdlePlayingMsg.Show() Else If PlayerRef.IsWeaponDrawn() PlayerRef.PlayIdle(RaiderSheath) EndIf Utility.Wait(0.3) If PlayerRef.GetAnimationVariableBool("IsFirstPerson") Debug.Notification("Player is in FIRST person") Game.ForceThirdPerson() EndIf Utility.Wait(0.2) PlayerRef.PlayIdle(MyIdle) Debug.Notification("idle called") RegisterForMenuOpenCloseEvent("PipboyMenu") GoToState("IdlePlaying") EndIf EndEvent State IdlePlaying Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (asMenuName == "PipboyMenu") && (!abOpening) Debug.Notification("Pipboy Open, calling IdleStop") PlayerRef.PlayIdle(IdleStop) GoToState("Done") EndIf EndEvent EndState State Done Event OnBeginState(string asOldState) UnregisterForMenuOpenCloseEvent("PipboyMenu") Self.Dispel() EndEvent EndState I'm just testing stuff about animations. My issue is "RegisterForMenuOpenCloseEvent("PipboyMenu")" gives me the following log error: "Cannot register unbound script to receive menu events" Self.Dispel() gives me an error too by the way: "Unable to call Dispel - no native object bound to the script object, or object is of incorrect type" - but I thought I might solve that one by trying to use that function on a spell rather than a MagicEffect - even though the Wiki seems to indicate that it should work directly on MagicEffects. Many thanks in advance! :smile: Link to comment Share on other sites More sharing options...
kitcat81 Posted February 10, 2017 Share Posted February 10, 2017 (edited) I have script registered for workshop open menu. RegisterForMenuOpenCloseEvent("WorkshopMenu"). But it`s not a magic effect, it`s object reference script. Maybe it makes some difference, not sure. Reneer is right. Ups :smile: you have posted it already... About the "Dispel" thing ...I got the same error. I used Dispel() in my effect and it works so that It does not remove the effect, but makes the effect go to the state OnEffectFinish while it`s still stays on the actor untill the duration is over. And the error appeared because I tried to dispel my effect twice. Once in the beginning if the conditions are not met and the second time when recieved some custom events. I did not notice that I forgot to add "uregister for all events " after forcing it to dispel . My script kept recieving the event in dispelled state and could not dispel itself again. Your script has no OnEffectFinish, can`t be sure...but maybe this is the reason(that it has no dispelled state to go to) Edited February 10, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
Hoamaii Posted February 10, 2017 Author Share Posted February 10, 2017 Hey KitCat 81, Yeah, I know, it should be working on active MagicEffects, Alias and Forms (again says the Wiki) - and like you say it works on ObjectReferences too. I'm confused by the error's phrasing though: "cannot register unbound script to receive menu events" - I wonder what unbound script refers to?... The very script which calls that event I guess, but bound to what exactly? Link to comment Share on other sites More sharing options...
kitcat81 Posted February 10, 2017 Share Posted February 10, 2017 Hey KitCat 81, Yeah, I know, it should be working on active MagicEffects, Alias and Forms (again says the Wiki) - and like you say it works on ObjectReferences too. I'm confused by the error's phrasing though: "cannot register unbound script to receive menu events" - I wonder what unbound script refers to?... The very script which calls that event I guess, but bound to what exactly Hey ! ;) I`d try to fix the dispel thing at first ....It might happen that it will remove the second error. Maybe it`s already dispelled when it tries to register. Link to comment Share on other sites More sharing options...
Hoamaii Posted February 10, 2017 Author Share Posted February 10, 2017 Hmm... yeah, trouble is my dispel() function is supposed to get triggered by the MenuOpen... I was thinking since I'm using this on a MagicEffect which is set to "Fire at once" (not sure this is the proper English term, my CK has the bad idea to have some definitions in French while all the rest is in English... :rolleyes: as if French gamers could mod these games without knowing a word of English!..) - anyway, I was thinking since my ME has no duration, it's possible it's already dispelled by the time I get to my "Done" state... But then, I'd get a "None" error in my log, I suppose... I'll try and use Dispel() independently to double check. Also, I was wondering that ObjectReference you're using to call RegisterForMenuOpenCloseEvent, is it an Alias by any chance? I was reading the Vanilla ScriptObject.psc and it seems to suggest that function would only work on Aliases. Here's what it says: ; Registers this alias to receive events when menus are opened / closedFunction RegisterForMenuOpenCloseEvent(string asMenuName) native Link to comment Share on other sites More sharing options...
kitcat81 Posted February 10, 2017 Share Posted February 10, 2017 (edited) In my version it`s called fire and forget. You can try try to Add OnEffectFinish (just an epmpty event or something like "debug.notification("Dispelled") to see when your effect is dispelled . i have not used states in effects, don`t know if it missing the the OnEffectFinish can make it get an error with Dispel function. But I found the description of error in the list of "Papyrus Runtime Errors" and it helped me to fix it with the help of this forum too... as some kind person helped me to understand what means "out of under " :D. I have just a usual object registered for menu open close event. Not alias. I have activators that disable themselves when the player is not in workshop menu. And I have magic effect registered for custom events. But they are all with duration and with OnEffectFinish. I could not find other significant difference between yours and mine effects so i suggested that it can be the cause. Don`t have other ideas for now. I had my effect opent for editting and added your function for testing. it worked for me.Though I added only notifications. But they fired when I used pipboy and no errors in the log. This was fire and forget effect and 15 seconds duration. I`m not 100% sure if you want the effect to be attached permanently and only dispel when the player goes to pipboy menu, but if so then maybe making it constant can help. Edited February 11, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
Hoamaii Posted February 10, 2017 Author Share Posted February 10, 2017 Yeah, just modified my script (which is in fact way longer than the extract I put up here) and will try in game. Thanks for helping me think, KitCat :smile: Yeah, as far as I can see, States do work fine in MagicEffects just like they did in Skyrim. Uh... What the heck does "out of under" mean?????... (French here as you've probably guessed :turned: ). Link to comment Share on other sites More sharing options...
Hoamaii Posted February 11, 2017 Author Share Posted February 11, 2017 Back from game - yup, at least part of my problem is the "Fire and Forget" flag, my MagicEffect gets dispelled almost instantly even though I gave it some duration. But if I place the RegisterForMenuOpenCloseEvent("PipboyMenu") function at the very beginning of my script, that error seems to be gone... For some reason, the error only disappears if I add "Import ScriptObject" to the Properties. Silly of me not to have thought of it before!.. I'll try to make it a perk, see if that solves my problems. Thanks KitCat :) - it always helps a lot to have someone to discuss issues with, sometimes all it takes is to change your perspective!.. Link to comment Share on other sites More sharing options...
Recommended Posts