Jump to content

[Solved] How to change character's minimap icon while in game?


Recommended Posts

My character has is able to change appearance & I would like the minimap icons to update with his appearance as well, does anyone know how I can change character's minimap icon? I tried

inst.MiniMapEntity:SetIcon( "insane_mode.tex" )

in master_postinit but it seems that code only works when character is loaded into the world & it has to be in common_postinit I know this is possible since I think players minimap icons change into ghosts when they die I confused that with player avatars oops, so it'd really be great if someone smarter than me can help, thanks for your time have a great day/night :D!

Edited by SuperDavid
Link to comment
Share on other sites

can someone guide me in right direction all I can find in files related to minimap is this in mapscreen.lua

self.minimap:UpdateTexture()

and these in player_common.lua

Spoiler

inst.MiniMapEntity:SetIcon(name..".png") -- can't be changed
inst.MiniMapEntity:SetPriority(10) -- no idea what this does
inst.MiniMapEntity:SetCanUseCache(false) -- no idea what this does
inst.MiniMapEntity:SetDrawOverFogOfWar(true) -- player can't see it when it's outside of their map range?

 

and minimap.lua doesn't seem to have anything about player icons?

 

Am I supposed to do something like this?

inst.MiniMapEntity:SetIcon( "insane_mode.tex" )
inst.components.minimap:UpdateTexture()

I can't try now but when I can it'll probably crash then I'll post ccrash here for more help lol, thanks for your time have good day/night.

Link to comment
Share on other sites

So I looked some more & in atrium_gate.lua it's able to change its minimap icons by

Spoiler

local function OnKeyGiven(inst, giver)
    --Disable trading, enable picking.
    inst.components.trader:Disable()
    inst.components.pickable:SetUp("atrium_key", 1000000)
    inst.components.pickable:Pause()
    inst.components.pickable.caninteractwith = true

    inst.AnimState:PlayAnimation("idle_active")
    inst.MiniMapEntity:SetIcon("atrium_gate_active.png")

    TheWorld:PushEvent("atriumpowered", true)
    TheWorld:PushEvent("ms_locknightmarephase", "wild")
    TheWorld:PushEvent("pausequakes", { source = inst })
    TheWorld:PushEvent("pausehounded", { source = inst })

    if giver ~= nil then
        inst.SoundEmitter:PlaySound("dontstarve/common/together/atrium_gate/key_in")

--      if giver.components.talker ~= nil then
--          giver.components.talker:Say(GetString(giver, "ANNOUNCE_GATE_ON"))
--      end
    end
end

local function OnKeyTaken(inst)
    --Disable picking, enable trading.
    inst.components.trader:Enable()
    inst.components.pickable.caninteractwith = false
    inst:RemoveTag("intense")

    inst.SoundEmitter:KillSound("loop")

    inst.AnimState:PlayAnimation("idle")
    inst.MiniMapEntity:SetIcon("atrium_gate.png")
    HideFx(inst)

    TheWorld:PushEvent("atriumpowered", false)
    TheWorld:PushEvent("ms_locknightmarephase", nil)
    TheWorld:PushEvent("unpausequakes", { source = inst })
    TheWorld:PushEvent("unpausehounded", { source = inst })
end

 

how come when I try to change minimap icon with " inst.MiniMapEntity:SetIcon("") " it doesn't work? Is there something I'm missing here?

Link to comment
Share on other sites

On 11/19/2017 at 7:51 PM, SuperDavid said:

So I looked some more & in atrium_gate.lua it's able to change its minimap icons by

  Hide contents


local function OnKeyGiven(inst, giver)
    --Disable trading, enable picking.
    inst.components.trader:Disable()
    inst.components.pickable:SetUp("atrium_key", 1000000)
    inst.components.pickable:Pause()
    inst.components.pickable.caninteractwith = true

    inst.AnimState:PlayAnimation("idle_active")
    inst.MiniMapEntity:SetIcon("atrium_gate_active.png")

    TheWorld:PushEvent("atriumpowered", true)
    TheWorld:PushEvent("ms_locknightmarephase", "wild")
    TheWorld:PushEvent("pausequakes", { source = inst })
    TheWorld:PushEvent("pausehounded", { source = inst })

    if giver ~= nil then
        inst.SoundEmitter:PlaySound("dontstarve/common/together/atrium_gate/key_in")

--      if giver.components.talker ~= nil then
--          giver.components.talker:Say(GetString(giver, "ANNOUNCE_GATE_ON"))
--      end
    end
end

local function OnKeyTaken(inst)
    --Disable picking, enable trading.
    inst.components.trader:Enable()
    inst.components.pickable.caninteractwith = false
    inst:RemoveTag("intense")

    inst.SoundEmitter:KillSound("loop")

    inst.AnimState:PlayAnimation("idle")
    inst.MiniMapEntity:SetIcon("atrium_gate.png")
    HideFx(inst)

    TheWorld:PushEvent("atriumpowered", false)
    TheWorld:PushEvent("ms_locknightmarephase", nil)
    TheWorld:PushEvent("unpausequakes", { source = inst })
    TheWorld:PushEvent("unpausehounded", { source = inst })
end

 

how come when I try to change minimap icon with " inst.MiniMapEntity:SetIcon("") " it doesn't work? Is there something I'm missing here?

That's the altrium gate code right? do you have yours?

Link to comment
Share on other sites

My code is simply

local function common_postinit(inst)
	inst.MiniMapEntity:SetIcon("normal_mode.tex")
end

local master_postinit = function(inst)
	inst:DoTaskInTime(1, function(inst) 
		inst.MiniMapEntity:SetIcon("insane_mode.tex")
	end)
end

even putting

ThePlayer.MiniMapEntity:SetIcon("atrium_gate_active.png")

ThePlayer.components.MiniMapEntity:SetIcon("atrium_gate_active.png")

into console doesn't work, I'm so confused what's wrong, I didn't think it'd be so darn hard to change a minimap texture :wilson_dilemma:..

Link to comment
Share on other sites

9 minutes ago, SuperDavid said:

My code is simply


local function common_postinit(inst)
	inst.MiniMapEntity:SetIcon("normal_mode.tex")
end

local master_postinit = function(inst)
	inst:DoTaskInTime(1, function(inst) 
		inst.MiniMapEntity:SetIcon("insane_mode.tex")
	end)
end

even putting


ThePlayer.MiniMapEntity:SetIcon("atrium_gate_active.png")

ThePlayer.components.MiniMapEntity:SetIcon("atrium_gate_active.png")

into console doesn't work, I'm so confused what's wrong, I didn't think it'd be so darn hard to change a minimap texture :wilson_dilemma:..

I don't have a transforming character I can test this with, but have you tried putting

    Asset("MINIMAP_IMAGE", "insane_mode.tex"),

at the top? I noticed that

    Asset("MINIMAP_IMAGE", "atrium_gate_active"),

was at the top of the Altrium gate file. 

Link to comment
Share on other sites

On 11/30/2017 at 11:10 PM, SuperDavid said:

@TagumonYatsuray Bruh, thank you thank you thank you thank you so much it finally works :wilson_celebrate:!!!!!!!

SERIOUSLY!? I WAS GUESSING.... I just wanted to help you out, since you helped me

For reference, do you have your end result code? I would like to try my hand at transforming characters

Edited by TagumonYatsuray
Link to comment
Share on other sites

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
 Share

×
  • Create New...