Jump to content

Needing Help with adding a new Fueltype


Recommended Posts

Ok I'm like ripping my hair out at this code I'm working on... I can't get the fuel to work on the item.

 

Here's me codes

the item

local assets ={    Asset("ANIM", "anim/cursedsword.zip"),	Asset("ANIM", "anim/swap_cursedsword.zip"),	Asset("IMAGE", "images/inventoryimages/cursedsword.tex"),	Asset("ATLAS", "images/inventoryimages/cursedsword.xml"),} local function onequip(inst, owner)	owner.AnimState:OverrideSymbol("swap_object", "swap_cursedsword", "swap_nightmaresword")	owner.AnimState:Show("ARM_carry")	owner.AnimState:Hide("ARM_normal")	if inst.components.fueled then		inst.components.fueled:StartConsuming()	end	owner.components.sanity.inducedinsanity = true	owner:PushEvent("goinsane", {})endlocal function onunequip(inst, owner)	owner.AnimState:Hide("ARM_carry") 	owner.AnimState:Show("ARM_normal")	if inst.components.fueled then		inst.components.fueled:StopConsuming()	end	owner.components.sanity.inducedinsanity = false	owner:PushEvent("gosane", {})endlocal function fn()    local inst = CreateEntity()     inst.entity:AddTransform()    inst.entity:AddAnimState()    inst.entity:AddSoundEmitter()    inst.entity:AddNetwork()     MakeInventoryPhysics(inst)     inst.AnimState:SetBank("nightmaresword")    inst.AnimState:SetBuild("cursedsword")    inst.AnimState:PlayAnimation("idle") 	inst:AddTag("sharp")    if not TheWorld.ismastersim then		return inst    end     inst.entity:SetPristine()     inst:AddComponent("inspectable")			inst:AddComponent("weapon")	inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE * 1.6)		    inst:AddComponent("inventoryitem")	inst.components.inventoryitem.atlasname = "images/inventoryimages/cursedsword.xml"			inst:AddComponent("equippable")	inst.components.equippable:SetOnEquip( onequip )	inst.components.equippable:SetOnUnequip( onunequip )		inst:AddComponent("fueled")    inst.components.fueled.fueltype = "CURSED"    inst.components.fueled:InitializeFuelLevel(500)	inst.components.fueled.accepting = true    return instend return Prefab("common/inventory/cursedsword", fn, assets)

and the fuel

local assets ={	Asset("ANIM", "anim/cursedfuel.zip"),}local function fn()	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()    inst.entity:AddNetwork()        MakeInventoryPhysics(inst)    inst.AnimState:SetBank("livinglog")    inst.AnimState:SetBuild("cursedfuel")    inst.AnimState:PlayAnimation("idle")    if not TheWorld.ismastersim then        return inst    end    inst.entity:SetPristine()    inst:AddComponent("fuel")    inst.components.fuel.fueltype = "CURSED"    inst.components.fuel.fuelvalue = 150	inst:AddComponent("inspectable")    inst:AddComponent("inventoryitem")	inst.components.inventoryitem.atlasname = "images/inventoryimages/cursedfuel.xml"	    inst:AddComponent("stackable")	inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM	return instendreturn Prefab("common/inventory/cursedfuel", fn, assets)
Link to comment
Share on other sites

@Crazybait24, I'm guessing it correctly burns the fuel when you equip it, but that it's not letting you refuel it with the cursedfuel?

 

Although I'm looking at mininglantern and lightbulb and it looks like your code should work...

 

Edit: Ah, looks like you need to be adding the fueltype to the FUELTYPE table, too, since that's what the FUEL componentaction checks.

Edited by rezecib
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...