Jump to content

Recommended Posts

So! Nearly everything on my mod is working correctly. For the last thing, I created a "cave spider egg sack" prefab that works just like the regular spider egg sack but spawns a Spider Hole instead of a Den once deployed.

It works as it's meant to work, it's spawning the Spider Hole, but I'm having a few issues.

1- The graphics are mostly working. However, it's invisible when on the ground and also the "positioning ghost" for when the player is about to deploy it doesn't show up either. I edited the Spider Hole's graphics to make it on the size of an inventory item and I would like basically the same thing for when it's on the ground or being deployed.

2- When the player deploys it, they're pushed backward. This is probably due to the structure's size x deploying size(?). I don't know if there's a way of fixing this.

issue.thumb.png.6dd9fc9a87392235d5a1a3ec2b830c69.png

Link to comment
https://forums.kleientertainment.com/forums/topic/88387-prefab-graphics-bug-help/
Share on other sites

it's probably something wrong with the build or bank of the inventory item, but we'll need more information about that to know.

As for the physics size pushing them back, you might be able to change its physical size (without changing the size of the sprite) with inst.Physics:SetCapsule(x, y) with x being the diameter and y being height

I based the prefab off the game's normal egg sack.

Spoiler

require "prefabutil"

local Assets =
{
	Asset("ANIM", "anim/cave_spider_egg_sack.zip"),
    Asset("ATLAS", "images/inventoryimages/cave_spider_egg_sack.xml"),
}

local prefabs =
{
    "spiderhole",
}

local function ondeploy(inst, pt)
    inst.SoundEmitter:PlaySound("dontstarve/creatures/spider/spider_egg_sack")
    local tree = SpawnPrefab("spiderhole")
    if tree ~= nil then
        tree.Transform:SetPosition(pt:Get())
        inst.components.stackable:Get():Remove()
    end
end

local function onpickup(inst)
    inst.SoundEmitter:PlaySound("dontstarve/creatures/spider/spider_egg_sack")
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("cave_spider_egg_sack")
    inst.AnimState:SetBuild("cave_spider_egg_sack")
    inst.AnimState:PlayAnimation("idle_90s")

    inst:AddTag("cattoy")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("stackable")
    inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM    
    inst:AddComponent("inspectable")

    inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.LARGE_FUEL

    MakeSmallBurnable(inst, TUNING.LARGE_BURNTIME)
    MakeSmallPropagator(inst)
    MakeHauntableLaunchAndIgnite(inst)

    inst:AddComponent("inventoryitem")
    inst:AddComponent("tradable")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/cave_spider_egg_sack.xml"
	
    inst.components.inventoryitem:SetOnPickupFn(onpickup)

    inst:AddComponent("deployable")
    --inst.components.deployable:SetDeployMode(DEPLOYMODE.ANYWHERE)
    inst.components.deployable:SetDeploySpacing(DEPLOYSPACING.NONE)
    inst.components.deployable.ondeploy = ondeploy

    return inst
end



return Prefab( "cave_spider_egg_sack", fn, Assets),
    MakePlacer("cave_spider_egg_sack_placer", "spider_mound", "spider_mound", "spider_mound")

 

 

This here is the scml, I don't really know how to deal with these files so I also based it off an existing mod.

Spoiler

<?xml version="1.0" encoding="UTF-8"?>
<spriter_data scml_version="1.0" generator="BrashMonkey Spriter" generator_version="b5">
	<folder id="0" name="spider_egg_sac01">
		<file id="0" name="spider_egg_sac01/spider_egg_sac01-0.png" width="344" height="212" pivot_x="0.493313" pivot_y="0.366158" />
	</folder>
	<entity id="0" name="spider_egg_sac">
		<animation id="0" name="idle_90s" length="34">
			<mainline>
				<key id="0" time="0">
					<object_ref id="0" name="spider_egg_sac01" abs_x="0" abs_y="0" abs_pivot_x="0.493313" abs_pivot_y="0.366158" abs_angle="0" abs_scale_x="1" abs_scale_y="1" abs_a="1" timeline="0" key="0" z_index="1" />
				</key>
				<key id="1" time="34">
					<object_ref id="0" name="spider_egg_sac01" abs_x="0" abs_y="0" abs_pivot_x="0.493313" abs_pivot_y="0.366158" abs_angle="0" abs_scale_x="1" abs_scale_y="1" abs_a="1" timeline="0" key="1" z_index="1" />
				</key>
			</mainline>
			<timeline id="0" name="spider_egg_sac01">
				<key id="0" time="0" spin="1">
					<object folder="0" file="0" x="0" y="-0" scale_x="1" scale_y="1" angle="0" />
				</key>
				<key id="1" time="34" spin="1">
					<object folder="0" file="0" x="0" y="-0" scale_x="1" scale_y="1" angle="0" />
				</key>
			</timeline>
		</animation>
	</entity>
</spriter_data>

 

 

I used the game's egg sack image for now just until I make it work, then I'll work on a graphic for it myself.

I'm attaching everything that has to do with the prefab. That's not the entire mod, so I did not include modmain or modinfo or whatever else the mod contains, which I judged to be irrelevant for this. I can post the whole thing if needed.

 

Thanks in advance!

Cave Spider Egg Sack.rar

It worked for the item on the ground, but not for the "placer", like when you're gonna place the normal egg sack as in the picture I attached to this post. Regardless that already helped me a lot! Thank you so much!

 

For anyone who might see this in the future, my problem was with naming things correctly in Spriter. I knew it was something dumb. I haven't really messed around with that tool too much, so yeah.

 

Edit: Just noticed the "PlaySound("dontstarve/creatures/spider/spider_egg_sack")" isn't playing any sounds

 

These are the last things for the grand finale of my mod. I wanna post a thread for it once I'm done with this.

I really appreciate all you guys' help! 

print.png

Edited by RedTarantula

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