Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Clopen

Map Icons Z Ordering and MiniMapEntity:SetPriority()

Recommended Posts

Clopen    12

I have made a simple mod in which I added map icons to existing prefabs.
These icons appear, but they hide the player icon on the map.

After looking around, I found that MiniMapEntity has a function called SetPriority which seems to control the Z ordering of layers.
I've tried setting it to various numbers, to no effect.
What's more, I used the in-game console, placed my mouse cursor over an instance of one of these prefabs and then executed the command:

TheInput:GetWorldEntityUnderMouse().MiniMapEntity:SetPriority(1)

Nothing changed.
I tried various values, of course.
If I did the same on an instance of some other random prefab (specifically one of the pig houses in Hamlet), changing the priority value like this did put its icon over or under the player's icon, but it didn't work on the ones I changed.
In case it matters, the prefabs I changed were of the pig merchants (this mod is for showing icons for the merchants so it would be easier to find the ones you want to trade with).

Any idea what I'm doing wrong here and how I can make the icons appear under the player icon?

This is the entirety of my short modmain.lua file:

Assets =
{
}

local TRADERS = {
	"pigman_collector",
	"pigman_banker",
	"pigman_beautician",
	"pigman_mechanic",
	"pigman_professor",
	"pigman_hunter",
	"pigman_mayor",
	"pigman_florist",
	"pigman_storeowner",
	"pigman_farmer",
	"pigman_miner",
	"pigman_erudite",
	"pigman_hatmaker",
	"pigman_queen",
	"pigman_usher",
}

for i, trader in ipairs(TRADERS) do
	table.insert(Assets, Asset("IMAGE", "minimap/" .. trader .. "_icon.tex"))
	table.insert(Assets, Asset("ATLAS", "minimap/" .. trader .. "_icon.xml"))
	AddMinimapAtlas("minimap/" .. trader .. "_icon.xml")
	
	AddPrefabPostInit(trader, function(inst)
		local minimap = inst.MiniMapEntity or inst.entity:AddMiniMapEntity()
		minimap:SetIcon(trader .. "_icon.tex")
		minimap:SetPriority(1)
	end)
end

Thanks in advance.

Share this post


Link to post
Share on other sites