Search the Community
Showing results for tags 'solved!'.
-
I am trying to make a character that gains sanity when around goats and I found a code, and it worked. But I want to increase the sanity gain, yet I can't really understand the codes so I don't know what to change. local function sanityfn(inst) local x, y, z = inst.Transform:GetWorldPosition() local delta = 0 local ents = TheSim:FindEntities(x, y, z, 20, {"lightninggoat"}) for k, v in pairs(ents) do if v ~= inst then local distsq = math.max(inst:GetDistanceSqToInst(v), 1) -- Handle Sanity if distsq < 50 then delta = .2 elseif distsq < 200 then delta = .1 end end end return delta end What I mainly don't know are; delta, distsq and k, v meanings.. Thanks in advance ^^
-
I know this is a repost from last week, but I am getting desperate here. Basically, I changed the weapon and swap_weapon sprites for a handslot item in my Mod, but the sprite appears invisible while eqquiped and on ground. I tried to look for help on other forum posts, but nothing has worked. The item in particular is titled "sanityspear", even though the item "sanitysword" has this problem too (however I think the sword will have the same solution). Please help me with this, as I want to go back to working on updating my mod as fast as possible. I have tried posting this issue on reddit and the Don't Starve forum, but I haven't gotten any help from those forums either. I am willing to get help over a discord call if you want me to, just please dm me via my forum profile about it. Any kind of help would be appreciated.Wayne_The_Experiment-1.2.zip
-
I'm trying to check if is player first spawn for do some things for Client and server. I already can do for Server, but I don't know how to do this for client. I think that when the function is executed by the server, it will not be executed by the client. When Cliente_Side is outslide OnNewSpawn function, is executed every time a player join server. English is not my main language so may have translation erros. My code looks like: local OnPlayerSpawn = function(player) player.prev_OnNewSpawn = player.OnNewSpawn player.OnNewSpawn = function() if SERVER_SIDE then --do Things in server_side end if CLIENT_SIDE then --do Things in client_side end if player.prev_OnNewSpawn ~= nil then player:prev_OnNewSpawn() player.prev_OnNewSpawn = nil end end end local function OnPlayerPostInit(player) OnPlayerSpawn(player) end AddPlayerPostInit(OnPlayerPostInit) This must be something simple, but I'm missing it.
-
Not sure why, but my autocompiler doesn't seem to be able to compile my character's animations (I used the Extended Sample Template), I have tried a bunch of different solutions I found here on the forums (Making sure I have all body parts, making sure everything is named properly, etc.) but for some odd reason I keep getting an error when trying to compile the animations so I can actually see my character in game. I would totally appreciate some help with this.
-
Hello, really really need some help. How do I go about coding a custom item with finite uses? Fueling and perishing works on decay, and health (i think) only works on structures. Basically I have this weapon that I want to be able to be repaired with a moon rock; it shouldn't be destructible and on 0 it shouldn't be usable. Non-craftable as it would be great to just have it be "whetstoned" to good use again when it "dulls". Supposedly it also can chop trees quickly (much like Woody and Lucy chop speed), but would weather the blade quicker. I haven't coded in the speed chopping yet either, i was focusing on the durability thing first. local prefabs = { } local function fn(colour) local function makeobstacle(inst) inst.Physics:SetActive(true) inst._ispathfinding:set(true) end local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_moonRK", "swap_moonRK") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function OnUnequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") end local inst = CreateEntity() inst.entity:AddNetwork() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() MakeInventoryPhysics(inst) anim:SetBank("moonrunekatana") anim:SetBuild("moonrunekatana") anim:PlayAnimation("idle") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("weapon") inst.components.weapon:SetDamage(42.5) inst.components.weapon.attackrange = 0 inst.components.weapon.hitrange = 0 inst:AddComponent("repairable") inst.components.repairable.repairmaterial = "moonrocknugget" inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(150) inst.components.finiteuses:SetUses(150) inst.components.finiteuses:SetConsumption(ACTIONS.CHOP, 4) inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.CHOP, 1) inst:AddTag("sharp") inst:AddTag("pointy") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "moonrunekatana" inst.components.inventoryitem.atlasname = "images/inventoryimages/moonrunekatana.xml" inst:AddComponent("equippable") inst.components.equippable:SetOnEquip( OnEquip ) inst.components.equippable:SetOnUnequip( OnUnequip ) inst:AddComponent("inspectable") MakeHauntableLaunch(inst) return inst end return Prefab("common/inventory/moonrunekatana", fn, assets, prefabs) The weapon already works, components for its effects are in place, but I don't really know how to implement this. I've looked into other game files/mod files and in the game, there isn't really anything that acts like this, and the repair tools mod adds an actions.lua which was too much for me to digest without some help. The way some others do it is by repairing the item with another prerequisite item, adding a component.lua that would trigger the repair? Can anyone lead me in the right direction? Thanks.