Monti18

  • Content Count

    420
  • Joined

  • Last visited

Community Reputation

459 Excellent

5 Followers

About Monti18

  • Rank
    Senior Member
...

Recent Profile Visitors

1101 profile views
  1. Try it with this: local function OnAttack(inst,attacker,target) if target and target.components.health then local old_val = target.components.health.currenthealth target.components.health:SetVal(old_val - 20) --replace it with the damage you would like it make target:PushEvent("attacked", { attacker = attacker, damage = 0, weapon = inst }) end end --fn() inst.components.weapon:SetOnAttack(OnAttack) This should set the value of the health directly to one minus the damage of the weapon. Not tested, but I think you can just push the event attacked like the fire and icestaff do to have the target play the stun animation. Not sure about the forcing stunlock each hit, I think if you add stimuli = "stun" to the PushEvent, it will stun every hit. target:PushEvent("attacked", { attacker = attacker, damage = 0, weapon = inst, stimuli = "stun" })
  2. Nice, sorry for not answering sooner, had too much on my plate But good that you were able to get it resolved
  3. No worries, it's always best to try it yourselves, this way you also learn a lot! If you use else, you also need to use if. This is just the way it's used in every programming language (I think) You need the conditional to have your different cases. The song never stopped because you never killed it. To be honest, not sure which volume is the start, I think it's 1. local function ReduceVolume(inst,volume) local new_volume = volume-FRAMES --new volume is old volume - FRAMES ( which is 1/30) inst.SoundEmitter:SetVolume("hungerbuffsong",new_volume) --set the new volume if volume < 0.1 then --if the volume is smaller than 0,1, kill the sound, you can also choose another value, I think with 0.1 it's not heard anymore inst.SoundEmitter:KillSound("hungerbuffsong") else inst:DoTaskInTime(2*FRAMES,ReduceVolume,new_volume) --else redo that in 2 frames, --if you want to have a faster reducing of the volume, change the time to 1 FRAMES or reduce the volume faster end end local function OnWorked(inst, data) if inst.SoundEmitter:PlayingSound("hungerbuffsong") then -- If the sound is still going inst.songkilltask:Cancel() -- Stop our kill task inst.songkilltask = nil else -- otherwise inst.SoundEmitter:PlaySound("soundstudio/hungerbuff/song", "hungerbuffsong") -- Start the sound end inst.songkilltask = inst:DoTaskInTime(3, function() -- Start the kill task ReduceVolume(inst,1) --start the periodic task that reduces the volume each 2 frames, start with volume = 1 end) end This should be working for your case, the volume will get lower after some time. I hope that works for you, if not let me know!
  4. I had a look at my block of code and your current code and didn't get a crash upon using either, so a serverlog would help You should also set inst.songkilltask = nil after using Cancel() on it, I don't think it will be nil after cancelling it. You can check if your current song is playing by running inst.SoundEmitter:PlayingSound("hungerbuffsong") which returns a bool and you can set the volume of a song by running inst.SoundEmitter:SetVolume("hungerbuffsong",volume) to make the fade out part. Just run a task each frame that reduces the volume a bit each time to get a fading out effect when you want it to fade out. I hope that helps and that I understood your problem correctly, if not let me know!
  5. That's good to hear! I think the problem is that you add the ListenForEvent in the function that is listening to the event. local function OnWorked(inst, data) inst.SoundEmitter:PlaySound("soundstudio/hungerbuff/song") end --masterpostinit inst:ListenForEvent("working", OnWorked) It should look more like this in your file. The song should automatically stop to play if the file is finished. If it still doesn't stop, you can do something like this: local function OnWorked(inst, data) inst.SoundEmitter:PlaySound("soundstudio/hungerbuff/song","hungerbuffsong") inst:DoTaskInTime(2,function(inst) --or whatever time you want it to stop inst.SoundEmitter:KillSound("hungerbuffsong") end) end --masterpostinit inst:ListenForEvent("working", OnWorked)
  6. I only did it once and it was some time ago so I'm not sure if this is correct, but you just make your sound file, names are whatever you want. Then you load it under Assets. Let's say this is your folder structure under FMOD: and it's saved under the name structureprefab.fev and structureprefab.fsb in the sound folder. To play the sound event1, you would need to call inst.SoundEmitter:PlaySound("structureprefab/structure/event1") So first the name of the file it's saved under, then the folder in FMOD and then the name of the event. Now to the part where you want to play it when doing work: You can either listen for the event "working" and play the sound or you hook into the corresponding stategraph functions so that they play this sound while digging,hammering,...
  7. inst._light,inst._body and inst._body._lantern are just variables that were saved. You can see them defined in the onequip function of redlantern.lua. inst._body = SpawnPrefab("redlanternbody") inst._body._lantern = inst inst._light is defined in the turnon function. If you want to use this code, you will need to define them in your code like they are defined there. It's probably better for you to start from an exact copy of the file and then change the pictures to those of your item and then do some fine tuning.
  8. You can listen for the event "builditem" instead of "consumeingredients". inst.onitembuild = function(player,data) if data and data.recipe and data.recipe.name == "your_recipe_name" then inst.components.finiteuses:Use(1) end end inst:ListenForEvent("builditem", inst.onitembuild, owner) This should work I think
  9. This is a very good template for making your own swap_animations. The reason why swap_redlantern doesn't have an anim is because it doesn't need one. When equipping a weapon, the swap_object symbol is overwritten with the picture of the item. For this to work, only a picture is needed and not an animation file. That's why only atlas and build.bin are needed, as atlas has the texture and build.bin tells the game the folder structure of the file. You can use any other anim file to decompile it with krane so that you can still see the files and the structure of the folders. I attached the decompiled zip swap_redlantern.zip
  10. This is how you can do it: local FUELTYPE = GLOBAL.FUELTYPE FUELTYPE.YOUR_FUELTYPE = "YOUR_FUELTYPE" --replace YOUR_FUELTYPE with the name of your new fuel AddPrefabPostInit("item", function(inst) --replace item with the item you want to have your new fueltype if not inst.components.fuel then inst:AddComponent("fuel") end inst.components.fuel.fueltype = FUELTYPE.YOUR_FUELTYPE end)
  11. There is no easy way to change it directly. If you add this to the master postinit of your character prefab, it should work:
  12. Ah so you mean rotate around the z-axis right? Unfortunaly I don't know how to do that...
  13. Follow this tutorial You probably don't have the overridesymbol in the onequip and onunequip function declared and didn't set the proper equipslot for the hat. Take a look at the files and you will see how it's done!
  14. AddRecipe2("item", { Ingredient("beefalowool", 4 ), Ingredient("marble", 3), Ingredient("rope", 2)}, TECH.SCIENCE_TWO, {atlas = "images/inventoryimages/item.xml",image = "item.tex", builder_tag = "your_character_tag"}, {"CHARACTER"}) Your character needs to have a tag special to them, replace you_character_tag with it and then it will appear in the character slot
  15. The problem is this snippet of the DoRecipeClick fn: if owner.components.playercontroller ~= nil then local iscontrolsenabled, ishudblocking = owner.components.playercontroller:IsEnabled() if not (iscontrolsenabled or ishudblocking) then --Ignore button click when controls are disabled --but not just because of the HUD blocking input return true end end This will return false, as playercontroller:IsEnabled will return false,nil You could try to hook into the inst.HUD:IsCraftingOpen() function and make it so that your widget returns true if it's there or hook any other function on the way. Edit: A quick fix would be this: