Jump to content

[Custom Character Help] Using the Torch


Recommended Posts

This is included in a mod for a custom character.

I am attempting to make the Torch apply a sanity:dodelta and drain it (sanity) every time it is used on trees, saplings, berry bushes and grass with this character only. Much like the ice staff drains sanity each time it is used on enemies.

 

I searched in many .lua files and the only thing I could salvage was the onignite function which activates some action whenever it is used to ignite something burnable, as it is pointed in there with comments. I tried to play around with this but to no avail.

I looked at the torch.lua and played around with it, but couldn't make the game care about my script even though it is not actually crashing, which confuses me.

 

Any help would be appreciated :-)

 

Link to comment
Share on other sites

I looked at the torch.lua and played around with it, but couldn't make the game care about my script even though it is not actually crashing, which confuses me.

 

Make sure you're using the one in DLC0001-- it overrides the base game script.

 

I haven't actually done anything with the burnable component before, let me root around a bit.

Link to comment
Share on other sites

@Ysulyan,

 

Ah, what you're looking for is the "lighter" component.  Specicifally, Lighter:Light(target).  You'll want to override that method on the torch. Just remember to try to segregate your code from the base code to avoid mod conflicts:

local Light_old = inst.components.lighter.Lightlocal function Light_new(target)    --sanity stuff here    Light_old(target)endinst.components.lighter.Light = Light_new

The more I look at the word "light" the weirder it looks...

Link to comment
Share on other sites

@Ysulyan,

 

Ah, what you're looking for is the "lighter" component.  Specicifally, Lighter:Light(target).  You'll want to override that method on the torch. Just remember to try to segregate your code from the base code to avoid mod conflicts:

local Light_old = inst.components.lighter.Lightlocal function Light_new(target)    --sanity stuff here    Light_old(target)endinst.components.lighter.Light = Light_new

The more I look at the word "light" the weirder it looks...

First off, thanks a lot for your assistance! :D

Secondly: I forgot to check the DLC files... Ugh, what a dope :B

Now for the code, I get an error (finally!).

I get this "variable 'inst' is not declared" error. (first line)

You said you found this code somewhere in the lighter.lua component? Because I cannot seem to find it in that .lua file.

Link to comment
Share on other sites

@Ysulyan,

 

You dont want to be editing the base files.  Make a mod called "Torchlit Madness" (come up with something better ;) and modify the torch prefab from there:

 

modmain.lua:

local ThePlayer = GetPlayer()local function mod_torch(inst)    local Light_old = inst.components.lighter.Light     local function Light_new(target)        --sanity code goes here... use ThePlayer to reference the player prefab.        Light_old(target)    end      inst.components.lighter.Light = Light_newendAddPrefabPostInit("torch", mod_torch)

It's entirely possible that I have a typo in there, so apologies if I do-- I'm barely keeping my eyes open here.

Link to comment
Share on other sites

@Ysulyan,

 

You dont want to be editing the base files.  Make a mod called "Torchlit Madness" (come up with something better ;) and modify the torch prefab from there:

 

modmain.lua:

local ThePlayer = GetPlayer()local function mod_torch(inst)    local Light_old = inst.components.lighter.Light     local function Light_new(target)        --sanity code goes here... use ThePlayer to reference the player prefab.        Light_old(target)    end      inst.components.lighter.Light = Light_newendAddPrefabPostInit("torch", mod_torch)

It's entirely possible that I have a typo in there, so apologies if I do-- I'm barely keeping my eyes open here.

 

 

Oh man I thank you for your efforts but is making a new mod really necessary? I was hoping all of this would be included in a single mod, my character's mod.

Perhaps if I send you my modmain.lua...? I'm sorry if I'm taking too much of your time for this D:

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.

×
  • Create New...