2badatmodding Posted June 17, 2022 Share Posted June 17, 2022 Hi im trying to make a items like a panflute im using the code in scripts and where do i put this? local assets= { Asset("ANIM", "anim/pan_flute.zip"), } local function onfinished(inst) inst:Remove() end local function HearPanFlute(inst, musician, instrument) if inst.components.sleeper then inst.components.sleeper:AddSleepiness(10, TUNING.PANFLUTE_SLEEPTIME) end end local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst:AddTag("flute") inst.AnimState:SetBank("pan_flute") inst.AnimState:SetBuild("pan_flute") inst.AnimState:PlayAnimation("idle") MakeInventoryPhysics(inst) inst:AddComponent("inspectable") inst:AddComponent("instrument") inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE inst.components.instrument:SetOnHeardFn(HearPanFlute) inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.PLAY) inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(TUNING.PANFLUTE_USES) inst.components.finiteuses:SetUses(TUNING.PANFLUTE_USES) inst.components.finiteuses:SetOnFinished( onfinished) inst.components.finiteuses:SetConsumption(ACTIONS.PLAY, 1) inst:AddComponent("inventoryitem") return inst end return Prefab( "common/inventory/panflute", fn, assets) Would I just put this in the custom item lua? any help would help thanks! Link to comment https://forums.kleientertainment.com/forums/topic/140926-how-to-make-panflute-like-item/ Share on other sites More sharing options...
Leonidas IV Posted June 17, 2022 Share Posted June 17, 2022 In MOD_ROOT/scripts/prefabs where MOD_ROOT is your mod folder. This is where the game will look for your mod's prefabs to load. But be aware that if you just copy this to a file with another name, your item will replace the Pan Flute, as the prefab name ("panflute") is the same. You need to give your item a unique name (which doesn't have to be the same as the file name) Link to comment https://forums.kleientertainment.com/forums/topic/140926-how-to-make-panflute-like-item/#findComment-1577744 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now