Jump to content

How Would I Temporarily Change the Sprites for an Already Existing Sprite?


Recommended Posts

49 minutes ago, thegreatJash said:

So I just put this all together in the rainshell.lua? Seems like a lot just to make it hammerable. It would be cool if you could attach a downloadable file for singshell.lua because I don't know what's wrong with me but I can't seem to find it. Thanks.

singingshell.lua

  • Like 1
Link to comment
Share on other sites

4 hours ago, Hornete said:

Oh boy. A lot of crashes today.

First of all, your minisign code still doesn't work. First I tried the code that you gave me, and then I realized that "rainshell.tex" isn't a file, so I put the correct name, "rain_shell.tex' instead. Still nothing. Have you managed to get minisign icons for your mods?

Second, the unique animation code still busts the game. Here's a screenshot of the crash.1707630057_Screenshot(29).thumb.png.5a6efdb4781a86957c28c181106b5cd5.png

Here's the current code for it.

Spoiler

 

local EventHandler = GLOBAL.EventHandler
local TimeEvent = GLOBAL.TimeEvent
local FRAMES = GLOBAL.FRAMES

AddStategraphState("wilson", GLOBAL.State{
        name = "play_shell", --The name of your state(Maybe you want to make the name more unique? If another mod adds the same name, it'll override, and "play_shell" is a pretty basic name, your noice!)
        tags = { "doing", "playing" }, --Tags to add during the state

        onenter = function(inst)
            inst.components.locomotor:Stop() --Tell our character to stop moving
            inst.AnimState:PlayAnimation("action_uniqueitem_pre") --play the necessary animations
            inst.AnimState:PushAnimation("horn", false) --PushAnimation queues the next animation

            inst.AnimState:OverrideSymbol("horn01", "rain_shell", "shell") --We are overriding the "pan_flute01" symbol with the "shell" symbol from our "rain_shell" file

            inst.AnimState:Hide("ARM_carry")
            inst.AnimState:Show("ARM_normal")
            inst.components.inventory:ReturnActiveActionItem(inv_obj)
        end,

        timeline =
        {
            TimeEvent(30 * FRAMES, function(inst)
                if inst:PerformBufferedAction() then
                    inst.SoundEmitter:PlaySound("dontstarve/wilson/flute_LP", "flute") --Play the flute sound, (Maybe make a unique sound? would be cool :P)
                else
                    inst.AnimState:SetTime(94 * FRAMES)
                end
            end),
            TimeEvent(85 * FRAMES, function(inst)
                inst.SoundEmitter:KillSound("flute")
            end),
        },

        events =
        {
            EventHandler("animqueueover", function(inst)
                if inst.AnimState:AnimDone() then
                    inst.sg:GoToState("idle") --When the animation is done, return to the idle state
                end
            end),
        },

        onexit = function(inst)
            inst.SoundEmitter:KillSound("flute") --kill the flute sound
            if inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) then
                inst.AnimState:Show("ARM_carry")
                inst.AnimState:Hide("ARM_normal")
            end
        end,
    })

  AddStategraphPostInit("wilson", function(sg)
    local _PLAY = sg.actionhandlers[ACTIONS.PLAY].deststate --Save the original function determining the state for the PLAY action
    sg.actionhandlers[ACTIONS.PLAY].deststate = function(inst, act, ...)
        return act.invobject ~= nil --Make sure the object responsible for the action exists, unlikely to happen, but if it does happen, the game would crash! So this check is important
            and    (act.invobject:HasTag("rain_shell") and "play_shell") --If the object has the "rain_shell" tag, then the play_shell state will play
            or _PLAY(inst, act, ...) --If all checks fail, go back to the original vanilla function
    end
end)

 

Also, the hammering code. First the game would crash because of the code not being in the proper order. I rearranged it and then the game loaded in just fine. But when I actually hammered it, it crashed again. It said something about the SoundEmitter being a nil value? Here's a screenshot of that.1964132857_Screenshot(28).thumb.png.fbe30b6b67b6135f1ead2101ddcf3701.png 

As you can see, it seems the shells and little bug are loading in fine. You can actually see them in the screenshot.

