Jump to content

Recommended Posts

I'm trying to turn frogs into inventory items.

In my mod folder I have images/inventoryimages and I have placed a 64x64 png of a frog in it. I start up the DST and it builds the .tex and .xml files for me. I've checked the names of everything, it all matches up perfectly.

in my modmain.lua

local assets =
{
  Asset("IMAGE", "images/inventoryimages/frog.tex"),
  Asset("ATLAS", "images/inventoryimages/frog.xml"),
}

AddPrefabPostInit("frog", 
function(inst)

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/frog.xml"
    inst.components.inventoryitem.nobounce = true
    inst.components.inventoryitem.canbepickedup = false
    inst.components.inventoryitem.canbepickedupalive = true

end)

when I type into the console c_give("frog") it doesn't look like anything happened, but i know i have a frog in my inventory because i can right click on the 1st slot and i get a frogleg, or i can left click it and then i can drop it somewhere and it becomes a regular frog.

For some reason it's invisible and I don't know why.

 

Another weird issue... I can right click on the frog in my inventory to murder it and I get frog legs. That's great, that's exactly what I wanted to happen, but it does not give the right mouse button to murder prompt like you get when you mouse over a bee, rabbit, bird, moleworm, butterfly, or mosquito in your inventory.

Edited by HomShaBom
8 hours ago, HomShaBom said:

I'm trying to turn frogs into inventory items.

In my mod folder I have images/inventoryimages and I have placed a 64x64 png of a frog in it. I start up the DST and it builds the .tex and .xml files for me. I've checked the names of everything, it all matches up perfectly.

in my modmain.lua


local assets =
{
  Asset("IMAGE", "images/inventoryimages/frog.tex"),
  Asset("ATLAS", "images/inventoryimages/frog.xml"),
}

AddPrefabPostInit("frog", 
function(inst)

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/frog.xml"
    inst.components.inventoryitem.nobounce = true
    inst.components.inventoryitem.canbepickedup = false
    inst.components.inventoryitem.canbepickedupalive = true

end)

when I type into the console c_give("frog") it doesn't look like anything happened, but i know i have a frog in my inventory because i can right click on the 1st slot and i get a frogleg, or i can left click it and then i can drop it somewhere and it becomes a regular frog.

For some reason it's invisible and I don't know why.

 

Another weird issue... I can right click on the frog in my inventory to murder it and I get frog legs. That's great, that's exactly what I wanted to happen, but it does not give the right mouse button to murder prompt like you get when you mouse over a bee, rabbit, bird, moleworm, butterfly, or mosquito in your inventory.

do you have TEXcreator? sometimes the files have issues and need to be compiled manually

18 minutes ago, mf99k said:

do you have TEXcreator? sometimes the files have issues and need to be compiled manually

I do have TEXcreator, I tried converting the .png file into .tex using it, but it still doesn't show in game. The file seems to be fine because when I open it with TEXtool it looks fine, I can convert it back to png and everything... My guess is that when you make a new prefab you pass the assets as a parameter to the Prefab constructor..

 

From data/scripts/prefabs/frog.lua (assets are created and passed into Prefab constructor)

local assets =
{
    Asset("ANIM", "anim/frog.zip"),
    Asset("SOUND", "sound/frog.fsb"),
}

...

return Prefab("frog", fn, assets, prefabs)

In my mod script I'm creating assets with the inventory images, but since I'm modifying a prefab that has already been created there's no way for me to pass the assets into the constructor and I'm not sure how else to get the assets into it.

But that may not even be the issue, I am not sure.

Edited by HomShaBom

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