JackCandem Posted February 13, 2015 Share Posted February 13, 2015 Hey there Klei Forum ,Excuse me if this question got already answered but I did not found it and the activated "flood control" kept me from trying to many keywords. So the Idea is to have an Item (a Weapon) that is characterspecific (like Abigails flower),stays with you all the time but gets "unsharp" after 25 uses and needs to get "sharpened" (I guess a mechanism like with the sewing kit would therefore work). But I do not exactly know how to work out that the Weapon stays in the inventory but does either 0 dmg or cant be even equipped until "sharpened". I hope you can help me, as this is my first mod try it could be that I oversaw many things or this is not even possible yet... Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/ Share on other sites More sharing options...
JackCandem Posted February 13, 2015 Author Share Posted February 13, 2015 or would it be possible that, if the weapon does not get "sharpened" it will be destroyed at 0% and, like abigails flower, return the next day? Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612800 Share on other sites More sharing options...
greenglacier Posted February 13, 2015 Share Posted February 13, 2015 Sigh, And here we go again. I got the problem many times. May it'll sound weird but when I left the game for day it just normalized and didn't appear for a while and now again. I just ignore this problem 'cuz I know it'll be gone. I dunno 'bout your case. Many things can cause that. Well, I wish good luck finding that one that's the real case ^^ Or u may should ask a modder like rezecib? Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612805 Share on other sites More sharing options...
Corrosive Posted February 14, 2015 Share Posted February 14, 2015 inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(<max number of uses here>) inst.components.finiteuses:SetUses(<number of uses to start out with here>) inst.components.finiteuses:SetOnFinished( onfinished )The weapon component automagically checks for the finiteuses component by default when attacking. onfinished should be a function that describes what happens when you run out of uses. Sharpening depends on how you want to implement it. The best way to learn though is to start playing around with this stuff. Just give it a go and keep tweaking stuff until it works. Don't get discouraged when something fails 20 times in a row. That comes with the territory of programming. I'd recommend getting a good file search utility (windows default search sucks horribly) and searching through *.lua when you want to learn how to do stuff. I use FileLocator Pro (which was a surprisingly good investment despite the ridiculous price), but there are plenty of free options out there. Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612877 Share on other sites More sharing options...
Blueberrys Posted February 14, 2015 Share Posted February 14, 2015 I'd recommend getting a good file search utility (windows default search sucks horribly) and searching through *.lua when you want to learn how to do stuff. I use FileLocator Pro (which was a surprisingly good investment despite the ridiculous price), but there are plenty of free options out there. Woah, hold on. I don't think DS modders will need something that complex or expensive. Lua files are in plain text format, and can be searched using free softwares quite nicely. Eclipse, for example, has a pretty reliable multi-file search (with highlighting search terms, and jumping to relevant lines). Though, that might also be overkill if someone is making just one or two small mods. I've heard Notepad++ also provides a similar functionality, and it's much easier to handle for beginners. Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612882 Share on other sites More sharing options...
debugman18 Posted February 14, 2015 Share Posted February 14, 2015 Woah, hold on. I don't think DS modders will need something that complex or expensive. Lua files are in plain text format, and can be searched using free softwares quite nicely. Eclipse, for example, has a pretty reliable multi-file search (with highlighting search terms, and jumping to relevant lines). Though, that might also be overkill if someone is making just one or two small mods. I've heard Notepad++ also provides a similar functionality, and it's much easier to handle for beginners. Both sublime and notepad++ have the 'find in files' functionality. Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612885 Share on other sites More sharing options...
Corrosive Posted February 14, 2015 Share Posted February 14, 2015 @Blueberrys, Haha, yeah after reading that back it sounds like I was endorsing getting it. I definitely agree you don't need something anywhere near that full featured to do some light modding. I just meant find something better than windows basic search <.< Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612908 Share on other sites More sharing options...
NikMik Posted February 14, 2015 Share Posted February 14, 2015 (edited) In my abandoned Old William mod, I had made a 3-shot rifle that had to be reloaded every 3 shots. Instead of finite uses, I used the fuel component. Like this: [codesyntax] local function onattack(inst, attacker, target)-- Take the bullet inst.components.fueled:DoDelta(-1)-- Tells the gun that it's missing a shot and can be reloaded inst.components.fueled.accepting = true end local function nofuel(inst)--Makes it not a weapon if inst.components.weapon then inst:RemoveComponent("weapon")--Tells it that it can reload inst.components.fueled.accepting = true endend local function takefuel(inst)--Make it work again! inst:AddComponent("weapon") inst.components.weapon:SetDamage(120) inst.components.weapon:SetRange(25, 30) inst.components.weapon:SetProjectile("bullet") inst.components.weapon:SetOnAttack(onattack) inst.components.fueled:DoDelta(3)--Tell it that it's full on armour inst.components.fueled.accepting =false--Make William go into a special state.GetPlayer().sg:GoToState("reloadrifle")end local function OnLoad(inst, data)--If it's empty, make it not a weapon. if inst.components.fueled:IsEmpty() then inst:RemoveComponent("weapon") inst.components.fueled.accepting = true else inst.components.fueled.accepting = false endend inst:AddComponent("weapon") inst.components.weapon:SetDamage(120) inst.components.weapon:SetRange(25, 30) inst.components.weapon:SetProjectile("bullet") inst.components.weapon:SetOnAttack(onattack) inst:AddComponent("fueled") inst.components.fueled.fueltype = "BULLET" inst.components.fueled:InitializeFuelLevel(3) inst.components.fueled.maxfuel = 3 inst.components.fueled:SetDepletedFn(nofuel) inst.components.fueled.ontakefuelfn = takefuel inst.components.fueled.accepting = true [/codesyntax] Edited February 14, 2015 by Mr. Tiddles Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612913 Share on other sites More sharing options...
JackCandem Posted February 14, 2015 Author Share Posted February 14, 2015 Thank you very much for your replies ! the munition idea is also very interesting You helped me al lot Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-612982 Share on other sites More sharing options...
seronis Posted February 14, 2015 Share Posted February 14, 2015 Best 'find in files' is Grep or WinGrep (if youre unlucky enough to not be using linux) Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-613009 Share on other sites More sharing options...
Corrosive Posted February 15, 2015 Share Posted February 15, 2015 Best 'find in files' is Grep or WinGrep (if youre unlucky enough to not be using linux) Hey now, grep isn't so advanced that there's not a direct port! I've never been a huge fan though, even on *nix. Requires too much work to tweak and customize searches, and isn't as full featured as I'd like. awk is pretty cool, but I don't want to spend weeks figuring out how to fully harness the power. Link to comment https://forums.kleientertainment.com/forums/topic/50919-creating-an-item-that-has-to-get-reloaded/#findComment-613184 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