Oh well, I guess I am making some progress. Here's the crash log if you need it. Thanks in advance.

client_log.txt

Edited by thegreatJash
  • Like 1
Link to comment
Share on other sites

19 minutes ago, thegreatJash said:

First of all, your minisign code still doesn't work. First I tried the code that you gave me, and then I realized that "rainshell.tex" isn't a file, so I put the correct name, "rain_shell.tex' instead. Still nothing.

There's your problem.

The image file name and prefab name need to be the same, currently the prefab name is "rainshell", and the image names are "rain_shell".
 

20 minutes ago, thegreatJash said:

Second, the unique animation code still busts the game. Here's a screenshot of the crash.

image.png.392850b357ec272198a4cc18bcf69874.png
Generally when it says "attempt to index global x" that means you need to put GLOBAL. before that variable, or do local x = GLOBAL.x like for the other variables before.
 

20 minutes ago, thegreatJash said:

Also, the hammering code. First the game would crash because of the code not being in the proper order. I rearranged it and then the game loaded in just fine. But when I actually hammered it, it crashed again. It said something about the SoundEmitter being a nil value? Here's a screenshot of that.

You need to add the SoundEmitter engine component to your entity, in the part of the prefab file where you can see..
 

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

or something akin to that, Add the line
 

inst.entity:AddSoundEmitter()

And now the entity will be able to play sounds.

  • Like 1
Link to comment
Share on other sites

30 minutes ago, Hornete said:

There's your problem.

The image file name and prefab name need to be the same, currently the prefab name is "rainshell", and the image names are "rain_shell".
 

image.png.392850b357ec272198a4cc18bcf69874.png
Generally when it says "attempt to index global x" that means you need to put GLOBAL. before that variable, or do local x = GLOBAL.x like for the other variables before.
 

You need to add the SoundEmitter engine component to your entity, in the part of the prefab file where you can see..
 


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

or something akin to that, Add the line
 


inst.entity:AddSoundEmitter()

And now the entity will be able to play sounds.

The hammering animation works, so that's pretty cool. Thanks. 

I also changed the image names from rain_shell.TEX and.XML to rainshell.TEX and .XML. I also loaded them in the modmain and rainshell prefab. What would I put in for the minsign now that I have done this? I currently have RegisterInventoryItemAtlas("images/rainshell.xml", "rainshell").

Also the game still crashes even after I put local x = GLOBAL.x at the beggining of the code. Here is the current code I am working with.

Spoiler

 

local EventHandler = GLOBAL.EventHandler
local TimeEvent = GLOBAL.TimeEvent
local FRAMES = GLOBAL.FRAMES
local x = GLOBAL.x

AddStategraphState("wilson", GLOBAL.State{
        name = "play_shell", --The name of your state(Maybe you want to make the name more unique? If another mod adds the same name, it'll override, and "play_shell" is a pretty basic name, your noice!)
        tags = { "doing", "playing" }, --Tags to add during the state

        onenter = function(inst)
            inst.components.locomotor:Stop() --Tell our character to stop moving
            inst.AnimState:PlayAnimation("action_uniqueitem_pre") --play the necessary animations
            inst.AnimState:PushAnimation("horn", false) --PushAnimation queues the next animation

            inst.AnimState:OverrideSymbol("horn01", "rain_shell", "shell") --We are overriding the "pan_flute01" symbol with the "shell" symbol from our "rain_shell" file

            inst.AnimState:Hide("ARM_carry")
            inst.AnimState:Show("ARM_normal")
            inst.components.inventory:ReturnActiveActionItem(inv_obj)
        end,

        timeline =
        {
            TimeEvent(30 * FRAMES, function(inst)
                if inst:PerformBufferedAction() then
                    inst.SoundEmitter:PlaySound("dontstarve/wilson/flute_LP", "flute") --Play the flute sound, (Maybe make a unique sound? would be cool :P)
                else
                    inst.AnimState:SetTime(94 * FRAMES)
                end
            end),
            TimeEvent(85 * FRAMES, function(inst)
                inst.SoundEmitter:KillSound("flute")
            end),
        },

        events =
        {
            EventHandler("animqueueover", function(inst)
                if inst.AnimState:AnimDone() then
                    inst.sg:GoToState("idle") --When the animation is done, return to the idle state
                end
            end),
        },

        onexit = function(inst)
            inst.SoundEmitter:KillSound("flute") --kill the flute sound
            if inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) then
                inst.AnimState:Show("ARM_carry")
                inst.AnimState:Hide("ARM_normal")
            end
        end,
    })

  AddStategraphPostInit("wilson", function(sg)
    local _PLAY = sg.actionhandlers[ACTIONS.PLAY].deststate --Save the original function determining the state for the PLAY action
    sg.actionhandlers[ACTIONS.PLAY].deststate = function(inst, act, ...)
        return act.invobject ~= nil --Make sure the object responsible for the action exists, unlikely to happen, but if it does happen, the game would crash! So this check is important
            and    (act.invobject:HasTag("rain_shell") and "play_shell") --If the object has the "rain_shell" tag, then the play_shell state will play
            or _PLAY(inst, act, ...) --If all checks fail, go back to the original vanilla function
    end
end)

 

 

