helix icon indicating copy to clipboard operation
helix copied to clipboard

Fix hasVignetteMaterial always returning true

Open OffLegAz opened this issue 3 years ago • 3 comments

Call IsError instead of comparing IMaterial with string

OffLegAz avatar Sep 01 '21 22:09 OffLegAz

@OffLegAz Have you tested this without the Helix content on, including in client materials/ folders .etc?

ZeMysticalTaco avatar Sep 02 '21 20:09 ZeMysticalTaco

@OffLegAz Have you tested this without the Helix content on, including in client materials/ folders .etc?

I've tested this while trying to check another material on validity in the same way it's done with vignette. Soon I found that this check always returns true due to IMaterial not being equal to string. Eventually, I discovered IsError function on wiki wich allows to safely check is material valid or not. So this fix should work fine.

OffLegAz avatar Sep 02 '21 22:09 OffLegAz

@OffLegAz Have you tested this without the Helix content on, including in client materials/ folders .etc?

I've tested this while trying to check another material on validity in the same way it's done with vignette. Soon I found that this check always returns true due to IMaterial not being equal to string. Eventually, I discovered IsError function on wiki wich allows to safely check is material valid or not. So this fix should work fine.

i have rechecked this just to be sure.

-------------- doesnot_exist.png --------------
Material [___error]	Material [___error]
true	true
false	false
-------------- BREAK --------------
-------------- CORRECT MATERIAL --------------
-------------- icon16/user.png --------------
Material [icon16/user]	Material [icon16/user]
false	false
false	false
-------------- BREAK --------------
local testcase_354 = { }

do
    testcase_354.test = function()
    print( '-------------- INCORRECT MATERIAL --------------' )
    print('-------------- doesnot_exist.png --------------')
    local materialBad = 'doesnot_exist.png'
    local YANKEE = Material( materialBad )
    local ZULU = ix.util.GetMaterial( materialBad )
    print( YANKEE, ZULU )
    print( YANKEE:IsError( ), ZULU:IsError( ) )
    print( YANKEE == '___error', ZULU == '___error' )
    print( '-------------- BREAK --------------' )
    print( '-------------- CORRECT MATERIAL --------------' )
    print('-------------- icon16/user.png --------------')
    local materialGood = 'icon16/user.png'
    local ALPHA = Material( materialGood )
    local BRAVO = ix.util.GetMaterial( materialGood )
    print( ALPHA, BRAVO )
    print( ALPHA:IsError( ), BRAVO:IsError( ) )
    print( ALPHA == '___error', BRAVO == '___error' )
    print( '-------------- BREAK --------------' )
    end
    testcase_354.test()
end

@alexgrist no issues found with the reasoning, he is correct in this.

I don't think anything will happen if the vignette isn't drawn when it doesn't exist.

ZeMysticalTaco avatar Sep 02 '21 23:09 ZeMysticalTaco