Jump to content

Recommended Posts

Hello as mentioned in the title I need a help with part of my code don't misunderstand it's working but the results are unpredictable and now time for part of code

 

Event PluginHasBeenRequestedForCustomHandlerNameCallback(String eventName, String strArg, Float numArg, Form sender)
    If (IsDebugging)
        Debug.Notification("Received " + PluginHasBeenRequestedForCustomHandlerName)
    EndIf
    DullMods_BasePluginInterface sendingForm = sender as DullMods_BasePluginInterface
    Int index = numArg as Int

    String[] registerHandlers = PluginForm.GetStringDataContext(index)
    Form client = PluginForm.GetFormDataContext(index)[0]
    Int handlerIndex = 0
    While (handlerIndex < registerHandlers.Length)
        If (StorageUtil.StringListHas(self, ListWithRegisteredHandlers, registerHandlers[handlerIndex]))
            StorageUtil.FormListAdd(self, registerHandlers[handlerIndex], client, false)
        ElseIf (IsDebugging)
            Debug.Notification("Trying to register on non existing handler " + registerHandlers[index])
        EndIf
        handlerIndex = handlerIndex + 1
    EndWhile
    PluginForm.ClearDataForContext(index)
    Float[] arr1 = Utility.CreateFloatArray(0)
    Int[] arr2 = Utility.CreateIntArray(0)
    String[] arr3 = Utility.CreateStringArray(0)
    Form[] arr4 = Utility.CreateFormArray(0)
    Debug.Notification("getter got " + getEarnedGoldByPC(Prefix + getEarnedGoldByPCHandler, arr1, arr2, arr3, arr4))
EndEvent

Float Function HandlerForFloat(String calledFunction, Float prevValue, Float[] floatParameters = none, Int[] intParameters = none, String[] stringParameters = none, Form[] formsParameters = none)
    if (calledFunction == Prefix + getEarnedGoldByPCHandler) 
        return 2.0 + prevValue
    EndIf
EndFunction

 

Part of it is for debugging but the most important thing whilst the last part of code in main event (Debug.notification) is expected to got 2.0 at this point but sometimes I got a 0.0 which is not expected behavior, the only thing I can think that StorageUtil works with some delay I mean after adding the form to list I shouldn't request immediately the above FormList from it but as I'm new with papyrus I'm not sure if this really is case.

Link to comment

I assume getEarnedGoldByPC is passing the first arugment to calledFunction, then some value (where the issue lies) to prevValue, and the following arguments in order to the remaining arguments of HandlerForFloat.

 

As far as I can tell, the essential function is missing from the code your showed: getEarnedGoldByPC

Link to comment
3 minutes ago, traison said:

I assume getEarnedGoldByPC is passing the first arugment to calledFunction, then some value (where the issue lies) to prevValue, and the following arguments in order to the remaining arguments of HandlerForFloat.

 

As far as I can tell, the essential function is missing from the code your showed: getEarnedGoldByPC

 

It's not like do something big I mean the idea is basically to load base value (0.0) + returned values from handlers from other forms (this is an idea but currently I only called a handler on the reference to self) but good thought maybe problem lies not here but in the initialization code 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use