client_log.txt

  • Like 1
Link to comment
Share on other sites

2 minutes ago, thegreatJash said:

RegisterInventoryItemAtlas("images/rainshell.xml", "rainshell").

RegisterInventoryItemAtlas("images/rainshell.xml", "rainshell.tex")

Should hopefully work.
 

2 minutes ago, thegreatJash said:

Also the game still crashes even after I put local x = GLOBAL.x at the beggining of the code.

Sorry. I didn't literally mean local x = GLOBAL.x. I used x as an example. In this case ACTIONS needs to be global, so you'll do local ACTIONS = GLOBAL.ACTIONS

  • Like 1
Link to comment
Share on other sites

48 minutes ago, Hornete said:

RegisterInventoryItemAtlas("images/rainshell.xml", "rainshell.tex")

Should hopefully work.
 

Sorry. I didn't literally mean local x = GLOBAL.x. I used x as an example. In this case ACTIONS needs to be global, so you'll do local ACTIONS = GLOBAL.ACTIONS

The minisign code still doesn't work. Does that code belong in the rainshell prefab or the modmain.lua? Only thing I could think of. Thanks in advance.

There was a crash. Let me guess. I need a GLOBAL in front of EQUIPSLOTS. I fixed it all by myself. Aren't you proud of me?

Edited by thegreatJash
  • Like 1
Link to comment
Share on other sites

31 minutes ago, thegreatJash said:

Let me guess. I need a GLOBAL in front of EQUIPSLOTS.

Correct!
 

31 minutes ago, thegreatJash said:

Also, the minisign code still doesn't work. Does that code belong in the rainshell prefab or the modmain.lua? Only thing I could think of. Thanks in advance.

Can you draw the shell on a minisign and then run this command, and tell me what prints out in the console log, thanks.

local sign = c_findnext("minisign") 
print(sign.components.drawable:GetImage()) 
print(sign.components.drawable:GetAtlas()) 
print(GetInventoryItemAtlas("rainshell.tex")) 

 

  • Like 1
Link to comment
Share on other sites

17 minutes ago, Hornete said:

Correct!
 

Can you draw the shell on a minisign and then run this command, and tell me what prints out in the console log, thanks.


local sign = c_findnext("minisign") 
print(sign.components.drawable:GetImage()) 
print(sign.components.drawable:GetAtlas()) 
print(GetInventoryItemAtlas("rainshell.tex")) 

 

Sure can. Here is what I got.

[00:07:06]: Finding a     minisign    
[00:07:06]: Found 114364 (1/16)    
[00:07:06]: rainshell    
[00:07:06]: images/rainshell.xml    
[00:07:06]: images/rainshell.xml

Hope it helps.

  • Like 1
Link to comment
Share on other sites

4 minutes ago, thegreatJash said:

Sure can. Here is what I got.

[00:07:06]: Finding a     minisign    
[00:07:06]: Found 114364 (1/16)    
[00:07:06]: rainshell    
[00:07:06]: images/rainshell.xml    
[00:07:06]: images/rainshell.xml

Hope it helps.

