fluffyNest Posted October 23, 2015 Share Posted October 23, 2015 (edited) Greetings.It's about many durabilities in one stackable. (Search bar gives nothing) First question - is this possible?Second q. - how? Some details:Required behaviour - item(weapon) have component stackable, onAtack its getting removed from stack:Stackable:Get(1) Some code going on and in the end its getting deleted completely and get replaced by new instance of the "weapon" that inherits "finiteuses" from old "weapon" throughnewweapon...finiteuses:SetUses(oldweapon...finiteuses:GetUses())But stackable just don't hold individual durability...Im starting to think about some sort of custom component.Any ideas? Edited October 23, 2015 by fluffyNest Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/ Share on other sites More sharing options...
Arkathorn Posted October 23, 2015 Share Posted October 23, 2015 (edited) Tags are set, removed, and read like this:inst:AddTag("tag") --Adds a taginst:RemoveTag("tag") --Removes a taginst:HasTag("tag") --Returns true if the entity has the tag, and false if it does notI am not sure exactly what you are trying to say. When do you want the stack of items to turn into a durability? EDIT: Do you want it to repair when you stack it with another one? Edited October 23, 2015 by Arkathorn Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682109 Share on other sites More sharing options...
Mobbstar Posted October 23, 2015 Share Posted October 23, 2015 (edited) Lol, the tags thing is for form searches. They're set when creating/editing a topic, right under the topic title. As for the coding problem, I don't think that's possible with stackable. You'd have to do a LOT of work for this, and it'd eat memory like bread crums if you do it for everything stackable. Edited October 23, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682113 Share on other sites More sharing options...
fluffyNest Posted October 23, 2015 Author Share Posted October 23, 2015 Mobbstar, Hmm... How about to keep Durabilties in an array and write them in stackable:Put() and restore them in stackable:Get()? Also add a bool to determine does item support multiDurs. And use only for around 2 stacks(40 items total) per player or more. Is this still a big work and memory killer? Arkathorn, sry for misunderstanding. Stackable don't keep items durabilities. Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682125 Share on other sites More sharing options...
fluffyNest Posted October 23, 2015 Author Share Posted October 23, 2015 Also, wrong game category, lol. This topic about DST. Can any good moderator fix it? Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682128 Share on other sites More sharing options...
Arkathorn Posted October 23, 2015 Share Posted October 23, 2015 So you want to have a stackable weapon, and each weapon keeps it's durability when you un-stack it? If so, what happen when you equip a stack? Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682135 Share on other sites More sharing options...
fluffyNest Posted October 23, 2015 Author Share Posted October 23, 2015 (edited) Arkathorn, some code from third man. Concrete it's "throwable spears" by rezecib. There is some fancy code. I'm alredy had modified it for stackable. just with few lines. STACK_SIZE is from mod settings(c)rezeciblocal spear = instlocal ontopspear = inst if STACK_SIZE > 0 theninst:AddComponent("stackable") --new code by nestofmooninst.components.equippable.equipstack = true --new code by nestofmoon TUNING.STACK_SIZE_SMALLITEM local stsz = 1if STACK_SIZE == 1 then stsz = TUNING.STACK_SIZE_SMALLITEMelseif STACK_SIZE == 2 then stsz = TUNING.STACK_SIZE_MEDITEMelseif STACK_SIZE == 3 then stsz = TUNING.STACK_SIZE_LARGEITEM endinst.components.stackable.maxsize = stszend local function onattack(inst, attacker, target, skipsanity)local smalltarget = target:HasTag("smallcreature") and not smallhits[target.prefab]local missed = falseif math.random() < SMALL_MISS_CHANCE and smalltarget thenmissed = trueif attacker.components and attacker.components.talker thenlocal miss_message = "Ugh, I don't think I can hit something that small!"if attacker.prefab == 'wx78' then miss_message = "INSUFFICIENT ACCURACY" endattacker.components.talker:Say(miss_message)target:PushEvent("attacked", {attacker = attacker, damage = damage, weapon = spear})endelseif target.components.combat thentarget.components.combat:GetAttacked(attacker, attacker.components.combat:CalcDamage(target, spear), weapon)end endif STACK_SIZE > 0 then ontopspear = spear.components.stackable:Get(1) end --new code by nestofmoonlocal newspear = GLOBAL.SpawnPrefab('spear')newspear.Transform:SetPosition(inst:GetPosition():Get())if newspear.components.finiteuses then--newspear.components.finiteuses:SetUses(spear.components.finiteuses:GetUses()) --original codenewspear.components.finiteuses:SetUses(spear.components.finiteuses:GetUses()) --'new missing' code by nestofmoonnewspear.components.finiteuses:Use((smalltarget and not missed)and GLOBAL.TUNING.SPEAR_USES/SMALL_USESor GLOBAL.TUNING.SPEAR_USES/LARGE_USES)endnewspear:AddTag("scarytoprey")newspear:DoTaskInTime(1, function(inst) inst:RemoveTag("scarytoprey") end)inst:Remove()-- spear.parent.AnimState:OverrideSymbol("swap_object", "", "")--spear:Remove() --original codeontopspear:Remove() --new code by nestofmoon attacker.SoundEmitter:PlaySound("dontstarve/wilson/attack_weapon", nil, nil, true)end Edited October 23, 2015 by fluffyNest Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682136 Share on other sites More sharing options...
fluffyNest Posted October 23, 2015 Author Share Posted October 23, 2015 (edited) Oh, looks messy. Just in case I had alredy get rezecib permision.New lines marked with "--new code by nestofmoon". So in the end I would like to get some universal stackable component that can be used with many other mods.Maybe even start some extended api library. Is this qood idea to implement it through smallbytearray? Edited October 23, 2015 by fluffyNest Link to comment https://forums.kleientertainment.com/forums/topic/58648-stackable-durabilities/#findComment-682139 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