Near4422 Posted February 15, 2021 Share Posted February 15, 2021 Hey! I am working on my first ever mod to don't starve together (and it's a character mod). I am still struggling a lot with the lua, but getting better. I would like to implement: Custom values for food types (for example for monster meat i'd like him to take half the original penalty), I've trid this metod inside modmain.lua: GetPlayer = GLOBAL.GetPlayer -- Food Values AddPrefabPostInit("carrot", function(inst) if GetPlayer().prefab == "fiddlesticks" then inst.components.edible.healthvalue = 2 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = -3 end end) but it resulted in instant error whenever i try to pick up a carrot :/ Special custom boomerang with infinite uses but using 10 health points per use (and if possible only usable by this custom character), I'd love to get a full tutorial on how to set up a new custom item. Aura around character that deals 1 point of damage every 2 seconds to every hostile characters in certain radius, and per each point dealt heal 1 point of hp (this could be working with a certain item in hand or just as a aura around character - whatever is easier). I've already created a topic about this subject a moment ago, but decided to create a new one containing all desired things. So far i tried the method mentioned by Combustiblemon, but it still isn't finished yet: local function IsVaildTarget(target) return target ~= nil and target.components.health ~= nil --can't drain when target has no health and not ((target:HasTag("prey") and not target:HasTag("hostile")) or target:HasTag("structure") or target:HasTag("wall") or target:HasTag("companion")) end local function onattack(inst, owner, target) target:AddTag("scythevictim") local count = 0 local pt = Vector3(target.Transform:GetWorldPosition()) local range = 5 local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) for i,ent in ipairs(ents) do if IsVaildTarget(ent) or ent and ent.components.health and ent:HasTag("scythevictim") then --because of scythevictim tag, you can even drain 'not vaild target(like wall, chester)' when it's directly attacked. if ent._scythedmgtask ~= nil then ent._scythedmgtask:Cancel() --it will reset its timer when it's re-attacked before timer done end ent._scythedmgtask = ent:DoTaskInTime(10, function(ent) ent._scythecount = nil ent._scythedmg = nil ent._scythedmgtask = nil end) --reset everything when 10 sec timer is done if ent._scythecount == nil then ent._scythedmg = ent:DoPeriodicTask(2, function(ent) ent.components.health:DoDelta(-1, false, owner) end) --every 2 seconds, it will deal 1 damage ent._scythecount = ent._scythecount + 1 else --it can be applied multiple times! ent._scythedmg = ent:DoPeriodicTask(2, function(ent) ent.components.health:DoDelta(-ent._scythecount, false, owner) end) --every 2 seconds, it will deal 'ent._scythecount' damage ent._scythecount = ent._scythecount + 1 end count = count + ent._scythecount --since ent._scythecount = damage dealt, you will heal total amount of damage dealt end end if owner._draintask ~= nil then owner._draintask:Cancel() owner._drain:Cancel() end --it will reset its timer when it is attacked before time done owner._draintask = owner:DoTaskInTime(10, function(owner) owner._drain = nil owner._draintask = nil end) owner._drain = owner:DoPeriodicTask(2, function(owner) owner.components.health:DoDelta(count) end) end There's high chance that i've poorly implemented this code but so far it causes Disconnect once a monster is attacked by weapon with this code. I am attatching core files of the mod so anyone can get a nice inside of what's going on. Thanks in advance to everyone who will try to help me with my very first character modmain.lua fiddlesticks.lua scare_scythe.lua Link to comment Share on other sites More sharing options...
Ultroman Posted February 17, 2021 Share Posted February 17, 2021 Start here Should get you everything except the boomerang, but there are tutorials for weapons somewhere on the forum. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.