Oh my God, I know what the issue is, I can't believe I forgot about it.

So, the minisign is setting the image correctly, however, we have to load the asset again in another way.

You need to add this to your assets table

Asset("ATLAS_BUILD", "images/rainshell.xml", 256),

To explain it simple, it loads the image as an "ATLAS_BUILD" which allows it to be added to animated objects(like the minisign) to be used.

man how did I forget about this step....

  • Sanity 1
Link to comment
Share on other sites

18 minutes ago, Hornete said:

Oh my God, I know what the issue is, I can't believe I forgot about it.

So, the minisign is setting the image correctly, however, we have to load the asset again in another way.

You need to add this to your assets table


Asset("ATLAS_BUILD", "images/rainshell.xml", 256),

To explain it simple, it loads the image as an "ATLAS_BUILD" which allows it to be added to animated objects(like the minisign) to be used.

man how did I forget about this step....

Lol I knew I remember reading something about this on an old bug post. Thought it was outdated. I'll have to wait to try this out tommorow. Probably won't be able to sleep. Thanks.

  • Like 1
Link to comment
Share on other sites

21 hours ago, Hornete said:

Oh my God, I know what the issue is, I can't believe I forgot about it.

So, the minisign is setting the image correctly, however, we have to load the asset again in another way.

You need to add this to your assets table


Asset("ATLAS_BUILD", "images/rainshell.xml", 256),

To explain it simple, it loads the image as an "ATLAS_BUILD" which allows it to be added to animated objects(like the minisign) to be used.

man how did I forget about this step....

Ok. When I put that line of code in, it crashed. Said something about a bracket??

Also, a have a couple questions regarding the animation code. The horn animation plays without crashing, which is great and all, but the shell is invisible. I assume the "rain_shell" in (  inst.AnimState:OverrideSymbol("horn01", "rain_shell", "shell") --We are overriding the "pan_flute01" symbol with the "shell") is the folder and then the "shell" is the image name. Right now I have an image named "shell-0" in there but we don't seem to mention it here. Also all of this is in the exported folder. The image this code reads, does it need to be in a .scml project and then exported or can it just be a basic PNG? 

Thanks in advance.

client_log.txt

  • Like 1
Link to comment
Share on other sites

3 minutes ago, thegreatJash said:

Ok. When I put that line of code in, it crashed. Said something about a bracket??

Ah, I believe you missed a comma, In Lua after every "item" you put in a table you need to have a comma to tell the computer "Hey, i'm putting another thing in this table now" Like-so

local example_tab = {
	"example1",
	"example2",
	"example3",
}

If you don't have a comma (like-so)

local example_tab = {
	"example1",
	"example2" --missing comma
	"example3",
}

The computer will think "Well, there's no comma here, so that means this is the end of the table, however there's no ending bracket"

That's likely what's wrong, So make sure to check there's a comma after every instance of "Asset("BLAHBLAH, "blahbalh/blahblah")" in the Assets.

5 minutes ago, thegreatJash said:

Also, a have a couple questions regarding the animation code. The horn animation plays without crashing, which is great and all, but the shell is invisible. I assume the "rain_shell" in (  inst.AnimState:OverrideSymbol("horn01", "rain_shell", "shell") --We are overriding the "pan_flute01" symbol with the "shell") is the folder and then the "shell" is the image name. Right now I have an image named "shell-0" in there but we don't seem to mention it here. Also all of this is in the exported folder. The image this code reads, does it need to be in a .scml project and then exported or can it just be a basic PNG? 

Yes! "rain_shell" is the name of the folder(aka the name of the build). But "shell" is the symbol name, which is the folder you made with the image inside of it. A symbol is just a collection of images.

So what went wrong here is the horn playing animation needs the sprite in the symbol labelled as 1 as seen here in the horn filesimage.png.82655ba72443533c7619de5e92caf236.png

However, your symbol only have the "0th"(who starts counting from 0, Im going to beat up the programmer that decided computers should start counting from 0) but the animation needs the "1st" sprite. So to fix this, simply make another image in the "shell" folder named "shell-1" and put the sprite you'd like in there. Once you did that, go in spriter, make a random "placeholder" animation and drag and drop the shell-1 image in there. You aren't going to use this animation, you just need to do this step so the shell-1 image is actually loaded in spriter.

