Coding Tips and Help needed for Character Mod


RavenWreckt

Recommended Posts

I've already sprited most of my Character Mod (the feet are a nightmare) but I've hit a roadblock with some of the coding. I've experimented with .lua code quite a bit, and I've figured out how to tinker with movement speed, sanity drain, hunger drain, health regen, freezing resistance, ect. However, there are certain seemingly simple things I've been trying to work with that I cannot code for the life of me. Please note that anyone who lends assistance with the coding will be mentioned when the finished mod is uploaded. Here are a few of my major problems:

 

How do I edit the efficiency of actions? i.e. make mining twice as fast (which is what I'm trying to code), or in the very least speed it up. So I figured this would work:

 

inst.components.worker:SetAction(ACTIONS.MINE, 2)

 

But it did not affect the speed whatsoever, so I take it I'm doing that wrong. Another thing: I'm trying to code it so that planting saplings or destroying rocks of any type (rock1, rock2, and rock_flintless) increases your sanity so I tried using this code (for the rocks):

 

local function onkill(inst, data)
   -- Increase sanity when destroying a any type of rock
   if data.cause == inst.prefab then
      if data.inst:HasTag(" * ") 
      or data.inst:HasTag(" * ") 
      or data.inst:HasTag(" * ") 
      then
         inst.components.sanity:DoDelta(5)
         -- Randomly respond
         if math.random() < .3 then
         inst.components.talker:Say("[Placeholder]")
         end
      end
   end
end
 
*I'm unsure of what to put in these spaces, or if this code will even work anyways. I'm also not sure what to do for the planting saplings code.
 
I also wanted to try to make my character make an announcement upon crafting any type of blowdart weapon, but this code doesn't seem to be working:
 
local function onbuild(inst, data)
   -- Announce liking certain items
   if data.item.prefab == "blowdart_pipe"
   or data.item.prefab == "blowdart_fire"
   or data.item.prefab == "blowdart_sleep"
   then
   inst.components.talker:Say("[Placeholder]")
end
 
And finally, I was trying to figure out a code that would allow my character to do more damage than normal with all types of blowdarts alone, and not a code that would increase base damage for all weapons (I already know how to do that). I honestly don't even know where to begin with this code. perhaps something like this?
 
 inst.components.combat.damagemultiplier("blowdart_pipe", "blowdart_sleep", "blowdart_fire")= 1.5
 
I'm not sure. Any help is ENORMOUSLY appreciated, and as mentioned earlier, anyone who helps me out with the code will be mentioned when the completed mod is uploaded. Thank you for your time!
 
Link to comment
Share on other sites

I'm not too experienced in coding, but I'd assume looking into Woodie's files might help with the mining.

 

I actually tried that, and the result was the code I listed; that didn't work. I did, however, find the solution to that particular one:

 

TUNING.ROCKS_MINE = 4
TUNING.ROCKS_MINE_MED = 2
TUNING.ROCKS_MINE_LOW = 2
 
As to why the other one works for Woodie but not my mod is beyond me, but I'm sure I did something wrong.
Link to comment
Share on other sites

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.