Hornete Posted June 17, 2021 Share Posted June 17, 2021 7 minutes ago, thegreatJash said: So wait am I supposed to put something in here? Or were you just explaining what this line does? Sorry, yeah I was explaining what that line does. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1469459 Share on other sites More sharing options...
thegreatJash Posted June 17, 2021 Author Share Posted June 17, 2021 (edited) 7 hours ago, Hornete said: Sorry, yeah I was explaining what that line does. Ok. So I put your code in an made a "music" animation with a "play" animation inside of that. I hope that's right. I put that animation in the "rain_shell" folder and it compiled. I ran into this crash though. Honestly, I don't know what's going on with the play animation. I made the play animation, which I named "placeholder", and originally it worked fine, but it didn't look right. Then I tried to edit it, and every time I did it recompiled but never seemed to actually change, which was strange. Then I decided to take a break with that and I removed the "placeholder" animation from the "rain_shell" .scml file, but it remained in the game, which bothered me. Then a completely removed the "shell-1" file but it refused to recompile. It said that "the rain_shell animation couldn't find the shell-1 file", even though I removed the animation that used it in the first place. So, I put it back so the game wouldn't crash looking for an animation that refused to compile and came up with this crash. Thanks in advance. client_log.txt Edited June 17, 2021 by thegreatJash 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1469595 Share on other sites More sharing options...
Hornete Posted June 18, 2021 Share Posted June 18, 2021 1 hour ago, thegreatJash said: Ok. So I put your code in an made a "music" animation with a "play" animation inside of that. I hope that's right. I put that animation in the "rain_shell" folder and it compiled. I ran into this crash though. Honestly, I don't know what's going on with the play animation. I made the play animation, which I named "placeholder", and originally it worked fine, but it didn't look right. Then I tried to edit it, and every time I did it recompiled but never seemed to actually change, which was strange. Then I decided to take a break with that and I removed the "placeholder" animation from the "rain_shell" .scml file, but it remained in the game, which bothered me. Then a completely removed the "shell-1" file but it refused to recompile. It said that "the rain_shell animation couldn't find the shell-1 file", even though I removed the animation that used it in the first place. So, I put it back so the game wouldn't crash looking for an animation that refused to compile and came up with this crash. Thanks in advance. client_log.txt 33.1 kB · 0 downloads Are you sure you defined the "OnCycle" function I gave you earlier? Here it says the variable doesn't exist. How did you try to edit the placeholder animation? You only touched the pivot points correct? Moving the sprite in the animation itself does not change anything. Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1469653 Share on other sites More sharing options...
thegreatJash Posted June 18, 2021 Author Share Posted June 18, 2021 (edited) 1 hour ago, Hornete said: Are you sure you defined the "OnCycle" function I gave you earlier? Here it says the variable doesn't exist. How did you try to edit the placeholder animation? You only touched the pivot points correct? Moving the sprite in the animation itself does not change anything. Ah, I misunderstood what the pivot point meant. I get it now. Also, I moved around the order the code that you gave me was in, and that fixed the OnCycle problem. But when I tried to cycle it, it crashed again, this time with PlaySound or OnSound or something not declared. If just moving around the order of the code fixed one crash, then it's probably the cause for the others. Is there sone sort of order the code should be put in, including the small chunk that makes it do the sound when the player walks near it, because that does the seem to work either. Thanks in advance. Edited June 18, 2021 by thegreatJash 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1469680 Share on other sites More sharing options...
Hornete Posted June 18, 2021 Share Posted June 18, 2021 5 minutes ago, thegreatJash said: Ah, I misunderstood what the pivot point meant. I get it now. Also, I moved around the order the code that you gave me was in, and that fixed the OnCycle problem. But when I tried to cycle it, it crashed again, this time with PlaySound or OnSound or something not declared. If just moving around the order of the code fixed one crash, then it's probably the cause for the others. Is there sone sort of order the code should be put in, including the small chunk that makes it do the sound when the player walks near it, because that does the seem to work either. Thanks in advance. Yes, when a function is called, that function must be defined. For example. local function TestFunction() print("test") end TestFunction() This piece of code will work, because TestFunction is defined and then ran, however. TestFunction() local function TestFunction() print("test") end Will not work, because when the game tries to run TestFunction, the definition for TestFunction hasn't occured yet since it happens later in the code. As a good rule of thumb, place all your functions at the top of your prefab file. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1469684 Share on other sites More sharing options...
thegreatJash Posted June 18, 2021 Author Share Posted June 18, 2021 20 hours ago, Hornete said: Yes, when a function is called, that function must be defined. For example. local function TestFunction() print("test") end TestFunction() This piece of code will work, because TestFunction is defined and then ran, however. TestFunction() local function TestFunction() print("test") end Will not work, because when the game tries to run TestFunction, the definition for TestFunction hasn't occured yet since it happens later in the code. As a good rule of thumb, place all your functions at the top of your prefab file. Ok. I moved the code around and fixed the one crash and got another crash regarding "PLANT_TAGS" or something like that. Dunno what that's about. I ripped the farm code out and I was able to cycle it without problems. However my "music" animation doesn't seem to work and instead makes the shell invisible, thus making it impossible to cycle it again. I loaded it in and have the "music.zip" file in the "anim" folder. Maybe you could take a look and see what's wrong? Is it in the wrong folder? It currently has the "rain_shell" folder as its root. Thanks in advance. client_log.txt music.scml Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470112 Share on other sites More sharing options...
Hornete Posted June 18, 2021 Share Posted June 18, 2021 11 minutes ago, thegreatJash said: Ok. I moved the code around and fixed the one crash and got another crash regarding "PLANT_TAGS" or something like that. Oh silly me, Put this line of code before the PlaySound function local PLANT_TAGS = {"tendable_farmplant"} 12 minutes ago, thegreatJash said: Dunno what that's about. I ripped the farm code out and I was able to cycle it without problems. However my "music" animation doesn't seem to work and instead makes the shell invisible, thus making it impossible to cycle it again. I loaded it in and have the "music.zip" file in the "anim" folder. Maybe you could take a look and see what's wrong? Is it in the wrong folder? It currently has the "rain_shell" folder as its root. Thanks in advance. You shouldn't be creating a new project for the one animation, it should be in the "rain_shell.scml" file along with your idle animation. Like-so. If you don't know how to create a new animation, you can click the third button here 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470129 Share on other sites More sharing options...
thegreatJash Posted June 18, 2021 Author Share Posted June 18, 2021 54 minutes ago, Hornete said: Oh silly me, Put this line of code before the PlaySound function local PLANT_TAGS = {"tendable_farmplant"} You shouldn't be creating a new project for the one animation, it should be in the "rain_shell.scml" file along with your idle animation. Like-so. If you don't know how to create a new animation, you can click the third button here Like this? local function PlaySound(inst, doer) local PLANT_TAGS = {"tendable_farmplant"} 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! end 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470159 Share on other sites More sharing options...
Hornete Posted June 18, 2021 Share Posted June 18, 2021 7 minutes ago, thegreatJash said: Like this? yup! that works. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470163 Share on other sites More sharing options...
thegreatJash Posted June 18, 2021 Author Share Posted June 18, 2021 (edited) 18 minutes ago, Hornete said: yup! that works. Ok cool it tends to crops and plays the animation normally. The only two things left is that it doesn't do the little bop when walking near it, like it should, and I want to play the current cycled sound when playing it to summon rain. Thanks in advance. Edited June 18, 2021 by thegreatJash 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470169 Share on other sites More sharing options...
Hornete Posted June 19, 2021 Share Posted June 19, 2021 1 hour ago, thegreatJash said: I want to play the current cycled sound when playing it to summon rain. timeline = { TimeEvent(30 * FRAMES, function(inst) local cycle = inst.bufferedaction.invobject.components.cyclable.step if inst:PerformBufferedAction() then inst.SoundEmitter:PlaySound("hookline_2/characters/hermit/plugged_fissure/"..cycle) else inst.AnimState:SetTime(94 * FRAMES) end end), }, If you go to your "play_shell" state and replace the timeline variable with this instead, then it should work! 1 hour ago, thegreatJash said: The only two things left is that it doesn't do the little bop when walking near it, like it should, Ah! Looks like I missed a few crucial things. local function RegisterActiveShell(inst) if TheWorld.components.singingshellmanager == nil then TheWorld:AddComponent("singingshellmanager") end TheWorld.components.singingshellmanager:RememberActiveShell(inst) end local function UnregisterActiveShell(inst) if TheWorld.components.singingshellmanager ~= nil then TheWorld.components.singingshellmanager:ForgetActiveShell(inst) end end These functions will need to be defined, and then in the constructor function for the shell you'll need to have inst.components.inventoryitem:SetOnDroppedFn(RegisterActiveShell) inst.components.inventoryitem:SetOnPickupFn(UnregisterActiveShell) inst.OnEntityWake = RegisterActiveShell inst.OnEntitySleep = UnregisterActiveShell (This is so the shell can "activate" and "deactivate" when unloaded/loaded or picked up/dropped, main purpose is for optimisation! I assume atleast) 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470192 Share on other sites More sharing options...
thegreatJash Posted June 19, 2021 Author Share Posted June 19, 2021 3 minutes ago, Hornete said: timeline = { TimeEvent(30 * FRAMES, function(inst) local cycle = inst.bufferedaction.invobject.components.cyclable.step if inst:PerformBufferedAction() then inst.SoundEmitter:PlaySound("hookline_2/characters/hermit/plugged_fissure/"..cycle) else inst.AnimState:SetTime(94 * FRAMES) end end), }, If you go to your "play_shell" state and replace the timeline variable with this instead, then it should work! Ah! Looks like I missed a few crucial things. local function RegisterActiveShell(inst) if TheWorld.components.singingshellmanager == nil then TheWorld:AddComponent("singingshellmanager") end TheWorld.components.singingshellmanager:RememberActiveShell(inst) end local function UnregisterActiveShell(inst) if TheWorld.components.singingshellmanager ~= nil then TheWorld.components.singingshellmanager:ForgetActiveShell(inst) end end These functions will need to be defined, and then in the constructor function for the shell you'll need to have inst.components.inventoryitem:SetOnDroppedFn(RegisterActiveShell) inst.components.inventoryitem:SetOnPickupFn(UnregisterActiveShell) inst.OnEntityWake = RegisterActiveShell inst.OnEntitySleep = UnregisterActiveShell (This is so the shell can "activate" and "deactivate" when unloaded/loaded or picked up/dropped, main purpose is for optimisation! I assume atleast) Thanks! I will have to try this out tommorow. If this code works, then this mod will be finished tommorow. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470195 Share on other sites More sharing options...
thegreatJash Posted June 19, 2021 Author Share Posted June 19, 2021 15 hours ago, Hornete said: (This is so the shell can "activate" and "deactivate" when unloaded/loaded or picked up/dropped, main purpose is for optimisation! I assume atleast) Hello again. I put the code in that you gave me. The piece where the shell plays the current cycled sound works fine, but the one where the shell plays the sound when walking near it does not however. No crashes though! I put the inst. code in the same spots with the inst.component stuff went. Also, how would I make it so the action "cycle" is "hit" in game? It's probably something really simple but I'm afraid to touch anything. As always thanks in advance. Also, here's the rainshell.lua if you need to take a look at it. rainshell.lua Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470404 Share on other sites More sharing options...
Hornete Posted June 19, 2021 Share Posted June 19, 2021 25 minutes ago, thegreatJash said: Hello again. I put the code in that you gave me. The piece where the shell plays the current cycled sound works fine, but the one where the shell plays the sound when walking near it does not however. No crashes though! I put the inst. code in the same spots with the inst.component stuff went. Also, how would I make it so the action "cycle" is "hit" in game? It's probably something really simple but I'm afraid to touch anything. As always thanks in advance. Also, here's the rainshell.lua if you need to take a look at it. rainshell.lua 4.49 kB · 1 download Oh silly me, add the "singingshell" tag and the shell should bop when going near, it'll also make the "Cycle" string "Hit" instead like the other shells! 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470410 Share on other sites More sharing options...
thegreatJash Posted June 19, 2021 Author Share Posted June 19, 2021 33 minutes ago, Hornete said: Oh silly me, add the "singingshell" tag and the shell should bop when going near, it'll also make the "Cycle" string "Hit" instead like the other shells! Ok last question. I swear. It bops when near and has "hit" now, which is great, but it plays the sound and acts as if I walked near whenever I drop it, which is strange. Is there a fix? Also how do I upload a mod to the dst workshop? I know you can use Don't Starve Mod Tools, but is there an easier way? Are there any tutorials? Thanks in advance. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470423 Share on other sites More sharing options...
Hornete Posted June 19, 2021 Share Posted June 19, 2021 6 minutes ago, thegreatJash said: Ok last question. I swear. It bops when near and has "hit" now, which is great, but it plays the sound and acts as if I walked near whenever I drop it, which is strange. Is there a fix? Also how do I upload a mod to the dst workshop? I know you can use Don't Starve Mod Tools, but is there an easier way? Are there any tutorials? Thanks in advance. Alright, this should be the last stuff you need now, I swear. local TRIGGER_MUST_TAGS = { "singingshelltrigger" } local TRIGGER_CANT_TAGS = { "playerghost" } local function PreventImmediateActivate(inst) if inst.entity:IsAwake() then local x, y, z = inst.Transform:GetWorldPosition() for _, v in ipairs(TheSim:FindEntities(x, y, z, TUNING.SINGINGSHELL_TRIGGER_RANGE, TRIGGER_MUST_TAGS, TRIGGER_CANT_TAGS)) do v.components.singingshelltrigger.overlapping[inst] = true end end end -- Prevents shell from immediately playing if spawning within range of a singingshelltrigger(or dropped) inst:DoTaskInTime(0, PreventImmediateActivate) inst:ListenForEvent("exitlimbo", PreventImmediateActivate) 7 minutes ago, thegreatJash said: I know you can use Don't Starve Mod Tools, but is there an easier way? Are there any tutorials? Thanks in advance. The Mod Tools are the only way, it should not be difficult to use though, open it up, select "Don't Starve Together" as the game to upload the mod to, click "Add" and that should bring you to this page. For "Update Data" simply click browse and then select your mod folder, select a preview image for the mod, and put in the details you'd like (These details can be changed later in steam page itself, I usually like to do that since I find it easier to type in the steam page itself). Also, you may want to create a copy of your mod folder and make that the public release version and use that to upload to the workshop, and then remove the "exported" folder and any other png's, since those aren't needed and are just unncessary space taken up, though the game won't blow up if you leave those things in. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470429 Share on other sites More sharing options...
thegreatJash Posted June 20, 2021 Author Share Posted June 20, 2021 22 hours ago, Hornete said: Alright, this should be the last stuff you need now, I swear. local TRIGGER_MUST_TAGS = { "singingshelltrigger" } local TRIGGER_CANT_TAGS = { "playerghost" } local function PreventImmediateActivate(inst) if inst.entity:IsAwake() then local x, y, z = inst.Transform:GetWorldPosition() for _, v in ipairs(TheSim:FindEntities(x, y, z, TUNING.SINGINGSHELL_TRIGGER_RANGE, TRIGGER_MUST_TAGS, TRIGGER_CANT_TAGS)) do v.components.singingshelltrigger.overlapping[inst] = true end end end -- Prevents shell from immediately playing if spawning within range of a singingshelltrigger(or dropped) inst:DoTaskInTime(0, PreventImmediateActivate) inst:ListenForEvent("exitlimbo", PreventImmediateActivate) The Mod Tools are the only way, it should not be difficult to use though, open it up, select "Don't Starve Together" as the game to upload the mod to, click "Add" and that should bring you to this page. For "Update Data" simply click browse and then select your mod folder, select a preview image for the mod, and put in the details you'd like (These details can be changed later in steam page itself, I usually like to do that since I find it easier to type in the steam page itself). Also, you may want to create a copy of your mod folder and make that the public release version and use that to upload to the workshop, and then remove the "exported" folder and any other png's, since those aren't needed and are just unncessary space taken up, though the game won't blow up if you leave those things in. Is there any specific place to put that code? I just tossed in into the rainshell.lua and got a crash. client_log.txt Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470719 Share on other sites More sharing options...
Hornete Posted June 20, 2021 Share Posted June 20, 2021 1 minute ago, thegreatJash said: Is there any specific place to put that code? I just tossed in into the rainshell.lua and got a crash. client_log.txt 38.34 kB · 0 downloads What does your rainshell.lua file look like? 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470722 Share on other sites More sharing options...
thegreatJash Posted June 20, 2021 Author Share Posted June 20, 2021 Just now, Hornete said: What does your rainshell.lua file look like? I put that code along with the other functions? rainshell.lua 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470723 Share on other sites More sharing options...
Hornete Posted June 20, 2021 Share Posted June 20, 2021 1 minute ago, thegreatJash said: I put that code along with the other functions? rainshell.lua 5.06 kB · 0 downloads The highlighted lines should be in the part of the code where the entity is being created(with the components, tags, and such, like so) 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470725 Share on other sites More sharing options...
thegreatJash Posted June 20, 2021 Author Share Posted June 20, 2021 Just now, Hornete said: The highlighted lines should be in the part of the code where the entity is being created(with the components, tags, and such, like so) Lol how am I so stupid. I looked around on the Mods Tools and can't find a way to upload screenshots of the mod in game. Do you have to do that on Steam? 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470726 Share on other sites More sharing options...
thegreatJash Posted June 20, 2021 Author Share Posted June 20, 2021 @Hornete Well, here it is, the final product. https://steamcommunity.com/sharedfiles/filedetails/?id=2522367292&searchtext= I probably annoyed you to high hell with all the questions I constantly bugged you with, but thanks again. I probably couldn't have done this mod without you. If you would like, I could send you a friend request on Steam so we can be friends, so I can add you as an author. Your choice. For now, I am probably going to take a break from modding. I do have a bunch of other cool ideas, so much so that I could probably have a massive mod adding an additional unique drop from each boss, and maybe I'll get good enough at modding to do that. I'm going to probably make a giant see weed Crab King zone to farm him for rainy shell bells. Fill up chests with them. Thanks again. 1 Link to comment https://forums.kleientertainment.com/forums/topic/130466-how-would-i-temporarily-change-the-sprites-for-an-already-existing-sprite/page/4/#findComment-1470735 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now