Once you're done that, recompile your animations, go in-game, test and it should hopefully work! The shell sprite will probably look very weird in the animation(It'll probably appear way off where it should be) This is fine! Just tweak the pivot point of the image, recompile, see if it looks good, if not repeat.

To edit the pivot point, go into spriter, go to the image in the top right and double-click, and you'll be able to adjust the pivot point like that!
2112180277_GIF6-15-20216-35-35PM.gif.8ea247fd877f2c108d365b085d45c479.gif

I think I'd suggest to copy the horn-1 image and it's pivot  point so you can get it right the first time. So here's the image, and it's pivot points are...
x: "0.135831"
y: "0.167426"
 horn01-1.png.2586fe49764a71831a01574805ac9565.png

  • Thanks 1
Link to comment
Share on other sites

1 minute ago, Hornete said:

That's likely what's wrong, So make sure to check there's a comma after every instance of "Asset("BLAHBLAH, "blahbalh/blahblah")" in the Assets.

Um ok. Here's my code. Can't find anything wrong.

Assets = {
    Asset("IMAGE", "images/rainshell.tex"),
    Asset("ATLAS", "images/rainshell.xml"),
    Asset("ANIM", "anim/rain_shell.zip")
    Asset("ATLAS_BUILD", "images/rainshell.xml", 256),
}

  • Like 1
Link to comment
Share on other sites

1 minute ago, thegreatJash said:

Um ok. Here's my code. Can't find anything wrong.

Assets = {
    Asset("IMAGE", "images/rainshell.tex"),
    Asset("ATLAS", "images/rainshell.xml"),
    Asset("ANIM", "anim/rain_shell.zip")
    Asset("ATLAS_BUILD", "images/rainshell.xml", 256),
}

image.png.8cdfd27619810587eb616c5670335557.png

Missing comma is there at the end of the highlighted text. :p

  • Like 1
Link to comment
Share on other sites

22 minutes ago, Hornete said:

image.png.8cdfd27619810587eb616c5670335557.png

Missing comma is there at the end of the highlighted text. :p

Ohh boy, You set me up with that post telling to put that there. You intentionally left the comma out knowing this owuld happen.

All jokes aside, I will play around with the play animation. Thanks.

25 minutes ago, Hornete said:

image.png.8cdfd27619810587eb616c5670335557.png

Missing comma is there at the end of the highlighted text. :p

Ohhhh my goood. The minisign still doesn't work. Here's the code. Also the play animation works. Thanks.

RegisterInventoryItemAtlas("images/rainshell.xml", "rainshell.tex")

Assets = {
    Asset("IMAGE", "images/rainshell.tex"),
    Asset("ATLAS", "images/rainshell.xml"),
    Asset("ANIM", "anim/rain_shell.zip"),
    Asset("ATLAS_BUILD", "images/rainshell.xml", 256),
}

Edited by thegreatJash
  • Like 1
Link to comment
Share on other sites

28 minutes ago, thegreatJash said:

Ohhhh my goood. The minisign still doesn't work. Here's the code. Also the play animation works. Thanks.

RegisterInventoryItemAtlas("images/rainshell.xml", "rainshell.tex")

Assets = {
    Asset("IMAGE", "images/rainshell.tex"),
    Asset("ATLAS", "images/rainshell.xml"),
    Asset("ANIM", "anim/rain_shell.zip"),
    Asset("ATLAS_BUILD", "images/rainshell.xml", 256),
}

give me the mod files, I'm going to make this shriveled code work.

Edited by Hornete
  • Wavey 1
Link to comment
Share on other sites

26 minutes ago, thegreatJash said:

Welp, I finally bloody figured it out.
image.png.65c3cebacfb6263cdbac4a6ba670d54f.png

Change this line in rainshell.lua

inst.components.inventoryitem.atlasname = "images/rainshell.xml"

to

inst.components.inventoryitem.atlasname = resolvefilepath("images/rainshell.xml")

what this does is it make sure it finds the correct file path for the atlas.

