RedRock911 Posted May 15, 2015 Share Posted May 15, 2015 Ok.....thought this might be fun for all. So I've been working on a few items, and it seems like everytime I gain a foot foward on how things work, I get a big awkard step back.I started with the handslot item from scratch found "here" I built a Lantern. Which you have to build a bit more on the prefab for it to all work then whats offered on the page.and a few more swap type files for the on and off stuff. SO I looked at a few examples. The monkeyskull lantern is pretty cool, and there is a neat brass lantern as well on the mods page, And it all seemed to go well. I forgot to declare a variable here and there, but for the most part in troubleshooting, I seemed to work things out....of course. Until I got this (dont laugh, cause im not sure how to fix it) Could not find anim bank [ground_shiplantern]Could not find anim bank [ground_shiplantern].../../mods/shiplantern/scripts/prefabs/shiplantern.lua:42: attempt to index field 'Light' (a nil value) Oh and those are the third renames of the bank and build. for those wanting to look at the prefab local assets={Asset("ANIM", "anim/ground_shiplantern.zip"),Asset("ANIM", "anim/swap_shiplantern.zip"),Asset("SOUND", "sound/wilson.fsb"),Asset("ATLAS", "images/inventoryimages/shiplantern.xml"),Asset("IMAGE", "images/inventoryimages/shiplantern.tex"),}prefabs = {"shiplantern",}local function turnon(inst)if not inst.components.fueled:IsEmpty() thenif not inst.components.machine.ison thenif inst.components.fueled theninst.components.fueled:StartConsuming()endinst.Light:Enable(true)inst.AnimState:PlayAnimation("idle_on")if inst.components.equippable:IsEquipped() theninst.components.inventoryitem.owner.AnimState:OverrideSymbol("swap_object", "swap_shiplantern", "swap_shiplantern_on")inst.components.inventoryitem.owner.AnimState:Show("SHIPLANTERN_OVERLAY")endinst.components.machine.ison = trueinst.SoundEmitter:PlaySound("dontstarve/wilson/lantern_on")inst.SoundEmitter:PlaySound("dontstarve/wilson/lantern_LP", "loop")inst.components.inventoryitem:ChangeImageName("shiplantern_lit")endendendlocal function turnoff(inst)if inst.components.fueled theninst.components.fueled:StopConsuming()endinst.Light:Enable(off)inst.AnimState:PlayAnimation("idle_off")if inst.components.equippable:IsEquipped() theninst.components.inventoryitem.owner.AnimState:OverrideSymbol("swap_object", "swap_shiplantern", "swap_shiplantern_off")inst.components.inventoryitem.owner.AnimState:Hide("SHIPLANTERN_OVERLAY")endinst.components.machine.ison = falseinst.SoundEmitter:KillSound("loop")inst.SoundEmitter:PlaySound("dontstarve/wilson/lantern_off")inst.components.inventoryitem:ChangeImageName("ShipLantern")endlocal function OnLoad(inst, data)if inst.components.machine and inst.components.machine.ison theninst.AnimState:PlayAnimation("idle_on")turnon(inst)elseinst.AnimState:PlayAnimation("idle_off")turnoff(inst)endendlocal function ondropped(inst)turnoff(inst)turnon(inst)endlocal function onpickup(inst)turnon(inst)endlocal function onputininventory(inst)turnoff(inst)end--local function onequip(inst, owner)owner.AnimState:Show("ARM_carry")owner.AnimState:Hide("ARM_normal")owner.AnimState:OverrideSymbol("shiplantern_overlay", "swap_shiplantern", "shiplantern_overlay")if inst.components.fueled:IsEmpty() thenowner.AnimState:OverrideSymbol("swap_object", "swap_shiplantern", "swap_shiplantern_off")owner.AnimState:Hide("SHIPLANTERN_OVERLAY")elseowner.AnimState:OverrideSymbol("swap_object", "swap_shiplantern", "swap_shiplantern_on")owner.AnimState:Show("SHIPLANTERN_OVERLAY")endturnon(inst)endlocal function onunequip(inst, owner)owner.AnimState:Hide("ARM_carry")owner.AnimState:Show("ARM_normal")owner.AnimState:ClearOverrideSymbol("shiplantern_overlay")owner.AnimState:Hide("SHIPLANTERN_OVERLAY")endlocal function nofuel(inst)local owner = inst.components.inventoryitem and inst.components.inventoryitem.ownerif owner thenowner:PushEvent("torchranout", {torch = inst})endturnoff(inst)endlocal function takefuel(inst)if inst.components.equippable and inst.components.equippable:IsEquipped() thenturnon(inst)endendlocal function fuelupdate(inst)local fuelpercent = inst.components.fueled:GetPercent()inst.Light:SetIntensity(Lerp(0.4, 0.6, fuelpercent))inst.Light:SetRadius(Lerp(3, 5, fuelpercent))inst.Light:SetFalloff(.9)endlocal function fn(Sim)local inst = CreateEntity()local trans = inst.entity:AddTransform()local anim = inst.entity:AddAnimState()local sound = inst.entity:AddSoundEmitter()MakeInventoryPhysics(inst)anim:SetBank("ground_shiplantern")anim:SetBuild("swap_shiplantern")anim:PlayAnimation("idle")inst:AddTag("light")inst:AddComponent("inspectable")inst:AddComponent("inventoryitem")inst.components.inventoryitem.imagename = "ShipLantern"inst.components.inventoryitem.atlasname = "images/inventoryimages/shiplantern.xml"inst.components.inventoryitem:SetOnDroppedFn(ondropped)inst:AddComponent("equippable")inst:AddComponent("fueled")inst:AddComponent("machine")inst.components.machine.turnonfn = turnoninst.components.machine.turnofffn = turnoffinst.components.machine.cooldowntime = 0inst.components.machine.caninteractfn = function() return not inst.components.fueled:IsEmpty() and (inst.components.inventoryitem.owner == nil or inst.components.equippable.isequipped) endinst.components.equippable:SetOnEquip( onequip )inst.components.equippable:SetOnUnequip( onunequip )inst.OnLoad = OnLoadreturn instendreturn Prefab("common/inventory/shiplantern", fn, assets, prefabs) there it is. as far as I can tell it has to do with the Spriter portion not being able to find the ANIM files, more then likely due to a typo somewhere that I am not seeing. And to be honest ive tried rechanging the names around, and troubleshooting some rookie mistakes in my script, I couldn't tell you where to look first. If none of this helps, and someone needs to look at the Anim files, let me know and ill pm you a link via dropbox. Any help is appreciated. Link to comment Share on other sites More sharing options...
Blueberrys Posted May 15, 2015 Share Posted May 15, 2015 @RedRock911 Didn't read all of it. Read error message, ctrl+f, and didn't find "AddLight" anywhere.See this. Link to comment Share on other sites More sharing options...
RedRock911 Posted May 17, 2015 Author Share Posted May 17, 2015 edited........ran into an issue, going to have to rebuild the item. I deleted something, and have no idea what i did. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.