Jump to content

[API] MiniMapEntity:SetPriority() unexpected effect


LaoWang27
  • Pending

MiniMapEntity priority failed to work in some cases.

Here is a example test script:

function map_test(underfog)
    local icons = {}
    local pos = ThePlayer:GetPosition() + Vector3(100, 0, 0)
    local space = 20
    for z = 1, 3 do
        for x = 1, 3 do
            local v = SpawnPrefab(underfog == true and "globalmapiconunderfog" or "globalmapicon")
            v.Transform:SetPosition(pos.x + (x - 2) * space, 0, pos.z + (z - 2) * space)
            table.insert(icons, v)
        end
    end
    local function setup(index, icon, priority)
        icons[index].MiniMapEntity:SetIcon(icon..".png")
        icons[index].MiniMapEntity:SetPriority(priority)
    end
    setup(5, "moonstormmarker0", 1)         -- in minimap_data1.xml
    setup(1, "lunarrift_portal_max1", 0)    -- in minimap_data1.xml
    setup(3, "lunarrift_portal_max1", 2)    -- in minimap_data1.xml
    setup(7, "lunarrift_portal1", 0)        -- in minimap_data2.xml
    setup(9, "lunarrift_portal1", 2)        -- in minimap_data2.xml

    if underfog then
        TheWorld.minimap.MiniMap:EnableFogOfWar(false)
    end
end

This script will create 3x3 global map icon entities, then setup icon name and priority of the centre one (index = 5) and four corners (index = 1, 3, 7, 9).

If api MiniMapEntity:SetPriority() works well, icons should be stacked in priority order, #3 and #9 should cover #5, and #5 should cover #1 and #7, however, #7 will always cover #5, not match the icon priority.

I added the script to scripts/util.lua to easy run it in console

Result of map_test(false)

minimap-1.jpg.613d0ca9bfaf73f4942105b621e3fe59.jpg

Result of map_test(true)

minimap-2.jpg.dd79f599d20286ad87a298f809caa5c3.jpg

 

-----------------------------------------------------

Possible cause

It seems that icons from minimap_data2.xml always cover minimal_data1.xml, because the former was added to c MiniMap before the latter (see prefabs/minimap.lua, Line 42–43)

If exchange the order of MiniMap:AddAtlas(xxxx), then the icon stacking behaviour will change too.

In addition, all mod minimap icon will cover DST minimap icon, because they are loaded later. (see prefabs/minimap.lua, Line 44–48)

-----------------------------------------------------

I notice this bug when coding Porkland interior minimap mod, some of the icons didn't stack properly, and the issue eventually pointed to a bug in the game itself.

it would be nice if the bug could be fixed.:)

minimap-3.jpg.697bd6c35299325b35b5f62f348a9eb0.jpg

 

 

 


Steps to Reproduce

add map_test function to any scripts (like util.lua)

run map_test in console

  • Like 2



User Feedback




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

×
  • Create New...