Aurata Posted July 10, 2015 Share Posted July 10, 2015 Hello,First thing, I wanted to let you know that this is a great tutorial! Everything worked perfectly. The only issue I am having is getting my swap image to show up in game and I am unsure why that is. Could you give me some suggestions on how I can fish this problem? Link to comment Share on other sites More sharing options...
Malacath Posted July 10, 2015 Author Share Posted July 10, 2015 @Aurata,not really. There are many small things that could have gone wrong, so check every little detail with the tutorial, folder structure, spelling mistakes, and also check the log file. A common mistake is the following folder structure:mymod\exported\myitem\swap_myitem\swap_myitem\swap_myitem.png There is twice a folder named "swap_myitem" and that has to be like this! If you don't manage after sincerely trying you can upload the mod in a *.zip file and I can take a look. Link to comment Share on other sites More sharing options...
Aurata Posted July 10, 2015 Share Posted July 10, 2015 @Aurata,not really. There are many small things that could have gone wrong, so check every little detail with the tutorial, folder structure, spelling mistakes, and also check the log file. A common mistake is the following folder structure:mymod\exported\myitem\swap_myitem\swap_myitem\swap_myitem.png There is twice a folder named "swap_myitem" and that has to be like this! If you don't manage after sincerely trying you can upload the mod in a *.zip file and I can take a look. Thank you @Malacath! I was able to fix the problem by doing what I explained. I just posted for others who make the same mistake as me. Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 11, 2015 Share Posted July 11, 2015 (edited) @Malacath, I was unable to get the two animations in the same file as of now but I will still keep trying after I am able to get the images to show. Right now I can't get the Eyebone to display. I think it might have something to do with my code but I'm not sure how to fix it. How do I check if an item is equipped because what I have now doesn't seem to work. Here's my code:local dir = inst.AnimState:GetCurrentFacing()if (inst.components.equippable:IsEquipped()) then if (dir == 1) then inst.AnimState:OverrideSymbol("swap_object", "swap_chester_eyebone_backward", "swap_chester_eyebone_backward") else inst.AnimState:OverrideSymbol("swap_object", "swap_chester_eyebone_forward", "swap_chester_eyebone_forward") endend Edited July 11, 2015 by BaconAndRibs Link to comment Share on other sites More sharing options...
Malacath Posted July 11, 2015 Author Share Posted July 11, 2015 @BaconAndRibs, it doesn't work because you are accessing the same entity all the time. In your code there is only one inst, and I assume that that is the weapon since you (presumably) don't crash on inst.components.equippable:IsEquipped(). So instead you want to get the ownerlocal owner = inst.components.inventoryitem.ownerAnd access the AnimState of this guy. Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 11, 2015 Share Posted July 11, 2015 @Malacath, Aaaahhhh, so I had to change it to owner instead of inst. Thank you. I can now get it to show the seperate image when I equip it facing that direction but how do I change the image if the the player has already equipped it and just changes direction. Do I have to have an event listener to check if the player changes the direction while still having it equipped? This is the code that makes it show properly when I equip it facing up otherwise it shows the other image:local function onequip(inst, owner) local dir = owner.AnimState:GetCurrentFacing() -- local owner = inst.components.inventoryitem.owner if (owner) then if (dir == 1) then owner.AnimState:OverrideSymbol("swap_object", "swap_chester_eyebone_backward", "swap_chester_eyebone_backward") else owner.AnimState:OverrideSymbol("swap_object", "swap_chester_eyebone_forward", "swap_chester_eyebone_forward") end end owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal")endHere is the mod so far if you want to test it to see if I need to change something somewhere.Attack of the Chester.zip Link to comment Share on other sites More sharing options...
ZupaleX Posted July 12, 2015 Share Posted July 12, 2015 HelloGreat tutorial but you should definitlly add that to actually move the pivot, you have to right click on it and then click "overwrite". Otherwise it is not taken into account. Link to comment Share on other sites More sharing options...
Malacath Posted July 13, 2015 Author Share Posted July 13, 2015 @BaconAndRibs, the only thing I can think about is modifying the player stategraph or doing a periodic task to check every frame. But I don't really have the time to try it myself. If you try it with a task then don't forget to cancel the task.-- In OnEquipinst.task = inst:DoPeriodicTask(0, UpdateAnim)-- In OnUnEquipinst.task:Cancel()isnt.task = nilAnd function UpdateAnim will check the facing and change the animation accordingly. It's easy but really suboptimal. @ZupaleX, that's only if you want to ovveride the default pivot, which is not necessary if you want to make just a weapon. If you want to do an armor or helmet then you need to do it. Link to comment Share on other sites More sharing options...
ZupaleX Posted July 13, 2015 Share Posted July 13, 2015 But when I was not doing it, then the item was floating away from the hand of my character as if the pivot was on the top left corner of the picture. I had to move it and overwrite it for the item to be displayed at the proper place.So I am confused now. Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 13, 2015 Share Posted July 13, 2015 (edited) @Malacath, Thank you, I had to change the UpdateAnim to this:inst.task = inst:DoPeriodicTask(0, function() local dir = owner.AnimState:GetCurrentFacing() if (dir == 1) then owner.AnimState:OverrideSymbol("swap_object", "swap_chester_eyebone_backward", "swap_chester_eyebone_backward") else owner.AnimState:OverrideSymbol("swap_object", "swap_chester_eyebone_forward", "swap_chester_eyebone_forward") endend)But after a bit of changes it works! I was thinking though, would using an event listener for the change in the direction be more efficient than checking every frame to see if it changed or is the periodic task method better? @ZupaleX, You do have to overwrite the default pivot in order for the image to show properly in the hand. Otherwise the image floats to the side. Also check that the image is scaled to the right size because if not it will seem really small in the players hand. Edited July 13, 2015 by BaconAndRibs Link to comment Share on other sites More sharing options...
Malacath Posted July 14, 2015 Author Share Posted July 14, 2015 @ZupaleX, I'm confused as well. Never did that and still don't do it. But I will write it in the tutorial to make sure noone has problems. @BaconAndRibs, yes, an EventListener is definitely more efficient. But I don't know if an according even is pushed anywhere in the code, so it's up to you to either find that event or use PostInit's to create it yourself. Link to comment Share on other sites More sharing options...
Gryfuz Posted July 18, 2015 Share Posted July 18, 2015 Alright disregard all my stuff, fixed everything How did you actually fix it? I'm having the same problem :/ The item appears in the inventory and in the ground when dropped, but not when i'm supposed to be holding it. Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 18, 2015 Share Posted July 18, 2015 @Gryfuz, Maybe I can help you. Can you upload your folder as it could be many things that might be causing the issue. Link to comment Share on other sites More sharing options...
Gryfuz Posted July 18, 2015 Share Posted July 18, 2015 @Gryfuz, Maybe I can help you. Can you upload your folder as it could be many things that might be causing the issue. Thank you, here it is. I didn't yet any art for the character not even for the Item, cause for now i'm just focusing on the coding and stuff. So don't be astonished of some 'arts' there xDcory_the_desperate_nerd.zip Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 18, 2015 Share Posted July 18, 2015 (edited) I narrowed it down to the folder order as I believe it should be, --exported --lightsaber --swap_lightsaber --swap_lightsaber ->swap_lightsaber.png ->swap_lightsaber.scml Also, in your lightsaber script, you haveowner.AnimState:OverrideSymbol("swap_object", "swap_lightsaber", "lightsaber")but I believe it should beowner.AnimState:OverrideSymbol("swap_object", "swap_lightsaber", "swap_lightsaber")I have tested this and it seemed to have worked. You may have to resize the image in order for it to show proper but it shows up in the players hand. Here is the folder with the fixes:cory_the_desperate_nerd.zip Edited July 18, 2015 by BaconAndRibs Link to comment Share on other sites More sharing options...
Gryfuz Posted July 19, 2015 Share Posted July 19, 2015 (edited) I narrowed it down to the folder order as I believe it should be, --exported --lightsaber --swap_lightsaber --swap_lightsaber ->swap_lightsaber.png ->swap_lightsaber.scml Also, in your lightsaber script, you haveowner.AnimState:OverrideSymbol("swap_object", "swap_lightsaber", "lightsaber")but I believe it should beowner.AnimState:OverrideSymbol("swap_object", "swap_lightsaber", "swap_lightsaber")I have tested this and it seemed to have worked. You may have to resize the image in order for it to show proper but it shows up in the players hand. Here is the folder with the fixes:cory_the_desperate_nerd.zip I tried to make the changes that you described but it didn't work (i've checked I didn't find differences).So i swaped your file with mine since i suppose there are no changes apart from that so, Thank you anyways. I'm sure I'll spot what was wrong. URRRRRRR AWESOME ! EDIT: I'm trying to resize the image in the spriter file, but is not working, I save the file, and i recreates the anim file etc. but in game the weapon stays small as it was :/ Edited July 19, 2015 by Gryfuz Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 19, 2015 Share Posted July 19, 2015 (edited) You must resize the actual image. Resizing it in spriter will not work. Just resize the png in the folder and it will automatically change the size in game.I might also mention that the scml file must be out side the swap_lightsaber folder that has the png in it. That is one of the other changes I made. Edited July 19, 2015 by BaconAndRibs Link to comment Share on other sites More sharing options...
Gryfuz Posted July 19, 2015 Share Posted July 19, 2015 I might also mention that the scml file must be out side the swap_lightsaber folder that has the png in it. That is one of the other changes I made. Yes you refered that before and somehow the problem was there i didn't check but i think that after make change i had to rebuild the anim file, cause the files before were different there when i opened the zip file. Thanks for the type of the image. I tough it would work resizing on spriter cause it worked when i did for the ground_myitem but seems like is not like that. Thank you mate it worked a lot! Btw one last favor if you don't mind x) (sorry). I would like to make my weapon glow at least enough for charlie do not atack (maybe as much as willow's lighter? or lower) I've tried to take some coding of the lighter file and the torch file but i think I didn't inser them well. Do you know how can I do this?One more time thank you ^^One more time sorry x) Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 19, 2015 Share Posted July 19, 2015 (edited) @Gryfuz, I was able to make the lightsaber have a small bit of light as you requested but you could change it around to suit your needs(e.g. bigger amount of light or smaller amount of light). You just have to change the radius or whatever else you want in the lightsaber script. All I had to add was,local function lightOn(inst) inst.Light:Enable(true) inst.Light:SetRadius(2) --[[ This causes it to crash for some reason. Not really sure why though. inst.Light:SetFallOff(1) --]] inst.Light:SetIntensity(.5) inst.Light:SetColour(1,1,1)endlocal function lightOff(inst) inst.Light:Enable(false)endAnd just call those functions in the onequip() and onunequip() functions. I also had to add this in the fn() function.inst.entity:AddLight()inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")inst.AnimState:SetRayTestOnBB(true)Here is the folder with the changes.cory_the_desperate_nerd.zip Edited July 19, 2015 by BaconAndRibs Link to comment Share on other sites More sharing options...
Gryfuz Posted July 20, 2015 Share Posted July 20, 2015 (edited) @Gryfuz, I was able to make the lightsaber have a small bit of light as you requested but you could change it around to suit your needs(e.g. bigger amount of light or smaller amount of light). You just have to change the radius or whatever else you want in the lightsaber script. All I had to add was,local function lightOn(inst) inst.Light:Enable(true) inst.Light:SetRadius(2) --[[ This causes it to crash for some reason. Not really sure why though. inst.Light:SetFallOff(1) --]] inst.Light:SetIntensity(.5) inst.Light:SetColour(1,1,1)endlocal function lightOff(inst) inst.Light:Enable(false)endAnd just call those functions in the onequip() and onunequip() functions. I also had to add this in the fn() function.inst.entity:AddLight()inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")inst.AnimState:SetRayTestOnBB(true)Here is the folder with the changes.cory_the_desperate_nerd.zip Gosh !! Wow man, thank you, I don't know what to say x) you did it all :/ I'm so gratefull, i've been in trouble trying to do it. Thanks !! EDIT1 I think fallout factor was crashing because it's supposed to work in limited items, since my sword doesnt have durability it crashed i guess that's what i understood from herehttp://dontstarveapi.com/utility/light/but since i'm a noob it's just a guess and probably wrong xD Edited July 20, 2015 by Gryfuz Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 20, 2015 Share Posted July 20, 2015 (edited) I believe your right about the fallout factor. I wasn't aware they had an API documentation. I'll have to go through that, might help me out. Thanks! Edited July 20, 2015 by BaconAndRibs 1 Link to comment Share on other sites More sharing options...
Gryfuz Posted July 20, 2015 Share Posted July 20, 2015 I believe your right about the fallout factor. I wasn't aware they had an API documentation. I'll have to go through that, might help me out. Thanks! Btw x) I did my character to lose sanity faster nearby hounds but sometimes the game crashes, just in a specific situation. I have it written more detailed here: (last posts)http://forums.kleientertainment.com/topic/56174-how-to-increase-damage-against-hounds/ if you don't mind to have a look x) I'm struggling cause i don't find the mistake Link to comment Share on other sites More sharing options...
PrinceKawaii Posted July 29, 2015 Share Posted July 29, 2015 I know I'm a little late to this, but something in my mod went wrong. However, everything else seems to be and order and this appears to be somewhat simple issue. As seen in this image: http://i.imgur.com/0t936A8.png the custom item is far off from the hand and actually being held, even though in the Spriter program I made sure to move the pivot point on the handle. (it is still acting as the the movable pivot is in the default location in the top-left)I'm not quite sure how to fix this, I've tried redoing that certain step and manually editing the swap_item.scml file (although the contents of the file confuse me) but the character still grabs onto the top-left. Any suggestions? Here's a link to the mod so far (Sorry, I couldn't figure out how to use the attachment function.) : https://copy.com/FjXyXvtT3z49khZj And all artworks in the screenshot/mod are place-holder and were never really meant to be seen, but I'm out of options here.The sword art is from the "Taronci" mod on the DST workshop. Link to comment Share on other sites More sharing options...
BaconAndRibs Posted July 29, 2015 Share Posted July 29, 2015 @PrinceKawaii, When in Spriter, you must move the pivot point to where you want it. Then right click on it and select "overwrite default pivot", then I think you also right click again and press "use default pivot" but I don't think it's necessary. Link to comment Share on other sites More sharing options...
PrinceKawaii Posted July 30, 2015 Share Posted July 30, 2015 Thank you, that fixed it. Link to comment 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