finally, i am a free man.

 

  • Like 1
  • GL Happy 1
Link to comment
Share on other sites

1 hour ago, Hornete said:

Welp, I finally bloody figured it out.
image.png.65c3cebacfb6263cdbac4a6ba670d54f.png

Change this line in rainshell.lua


inst.components.inventoryitem.atlasname = "images/rainshell.xml"

to


inst.components.inventoryitem.atlasname = resolvefilepath("images/rainshell.xml")

what this does is it make sure it finds the correct file path for the atlas.

finally, i am a free man.

 

image.png.4a2a9af4efc2b37a5000dc88c8b2a428.png

I'll come back when is this done and the animation is where I want it to be.

  • Health 1
Link to comment
Share on other sites

On 6/15/2021 at 8:08 PM, Hornete said:

Welp, I finally bloody figured it out.
image.png.65c3cebacfb6263cdbac4a6ba670d54f.png

Change this line in rainshell.lua


inst.components.inventoryitem.atlasname = "images/rainshell.xml"

to


inst.components.inventoryitem.atlasname = resolvefilepath("images/rainshell.xml")

what this does is it make sure it finds the correct file path for the atlas.

finally, i am a free man.

 

Ok. I am back. The animation is good and the minisign works. Inner peace. Now the final thing I want it to do is to make it have little bop animation when walking close to it and able to "hit" it when on the ground to change through the three sounds. Exactly like the regular shell bells. Is there such things are variables in .lua to keep track of the sound so that it can access it when nessecary?

Thanks in advance.

Edit: lol I don't know what happened but all of a sudden my animation is wonked up. I can't figure out how to fix it. Originally it worked fin the first time. I've have been trying for a straight hour now. Maybe you can line the shell up right? Here are files if you want. I deleted the play animation in the .scml file so you can try it for yourself.

Also another edit: I deleted the "placeholder" animation in the .scml file but the play animation still shows up in game. It's kinda creeping me out. Why is it doing this?

shell-1.png

rain_shell.scml

Edited by thegreatJash
  • Like 1
Link to comment
Share on other sites

1 hour ago, thegreatJash said:

Edit: lol I don't know what happened but all of a sudden my animation is wonked up. I can't figure out how to fix it. Originally it worked fin the first time. I've have been trying for a straight hour now. Maybe you can line the shell up right? Here are files if you want. I deleted the play animation in the .scml file so you can try it for yourself.

Also another edit: I deleted the "placeholder" animation in the .scml file but the play animation still shows up in game. It's kinda creeping me out. Why is it doing this?

Did you recompile your things? If not, and it's still happening, it's likely there's an error when recompiling, the error will usually pop up in the window, click in the window to pause it if you see the error, and let me know what it says
 

1 hour ago, thegreatJash said:

Ok. I am back. The animation is good and the minisign works. Inner peace. Now the final thing I want it to do is to make it have little bop animation when walking close to it and able to "hit" it when on the ground to change through the three sounds. Exactly like the regular shell bells. Is there such things are variables in .lua to keep track of the sound so that it can access it when nessecary?

Thanks in advance.

inst:AddComponent("cyclable")
inst.components.cyclable:SetOnCycleFn(OnCycle)
inst.components.cyclable:SetNumSteps(12)
inst.components.cyclable:SetStep(math.random(inst.components.cyclable.num_steps), nil, true)

Looking at singingshell.lua, this seems to be what allows the shells to be cycleable. So you'll want to do the same thing here, but instead change the 12 in "SetNumSteps" to 3 since you'll only have 3 cycles, for the 3 sounds. And then you'll need to define these functions.

local function PlaySound(inst, doer)
	inst.SoundEmitter:PlaySound("hookline_2/characters/hermit/plugged_fissure/"..inst.components.cyclable.step) --Attach the current cycled step to this string to determine which of the 3 sounds to play

	inst.AnimState:PlayAnimation("music") --You need to make your own animation here!

    local x,y,z = inst.Transform:GetWorldPosition() --Just for tending to crops like the regular shells
    for _, v in pairs(TheSim:FindEntities(x, y, z, TUNING.SINGINGSHELL_FARM_PLANT_INTERACT_RANGE, PLANT_TAGS)) do
		if v.components.farmplanttendable ~= nil then
			v.components.farmplanttendable:TendTo(doer)
		end
	end
