Jump to content

Recommended Posts

First, what's the syntax for the makeplacer function/class. I know that it's something along the lines of 'MakePlacer("placername","prefab","prefab", start anim)' but I can't find it anywhere in the main code. Also, my item (which is based off of gold nuggets) doesn't have a texture. I copied the files for gold nuggets (I hope), but the item doesn't show up. This is my item file:

Spoiler

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

local function shine(inst)
    inst.task = nil
    inst.AnimState:PlayAnimation("sparkle")
    inst.AnimState:PushAnimation("idle")
    inst.task = inst:DoTaskInTime(4+math.random()*5, function() shine(inst) end)
end


local function fn(Sim)
    
    local inst = CreateEntity()
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddPhysics()
    MakeInventoryPhysics(inst)

    inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )
    
    inst.AnimState:SetBank("goldnugget")
    inst.AnimState:SetBuild("gold_nugget")
    inst.AnimState:PlayAnimation("idle")

    inst:AddComponent("edible")
    inst.components.edible.foodtype = "ELEMENTAL"
    inst.components.edible.hungervalue = 2
    inst:AddComponent("tradable")
    
    inst:AddComponent("inspectable")
    
    inst:AddComponent("stackable")
    inst:AddComponent("inventoryitem")
    
    shine(inst)
    
    return inst
end

return Prefab( "common/inventory/coppernugget", fn, assets)

 

You need to set the custom icon like so:

inst.components.inventoryitem.atlasname = "images/inventoryitems/coppernugget.xml"

MakePlacer(name, bank, build, anim, ongroundorientation, snap, metersnap, scale) is defined in "data/scripts/prefabutil.lua".

20 hours ago, memcallen said:

My item doesn't have a name so it defaulted to 'Missing name', and me being a noob to don't starve modding, I have no idea how to fix it.

You need to set a name "string" via modmain.lua like so

GLOBAL.STRINGS.NAMES.ITEMNAME = "Fancy Name"

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