Jump to content

I still have problems about my containing Item.


Recommended Posts

My mod item with the function of chest still make crash for guest player.

 

Following is the error message and my original code.

 

http://prntscr.com/5onzbb

local assets={	Asset("ANIM", "anim/buckyball.zip"),  Asset("ATLAS", "images/inventoryimages/buckyball.xml"),  Asset("IMAGE", "images/inventoryimages/buckyball.tex")}local function OnDropped(inst)    inst.Light:Enable(true)endlocal function OnPickup(inst)    inst.Light:Enable(false)endlocal function onopen(inst)    inst.SoundEmitter:PlaySound("dontstarve/common/butterfly_trap")end local function onclose(inst)     inst.SoundEmitter:PlaySound("dontstarve/common/butterfly_trap")end local function fn()	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()	inst.entity:AddSoundEmitter()    inst.entity:AddLight()    inst.entity:AddNetwork()    MakeInventoryPhysics(inst)    inst.AnimState:SetBank("bulb")    inst.AnimState:SetBuild("buckyball")    inst.AnimState:PlayAnimation("idle")        inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )    local light = inst.entity:AddLight()    light:SetFalloff(0.7)    light:SetIntensity(.5)    light:SetRadius(1.0)    light:SetColour(237/255, 237/255, 209/255)    light:Enable(true)    if not TheWorld.ismastersim then        return inst    end    inst.entity:SetPristine()    inst:AddComponent("tradable")    inst:AddComponent("inspectable")        inst:AddComponent("fuel")    inst.components.fuel.fuelvalue = TUNING.TINY_FUEL    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/inventoryimages/buckyball.xml"    inst.components.inventoryitem:SetOnDroppedFn(OnDropped)    inst.components.inventoryitem:SetOnPickupFn(OnPickup)    inst:AddComponent("container")    inst.components.container:WidgetSetup("treasurechest")    inst.components.container.onopenfn = onopen    inst.components.container.onclosefn = onclose    MakeHauntableLaunchAndDropFirstItem(inst)	return instend	return Prefab( "common/inventory/buckyball", fn, assets ) 

Actually, I tried to put the code recezib gave me.

 

But, whenever I did this, DST automatically went out or had no response.

 

I think it's my fault because I'm not a good mod maker and I feel like I have to revise this code properly.

 

But, I failed..

 

Can you give me more detailed way to put that code in my lua file??

 

 

 

Edited by Conker446
Link to comment
Share on other sites

My mod item with the function of chest still make crash for guest player.

 

Following is the error message and my original code.

 

http://prntscr.com/5onzbb

local assets={	Asset("ANIM", "anim/buckyball.zip"),  Asset("ATLAS", "images/inventoryimages/buckyball.xml"),  Asset("IMAGE", "images/inventoryimages/buckyball.tex")}local function OnDropped(inst)    inst.Light:Enable(true)endlocal function OnPickup(inst)    inst.Light:Enable(false)endlocal function onopen(inst)    inst.SoundEmitter:PlaySound("dontstarve/common/butterfly_trap")end local function onclose(inst)     inst.SoundEmitter:PlaySound("dontstarve/common/butterfly_trap")end local function fn()	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()	inst.entity:AddSoundEmitter()    inst.entity:AddLight()    inst.entity:AddNetwork()    MakeInventoryPhysics(inst)    inst.AnimState:SetBank("bulb")    inst.AnimState:SetBuild("buckyball")    inst.AnimState:PlayAnimation("idle")        inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )    local light = inst.entity:AddLight()    light:SetFalloff(0.7)    light:SetIntensity(.5)    light:SetRadius(1.0)    light:SetColour(237/255, 237/255, 209/255)    light:Enable(true)    if not TheWorld.ismastersim then        return inst    end    inst.entity:SetPristine()    inst:AddComponent("tradable")    inst:AddComponent("inspectable")        inst:AddComponent("fuel")    inst.components.fuel.fuelvalue = TUNING.TINY_FUEL    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/inventoryimages/buckyball.xml"    inst.components.inventoryitem:SetOnDroppedFn(OnDropped)    inst.components.inventoryitem:SetOnPickupFn(OnPickup)    inst:AddComponent("container")    inst.components.container:WidgetSetup("treasurechest")    inst.components.container.onopenfn = onopen    inst.components.container.onclosefn = onclose    MakeHauntableLaunchAndDropFirstItem(inst)	return instend	return Prefab( "common/inventory/buckyball", fn, assets ) 

Actually, I tried to put the code recezib gave me.

 

But, whenever I did this, DST automatically went out or had no response.

 

I think it's my fault because I'm not a good mod maker and I feel like I have to revise this code properly.

 

But, I failed..

 

Can you give me more detailed way to put that code in my lua file??

 

 

I finally solved that.

 

Thank you recezib!

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