Jump to content

Recommended Posts

Hello, I need help because I am dumb and can't figure this out.

I'm trying to make a mod prefab show up on the map always like the moonlens, but it doesn't seem to work? I copy pasted code from the moonlens which I thought is what makes it appear on the map always, but it doesn't seem to do anything :wilson_resigned:..

Spoiler

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()
	inst.entity:AddMiniMapEntity()
	MakeObstaclePhysics(inst, .75)

    inst:AddTag("structure")
	inst:AddTag("grand_totem")

	inst.AnimState:SetBank("grand_totem")
	inst.AnimState:SetBuild("grand_totem")
	inst.AnimState:PlayAnimation("idle")
	
	inst.MiniMapEntity:SetIcon("grand_totem.tex")
	inst.MiniMapEntity:SetCanUseCache(false) --from moonlens
	inst.MiniMapEntity:SetDrawOverFogOfWar(true) --from moonlens

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then return inst end
	
 --from moonlens
	inst.icon = nil
	if inst.icon == nil then
		inst.icon = SpawnPrefab("globalmapicon")
		inst.icon:TrackEntity(inst)
	end

 

Thanks for your time and any help, have a great day :D!

I don't really understand what you're trying to do but seems this code works.

local assets = {
    Asset("ANIM", "anim/sentryward.zip"),
}

local function OnInit(inst)
	inst.icon = SpawnPrefab("globalmapicon")
	inst.icon:TrackEntity(inst)
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()
	inst.entity:AddMiniMapEntity()
	MakeObstaclePhysics(inst, .75)

    inst:AddTag("structure")

	inst.MiniMapEntity:SetIcon("sentryward.png")
	inst.MiniMapEntity:SetCanUseCache(false)
	inst.MiniMapEntity:SetDrawOverFogOfWar(true)

	inst.AnimState:SetBank("sentryward")
    inst.AnimState:SetBuild("sentryward")
    inst.AnimState:PlayAnimation("idle_full_loop", true)
	
    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

	inst:AddComponent("inspectable")

	inst:DoTaskInTime(0, OnInit)

    return inst
end

return Prefab("teststructure", fn, assets) 

It's kind of full script because I have to test it.

I think I should explain this after confirming your answer if this is what you were trying to do or not.

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...