Jump to content

Recommended Posts

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...

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?

    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.

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.

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.

@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 <.<

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
 
end
end
 
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
 
    end
end
 
    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 by Mr. Tiddles

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.

6tTciNJ.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...