Lazy Evaluation: Circular Dependency

Everything about mods can be found here.

Moderator: Morax

Lazy Evaluation: Circular Dependency

Postby Jip » 23 Jul 2016, 02:33

Hello everyone,

It appears to be a not-critical bug, however, when making my UI mod I keep getting the following errors:
Code: Select all
WARNING: Evaluating LazyVar failed: error evaluating lazy variable: ... alliance\gamedata\mohodata.scd\lua\maui\control.lua(37): error evaluating lazy variable: ... alliance\gamedata\mohodata.scd\lua\maui\control.lua(35): circular dependency in lazy evaluation for variable set from:
         stack traceback:
            ...orged alliance\gamedata\mohodata.scd\lua\lazyvar.lua(64): in function `SetFunction'
            ...orged alliance\gamedata\mohodata.scd\lua\lazyvar.lua(95): in function `Set'
            ... alliance\gamedata\mohodata.scd\lua\maui\control.lua(37): in function `ResetLayout'
            ...d alliance\gamedata\mohodata.scd\lua\maui\bitmap.lua(68): in function `ResetLayout'
            ... alliance\gamedata\mohodata.scd\lua\maui\control.lua(43): in function `OnInit'
            ...d alliance\gamedata\mohodata.scd\lua\maui\bitmap.lua(74): in function <...d alliance\gamedata\mohodata.scd\lua\maui\bitmap.lua:73>
            [C]: in function `InternalCreateBitmap'
            ...d alliance\gamedata\mohodata.scd\lua\maui\bitmap.lua(35): in function `__init'
            ...d alliance\gamedata\mohodata.scd\lua\maui\button.lua(9): in function `initfn'
            ... alliance\gamedata\mohodata.scd\lua\system\class.lua(258): in function <... alliance\gamedata\mohodata.scd\lua\system\class.lua:246>
            ...rselection\modules\helpmodules\helpuserinterface.lua(27): in function `CreateButton'
            ...rselection\modules\helpmodules\helpfilterbuttons.lua(19): in function `CreateFilterButton'
            ...iance\mods\filterselection\modules\userinterface.lua(8): in function `CreateUI'
            ...d alliance\gamedata\lua.scd\lua\ui\game\gamemain.lua(721): in function <...d alliance\gamedata\lua.scd\lua\ui\game\gamemain.lua:717>
            ...d alliance\gamedata\lua.scd\lua\ui\game\gamemain.lua(738): in function `CreateUI'
            ...d alliance\gamedata\lua.scd\lua\ui\game\gamemain.lua(322): in function <...d alliance\gamedata\lua.scd\lua\ui\game\gamemain.lua:316>

And I got no clue why. The files mentioned are:

Userinterface:
Code: Select all
local helpFilter = import("/Mods/FilterSelection/Modules/HelpModules/HelpFilterButtons.lua")
local LayoutHelpers = import('/lua/maui/layouthelpers.lua')



function CreateUI(parent)

   local a = helpFilter.CreateFilterButton(parent, "land", true)
   --LayoutHelpers.AtRightTopIn(a, parent, 200 , 200)

end


Helpuserinterface:
Code: Select all
local UIUtil = import('/lua/ui/uiutil.lua')
local Bitmap = import('/lua/maui/bitmap.lua').Bitmap
local Button = import('/lua/maui/button.lua').Button

-- Creates a bitmap.
-- parent: The UI element that is the parent of this UI element. Position is relative to the UI element.
-- normal: The path to the normal icon of this bitmap.
function CreateBitmap(parent, normal)

   LOG("Helpuserinterface: Bitmap path: " .. normal)

   bit = Bitmap(parent)
   bit:SetTexture(RetrieveIcon(normal))

   return bit

end

-- Creates a button.
-- parent: The UI element that is parent of this UI element. Position is relative to the parent.
-- normal: The way the button looks generally.
-- hover: The way the button looks when the mouse is over it.
-- down: the way the button looks when clicked.
-- up: the way the button looks right after clicking and right before going back to the normal / hover state.
function CreateButton(parent, normal, hover, down, up)

   button = Button(parent, RetrieveIcon(normal), RetrieveIcon(hover), RetrieveIcon(down), RetrieveIcon(up) )
   return button

end

-- Retrieves the actual icon from the path.
function RetrieveIcon(iconpath)

    if DiskGetFileInfo(iconpath) == false then
       LOG("Helpuserinterface: Can't find icon in path: " .. iconpath)
        iconpath = '/textures/ui/common/icons/units/default_icon.dds'
    end

    icon = UIUtil.UIFile(iconpath)
    return icon

end


Helpfilterbuttons:
Code: Select all
local helpUI = import("/Mods/FilterSelection/Modules/HelpModules/HelpUserinterface.lua")
local helpTex = import("/Mods/FilterSelection/Modules/HelpModules/HelpTexture.lua")

function CreateFilterButton(parent, iconname, multipleicons)

   local normal, hover, down, up

   if multipleicons then
      normal, hover, down, up = helpTex.GetPathMultipleIcons(iconname)
   else
      normal = helpTex.GetPathIcon(iconname)
      hover = normal
      down = normal
      up = normal
   end

   LOG("We got here!")

   local UIGroup = helpUI.CreateButton(parent, hover, hover, down, up)
   UIGroup.Depth:Set(42)
   UIGroup.Width:Set(34)
   UIGroup.Height:Set(34)

   UIGroup.Neutral = helpUI.CreateBitmap(UIGroup, helpTex.textureNeutral)
   UIGroup.FilterOut = helpUI.CreateBitmap(UIGroup, helpTex.textureFilterOut)
   UIGroup.FilterIn = helpUI.CreateBitmap(UIGroup, helpTex.textureFilterIn)
   UIGroup.Active = false

      UIGroup.OnHide = function (self, hidden)
         if hidden then
            UIGroup.Neutral:Hide()
            UIGroup.FilterOut:Hide()
            UIGroup.FilterIn:Hide()
         else
            if not UIGroup.Active then
               UIGroup.Neutral:Show()
            else
               --UIGroup[tostring(import("/Mods/FilterSelection/Modules/Functionality.lua").functionality)]:Show()
            end
         end

         return true
      end

   return UIGroup
end


Now -before I started redoing a lot of my code it all worked fine.
And, the errors do not make Supreme crash.
However, the bitmaps are not shown (only the button is).

Does anyone have any idea about what could be causing this?

Lots of love,
Jip
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip

Re: Lazy Evaluation: Circular Dependency

Postby nine2 » 23 Jul 2016, 04:30

This is a common problem. You just need to set top/left/width/height on all UI elements.

It's something like this: if you dont specify left and width, it tries to work out the width from the left and right. However since there is no right it tries to work that out form the left and width. And then it realizes it is doing something stupid (detecting in a circle) and gives the error.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Lazy Evaluation: Circular Dependency

Postby Jip » 23 Jul 2016, 13:53

Indeed, you are right. That is quite interesting.
I also found the same answer in the webarchives: http://web.archive.org/web/201310051321 ... php?t=9184

It told me the same.
It's a shame that 90% of the links present on that website are not archived.

Thanks anyway!

Lots of love,
Jip
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest