[Solved] Mask Picture's Value from variable

I'm working on a set of common events to manage a simple Health Bar. One of these "Update Health Bar", has a Mask Picture command in it. It works just fine when I use a constant value, but for some reason It does not when using local variables.

I've already checked if the value of the variable was really the one I wanted with a show message (it was).
Screenshot.png

Thanks!​
Hi FoxySeta,

I checked the underlying code and it seems that variables are actually not supported for the mask value yet. But it is very easy to fix, I could provide you a quick fix if you tell me which version of VN Maker you are using.
Sure! 1.0.1085 (BETA)
Also, should I add it in @Archeia 's VNM snippets that don't deserve their own thread until it get fixed?
@FoxySeta sure. if you can provide a demo that might help
I'll be waiting for the fix then😂
Hi, there are two ways how to apply the fix, the easiest is to just replace the entire content of the Components > Component_CommandInterpreter script in Script Editor with this:



When VN Maker updates to Version 1086 in the future that fix gets overridden which is not an issue because the fix has been added to 1086 anyway. The only issue with this approach is that if you want to apply multiple fixes. But since that is not the case, you should be fine with this one.






Otherwise, you have to create a new script BELOW Component_CommandInterpreter with the following content, just call it MaskPictureFix or something.

Code:
# ===================================================================
#
#   Script: MaskPictureFix
#
#   $$COPYRIGHT$$
#
# ===================================================================
class Component_MaskPictureFix extends gs.Component_CommandInterpreter
    ###*
    * Executes a masking-effect on a game object..
    *
    * @method maskObject
    * @param {gs.Object_Base} object - The game object to execute a masking-effect on.
    * @param {Object} A params object containing additional info.
    ###
    maskObject: (object, params) ->
        easing = gs.Easings.fromObject(params.easing)

        if params.mask.type == 0
            object.mask.type = 0
            object.mask.ox = @numberValueOf(params.mask.ox)
            object.mask.oy = @numberValueOf(params.mask.oy)
            if object.mask.source?.videoElement?
                object.mask.source.pause()

            if params.mask.sourceType == 0
                object.mask.source = ResourceManager.getBitmap("Graphics/Masks/#{params.mask.graphic?.name}")
            else
                object.mask.source = ResourceManager.getVideo("Movies/#{params.mask.video?.name}")
                if object.mask.source
                    object.mask.source.play()
                    object.mask.source.loop = yes
        else
            duration = @durationValueOf(params.duration)
            mask = Object.flatCopy(params.mask)
            mask.value = @numberValueOf(mask.value)
            object.animator.maskTo(mask, duration, easing)

        if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
            @isWaiting = yes
            @waitCounter = duration

gs.Component_CommandInterpreter = Component_MaskPictureFix

However, that approach has the disadvantages that you might forget to delete it after updating to 1086.
Thanks a bunch, really! (Also, I'm happy if this helped you devs notice a bug.)

@FoxySeta sure. if you can provide a demo that might help
Done. Is it okay for you check the post before deciding if a demo might be useful? (This way I may avoid a needless 3MB uplod)
Thanks a bunch, really! (Also, I'm happy if this helped you devs notice a bug.)
Done. Is it okay for you check the post before deciding if a demo might be useful? (This way I may avoid a needless 3MB uplod)

OK now that I've read everything, if it's gonna be patched on the next version we don't want to add it on that thread. It's only for snippets that will be useful for the longest time not something that's a "bug" or going to be "patched" on later versions.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-mask-pictures-value-from-variable.97796/