end

local function OnCycle(inst, step, doer)
	PlaySound(inst, doer)
end



To make the shell play when being walked nearby, you'll also need to add this line in your shells file in the place where you add the components.

-- Called from singingshelltrigger
inst._activatefn = PlaySound



And it'll hopefully work! One last thing, you'll now need to make your own animation so your shell can do the lil "bop". Create a new animation in your spriter file named "music", and well, make your animation now! A powerful tool you'll be able to use in spriter is something called "tweening", tweening is when the software just fills in the animation for you. For example here I created a quick little animation, where I clicked the 130th frame(or somewhere around there) and changed the sprite a little bit by squishing it, which created a new keyframe, Spriter then automatically filled in the frames between the first frame and the new keyframe we created and that created this lil animation! Of course, this animation is pretty crappy, so be sure to experiment around and get it right. I hope that helps

 1787031521_GIF6-16-20219-41-45PM.thumb.gif.963b9f143d94846a9eb0895d19731375.gif

  • Like 1
  • GL Happy 1
Link to comment
Share on other sites

22 minutes ago, Hornete said:

Did you recompile your things? If not, and it's still happening, it's likely there's an error when recompiling, the error will usually pop up in the window, click in the window to pause it if you see the error, and let me know what it says
 


inst:AddComponent("cyclable")
inst.components.cyclable:SetOnCycleFn(OnCycle)
inst.components.cyclable:SetNumSteps(12)
inst.components.cyclable:SetStep(math.random(inst.components.cyclable.num_steps), nil, true)

Looking at singingshell.lua, this seems to be what allows the shells to be cycleable. So you'll want to do the same thing here, but instead change the 12 in "SetNumSteps" to 3 since you'll only have 3 cycles, for the 3 sounds. And then you'll need to define these functions.


local function PlaySound(inst, doer)
	inst.SoundEmitter:PlaySound("hookline_2/characters/hermit/plugged_fissure/"..inst.components.cyclable.step) --Attach the current cycled step to this string to determine which of the 3 sounds to play

	inst.AnimState:PlayAnimation("music") --You need to make your own animation here!

    local x,y,z = inst.Transform:GetWorldPosition() --Just for tending to crops like the regular shells
    for _, v in pairs(TheSim:FindEntities(x, y, z, TUNING.SINGINGSHELL_FARM_PLANT_INTERACT_RANGE, PLANT_TAGS)) do
		if v.components.farmplanttendable ~= nil then
			v.components.farmplanttendable:TendTo(doer)
		end
	end
end

local function OnCycle(inst, step, doer)
	PlaySound(inst, doer)
end



To make the shell play when being walked nearby, you'll also need to add this line in your shells file in the place where you add the components.


-- Called from singingshelltrigger
inst._activatefn = PlaySound



And it'll hopefully work! One last thing, you'll now need to make your own animation so your shell can do the lil "bop". Create a new animation in your spriter file named "music", and well, make your animation now! A powerful tool you'll be able to use in spriter is something called "tweening", tweening is when the software just fills in the animation for you. For example here I created a quick little animation, where I clicked the 130th frame(or somewhere around there) and changed the sprite a little bit by squishing it, which created a new keyframe, Spriter then automatically filled in the frames between the first frame and the new keyframe we created and that created this lil animation! Of course, this animation is pretty crappy, so be sure to experiment around and get it right. I hope that helps

 1787031521_GIF6-16-20219-41-45PM.thumb.gif.963b9f143d94846a9eb0895d19731375.gif

Thanks. So this code will allow it me hit the shell to cycle between sounds? Also I'll see if there is an error with the recompiling.

  • Big Ups 1
Link to comment
Share on other sites

11 hours ago, thegreatJash said:

inst.SoundEmitter:PlaySound("hookline_2/characters/hermit/plugged_fissure/"..inst.components.cyclable.step)

So wait am I supposed to put something in here? Or were you just explaining what this line does? 

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