TerriFried

  • Content Count

    30
  • Joined

  • Last visited

Community Reputation

3 Neutral

About TerriFried

  • Rank
    Junior Member
...

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Enable
  1. I have a character that used to work perfectly fine, but as of recently the game crashes whenever I spawn or craft a couple items that share some code with the shield of terror. I am wondering if there is any change to the shield of terror that may be causing this crash, or otherwise some other reason that I have not noticed. I have attached the character mod as well as the scripts for the two individual items. All help is greatly appreciated! tfmmw.lua lmw.lua WerriTerri (2).zip
  2. I am trying to make a mod where every time the character plays an item similar to the pan flute, they get struck by lightning. unfortunately, every attempt I have made to make this happen has either resulted in the game not starting the server, or the game crashing after doing the pan flute animation. I have code that should cause the player to get struck by lightning: inst.components.playerlightningtarget:DoStrike() And I have this for hopefully ignoring the players insolation and lack of moisture (Huge credit to @CarlZalph for help with this code) local ForceStrikeOn = function(inst) if inst.components.health and not (inst.components.health:IsDead() or inst.components.health:IsInvincible()) then local x, y, z = inst.Transform:GetWorldPosition() SpawnPrefab("lightning").Transform:SetPosition(x, y, z) local mult = TUNING.ELECTRIC_WET_DAMAGE_MULT * (inst.components.moisture and inst.components.moisture:GetMoisturePercent() or 0) local damage = TUNING.LIGHTNING_DAMAGE + mult * TUNING.LIGHTNING_DAMAGE inst.components.health:DoDelta(-damage, false, "lightning") if not inst.sg:HasStateTag("dead") then inst.sg:GoToState("electrocute") end end end Here is the code for the item basically straight from the pan flute code. I would assume that I would place this code under local function HearPanFlute(inst, musician, instrument), but I have no idea why it refuses to work. local assets = { Asset("ANIM", "anim/sigjam.zip"), Asset("ATLAS", "images/inventoryimages/sigjam.xml"), Asset("IMAGE", "images/inventoryimages/sigjam.tex"), } local function HearPanFlute(inst, musician, instrument) if inst ~= musician and (TheNet:GetPVPEnabled() or not inst:HasTag("player")) and not (inst.components.freezable ~= nil and inst.components.freezable:IsFrozen()) and not (inst.components.pinnable ~= nil and inst.components.pinnable:IsStuck()) and not (inst.components.fossilizable ~= nil and inst.components.fossilizable:IsFossilized()) then local mount = inst.components.rider ~= nil and inst.components.rider:GetMount() or nil if mount ~= nil then mount:PushEvent("ridersleep", { sleepiness = 10, sleeptime = TUNING.PANFLUTE_SLEEPTIME }) end if inst.components.sleeper ~= nil then inst.components.sleeper:AddSleepiness(10, TUNING.PANFLUTE_SLEEPTIME) elseif inst.components.grogginess ~= nil then inst.components.grogginess:AddGrogginess(10, TUNING.PANFLUTE_SLEEPTIME) else inst:PushEvent("knockedout") end end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst:AddTag("sigjam") inst.AnimState:SetBank("pan_flute") inst.AnimState:SetBuild("sigjam") inst.AnimState:PlayAnimation("idle") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/sigjam.xml" inst.components.inventoryitem.cangoincontainer = true inst.components.inventoryitem.onputininventoryfn = function(inst, player) local owner = inst.components.inventoryitem:GetGrandOwner() if owner.components.inventory and owner.prefab ~= "absynth" then inst:DoTaskInTime(0.1, function() player.components.inventory:DropItem(inst) player.components.talker:Say("I guess only holograms can use this?") end) end end --tool (from tool component) added to pristine state for optimization inst:AddTag("tool") MakeInventoryFloatable(inst, "small", 0.05, 0.8) inst.AnimState:AddOverrideBuild("sigjam") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("instrument") inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE inst.components.instrument:SetOnHeardFn(HearPanFlute) inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.PLAY) inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "sigjam" inst.components.inventoryitem.atlasname = "images/inventoryimages/sigjam.xml" MakeHauntableLaunch(inst) inst:ListenForEvent("floater_startfloating", function(inst) inst.AnimState:PlayAnimation("float") end) inst:ListenForEvent("floater_stopfloating", function(inst) inst.AnimState:PlayAnimation("idle") end) return inst end return Prefab("common/inventory/sigjam", fn, assets) I will attach the .lua file, and any help or explanation would be incredibly appreciated! sigjam.lua
  3. @CarlZalph Every attempt to incorporate the code into the local function HearPanFlute(inst, musician, instrument) section has either resulted in the server not running, or the server crashing when I attempt to play the pan flute. Like I said, I have minimal coding knowledge, but do you know how and where I would put the code you so generously gave me? Happy Holidays btw! local assets = { Asset("ANIM", "anim/sigjam.zip"), Asset("ATLAS", "images/inventoryimages/sigjam.xml"), Asset("IMAGE", "images/inventoryimages/sigjam.tex"), } local function HearPanFlute(inst, musician, instrument) if inst ~= musician and (TheNet:GetPVPEnabled() or not inst:HasTag("player")) and not (inst.components.freezable ~= nil and inst.components.freezable:IsFrozen()) and not (inst.components.pinnable ~= nil and inst.components.pinnable:IsStuck()) and not (inst.components.fossilizable ~= nil and inst.components.fossilizable:IsFossilized()) then local mount = inst.components.rider ~= nil and inst.components.rider:GetMount() or nil if mount ~= nil then mount:PushEvent("ridersleep", { sleepiness = 10, sleeptime = TUNING.PANFLUTE_SLEEPTIME }) end if inst ~= musician then local ForceStrikeOn = function(inst) if inst.components.health and not (inst.components.health:IsDead() or inst.components.health:IsInvincible()) then local x, y, z = inst.Transform:GetWorldPosition() SpawnPrefab("lightning").Transform:SetPosition(x, y, z) local mult = TUNING.ELECTRIC_WET_DAMAGE_MULT * (inst.components.moisture and inst.components.moisture:GetMoisturePercent() or 0) local damage = TUNING.LIGHTNING_DAMAGE + mult * TUNING.LIGHTNING_DAMAGE inst.components.health:DoDelta(-damage, false, "lightning") if not inst.sg:HasStateTag("dead") then inst.sg:GoToState("electrocute") end end end if inst.components.sleeper ~= nil then inst.components.sleeper:AddSleepiness(10, TUNING.PANFLUTE_SLEEPTIME) elseif inst.components.grogginess ~= nil then inst.components.grogginess:AddGrogginess(10, TUNING.PANFLUTE_SLEEPTIME) else inst:PushEvent("knockedout") end end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst:AddTag("sigjam") inst.AnimState:SetBank("pan_flute") inst.AnimState:SetBuild("sigjam") inst.AnimState:PlayAnimation("idle") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/sigjam.xml" inst.components.inventoryitem.cangoincontainer = true inst.components.inventoryitem.onputininventoryfn = function(inst, player) local owner = inst.components.inventoryitem:GetGrandOwner() if owner.components.inventory and owner.prefab ~= "absynth" then inst:DoTaskInTime(0.1, function() player.components.inventory:DropItem(inst) player.components.talker:Say("I guess only holograms can use this?") end) end end --tool (from tool component) added to pristine state for optimization inst:AddTag("tool") MakeInventoryFloatable(inst, "small", 0.05, 0.8) inst.AnimState:AddOverrideBuild("sigjam") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("instrument") inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE inst.components.instrument:SetOnHeardFn(HearPanFlute) inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.PLAY) inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "sigjam" inst.components.inventoryitem.atlasname = "images/inventoryimages/sigjam.xml" MakeHauntableLaunch(inst) inst:ListenForEvent("floater_startfloating", function(inst) inst.AnimState:PlayAnimation("float") end) inst:ListenForEvent("floater_stopfloating", function(inst) inst.AnimState:PlayAnimation("idle") end) return inst end return Prefab("common/inventory/sigjam", fn, assets) sigjam.lua
  4. @CarlZalph How would I incorporate the lightning code into the action of playing the music? I have the .lua here for reference sigjam.lua
  5. @CarlZalph thank you for the speedy replies! Just a couple more questions: Where do I place your code, and how can I put a set damage? I assume I would just be able to replace the TUNING.LIGHTNING_DAMAGE with a number? Second, how can I get the .scml file for the pan flute, is there something in Dont Starve Mod Tools that can do that? I figured out a solution here, however it does not give me an option to edit the animation, and I can't find the panflute player_[whatever] However I found the player_actions_cowbell.scml which appears to be an even better animation for what I want to do, but doing inst:AddTag("bell") uses the old bell animation (for some reason) even though the .lua for the cowbell uses the same inst??? I dont know how to code it to appear in my players hand! I've been trying to figure this out all day, and need some help! Thanks again!
  6. @CarlZalph Thank you for the help! May I ask whet the code would be to just damage the player? I assume it is an "inst." code, but I have not been able to find it. Thank you in advance!
  7. I want to add an item to my character that acts as a pan flute, but electrocutes the player on use. when I use the code for the pan flute, however, the game just crashes shortly after I get into the world. First of all, how do I get this item into the game, and secondly, how would I electrocute/damage the player on use? I will add the code and a zip file of the character, any help would be greatly appreciated! absynth.zip sigjam.lua
  8. Ok this seems to help quite a bit. I probably will just avoid the lightning strike part all together because of the insulation you mentioned. Do you know how I would just damage and/or electrocute the player then?
  9. I have minimal coding and modding knowledge, and I want to make an item for a modded character I am working on that is like an unlimited use pan flute, but where the character gets struck by lighting on use. First of all, how do I find the code for the pan flute to copy? The command TheWorld:PushEvent("ms_sendlightningstrike", ThePlayer:GetPosition()) appears to do the trick in the in game console, but I don't have the knowledge of if I could or how to incorporate that into the code. Alternatively, is there a way to make it so the character just gets hurt and does the struck by lightning animation on use? That would almost be better. Thanks!