Jump to content

Recommended Posts

I'm trying to make a craftable edible item. It appears in inventory (starting_inv) and on ground when dropped. However, it crashes in food" recipe tab (scrolling down).

I've done this (making custom item, but inedible) before but I can't figure out why this one crashed.

 

Log:

[00:23:33]: WARNING! Could not find region 'OUTOFSPACE' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas?
[00:23:33]: Looking for default texture '(null)' from atlas 'images/inventoryimages.xml'.
[00:23:33]: images/inventoryimages.xml
LUA ERROR stack traceback:
        scripts/widgets/image.lua(30,1) in function 'SetTexture'
 
My modmain:
local recipes = 
{
  Recipe("ggwooddeluxe"
  ,{Ingredient("twigs", 6),Ingredient("logs", 3),Ingredient("boards",1),}
  ,RECIPETABS.FARM --Food
  ,{SCIENCE=1}),
}
 
for k,v in pairs(recipes) do
  v.tagneeded = true
  v.atlas = "images/inventoryimages/" .. v.name .. ".xml"
end

 

The ggwooddeluxe.lua:

local assets=
{
Asset("ANIM", "anim/ggwooddeluxe.zip"),
 
Asset("IMAGE", "images/inventoryimages/ggwooddeluxe.tex"),
Asset("ATLAS", "images/inventoryimages/ggwooddeluxe.xml")
}
 
local function OnDropped(inst)
    inst.Light:Enable(true)
end
 
local function OnPickup(inst)
    inst.Light:Enable(false)
end
 
local function fn()
local inst = CreateEntity()
 
inst.entity:AddTransform()
inst.entity:AddAnimState()
inst.entity:AddLight()
inst.entity:AddNetwork()
 
MakeInventoryPhysics(inst)
 
inst.AnimState:SetBank("ggwooddeluxe")
inst.AnimState:SetBuild("ggwooddeluxe")
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()
 
local minimap = inst.entity:AddMiniMapEntity()
    minimap:SetIcon("ggwooddeluxe.tex")
 
inst:AddComponent("inspectable")
 
inst:AddComponent("inventoryitem")
inst.components.inventoryitem.imagename = "ggwooddeluxe"
inst.components.inventoryitem.atlasname = "images/inventoryimages/ggwooddeluxe.xml"
 
inst:AddComponent("stackable")
inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM
 
inst.components.inventoryitem:SetOnDroppedFn(OnDropped)
    inst.components.inventoryitem:SetOnPickupFn(OnPickup)
 
inst:AddComponent("edible")
inst.components.edible.foodtype = FOODTYPE.MYCHARFOOD
inst:AddTag("edible_"..FOODTYPE.MYCHARFOOD)
inst.components.edible.healthvalue = 16
    inst.components.edible.hungervalue = 68
    inst.components.edible.sanityvalue = 0
 
MakeHauntableLaunchAndDropFirstItem(inst)
 
inst:AddComponent("characterspecific")
inst.components.characterspecific:SetOwner("MyChar")
    
return inst
end
 
return Prefab( "common/inventory/ggwooddeluxe", fn, assets) 
 
Thanks!
 
Edit:
I deleted all zip files from anim\ but the zip files are not re-created.
What gives?
 
Now let me try that recipe tab again...
 
Edit:
Still crashes. Darn.
Edited by SenL

Shouldn't it be like this for the recipe? This is how the format is handled for in the base game files. Note the tech tree difference between your post and mine. Base game types out the numbers rather than using the actual number for some reason in recipes.lua, it looks like.

local recipes = { Recipe("ggwooddeluxe", {Ingredient("twigs", 6), Ingredient("logs", 3), Ingredient("boards",1),}, RECIPETABS.FARM, TECH.SCIENCE_ONE),}

Another issue.

Host (mychar) can create ggwooddeluxe with no problem. However, client (mychar) can't. He would be doing "crafting animation" for 2 seconds and then nothing. No ingredients consumed, no ggwooddeluxe resulted.

Relogged twice = no fix. Shut down server and try again = no fix.

Any ideas?

 

Thanks.

Previous issue is that it crashes when I change max size to 2

or to

TUNING.STACK_SIZE_LARGEITEM-8 --2

 

Log:

[00:03:31]: [string "scripts/components/stackable_replica.lua"]:21: attempt to perform arithmetic on field '?' (a nil value)
LUA ERROR stack traceback:
scripts/components/stackable_replica.lua:21 in (method) SetMaxSize (Lua) <20-22>
 
Odd...

@SenL, Your log had all the information you needed to see why it was going wrong... First, look at stackable_replica. It should be pretty clear why it's crashing if you just take a few minutes to read the line that's causing the error and look at the things it calls. It's a really short file.

 

It takes the stack sizes defined in the game (smallitem, meditem, largeitem), and assigns them indexes (0, 1, 2), and only transmits the index to clients to reduce the amount of data transferred. Unfortunately this is all in a local table... 

 

So I think your only option for a custom stacksize is to replace stackable_replica.

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