Addons modifying Ashes content

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
fireflutterpony
Low Yeek
Posts: 8
Joined: Wed Feb 20, 2013 7:08 am

Addons modifying Ashes content

#1 Post by fireflutterpony »

I'm messing with modifying the Ashes DLC content with another addon, and I've run into an issue.

I understand that I have to make sure my addon loads after Ashes to make its changes appear, and that appears to be happening in te4_log.txt. I'm trying to superload some talent changes ... but TOME doesn't seem to think the talents I'm modifying have been defined.

Lua Error: ...gmod/superload//data/talents/corruptions/corruptions.lua:23: attempt to index field 'T_SHARE_THE_PAIN' (a nil value)
At [C]:-1 __newindex
At ...gmod/superload//data/talents/corruptions/corruptions.lua:23 f
At /engine/interface/ActorTalents.lua:42 loadDefinition
At /engine/interface/ActorTalents.lua:39 load
At /data/talents.lua:71 f
At /engine/interface/ActorTalents.lua:42 loadDefinition
At /mod/load.lua:204
At [C]:-1 require
At /engine/Module.lua:158 load
At /engine/Module.lua:921 instanciate
At /engine/utils.lua:2235 showMainMenu
At /engine/init.lua:156
At [C]:-1 dofile
At /loader/init.lua:196

I've superloaded talent changes before, and I used the same method here - referencing Talents.talents_def, so I'm a little stumped. I see no indication that the new talents in Ashes aren't loaded to the same table, nor that loadDefinition in ActorTalents has changed how it generates the table id for each talent.

Anyone else tried messing with Ashes' new talents?

wuxiangjinxing
Wayist
Posts: 29
Joined: Fri May 16, 2014 6:30 pm

Re: Addons modifying Ashes content

#2 Post by wuxiangjinxing »

I do not think it's a good way to modify addon-based contents with Superload. Here's my suggestion. (Assuming your addon is named as tome-myaddon)

(1)Make a folder as tome-myaddon/data

(2)Copy the file currently you have in your superload folder to this folder. And remove the first and the very last line. They shall be "local _M = loadPrevious " and "return _M". Let's assume that this file is named as "newtalent.lua".

(3)Make a folder as tome-myaddon/hooks and put a new file called "load.lua" in it.

(4)In load.lua, put the following things in:
local ActorTalents = require "engine.interface.ActorTalents"
class:bindHook("ToME:load", function(self, data)
ActorTalents:loadDefinition("/data-myaddon/newtalent.lua")
end)

The highlighted part shall be changed according to the real name of the folder and file. Sorry for my poor English ^_^

Effigy
Uruivellas
Posts: 970
Joined: Fri Oct 10, 2014 4:00 pm

Re: Addons modifying Ashes content

#3 Post by Effigy »

Your English is very good. No need to apologize.

fireflutterpony
Low Yeek
Posts: 8
Joined: Wed Feb 20, 2013 7:08 am

Re: Addons modifying Ashes content

#4 Post by fireflutterpony »

Okay, so I set up the hook (note, set hooks to true in init.lua or you'll spend an hour staring dumbly at your code wondering why your addon won't admit hooks exist) and ... now, instead of not seeing the Ashes-specific entries in Talents, my attempted changes can't see Talents at all.

Code: Select all

Lua Error: /data-mynextamazingmod/newcorruptions.lua:5: attempt to index global 'self' (a nil value)
	At [C]:-1 __index
	At /data-mynextamazingmod/newcorruptions.lua:5 
	At [string "return function(l, self, data) local ok=false..."]:1 
	At /mod/load.lua:300 
	At [C]:-1 require
	At /engine/Module.lua:158 load
	At /engine/Module.lua:921 instanciate
	At /engine/utils.lua:2235 showMainMenu
	At /engine/init.lua:156 
	At [C]:-1 dofile
	At /loader/init.lua:196 
Now, what I'm attempting to do is directly change parameters of the relevant talents by referencing Talents, eg:

Code: Select all

Talents.talents_def.T_BLEAK_OUTCOME.sustain_vim = 10
This works for superloading on core game stuff. Should I be trying something completely different when trying to use a hook into another addon's content?

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Addons modifying Ashes content

#5 Post by HousePet »

Better post the code, the error doesn't match with what you think is wrong.
My feedback meter decays into coding. Give me feedback and I make mods.

fireflutterpony
Low Yeek
Posts: 8
Joined: Wed Feb 20, 2013 7:08 am

Re: Addons modifying Ashes content

#6 Post by fireflutterpony »

Okay, cleaned that up, posted something from a failed attempt.

The problematic piece of code looks like this.

Code: Select all

function hookLoad()
Talents.talents_def.T_BLEAK_OUTCOME.sustain_vim = 2
end
I tried a more normal hook (loading a race definition) in this same function, and if I don't try the Talents call, the race definition works.

0player
Uruivellas
Posts: 717
Joined: Fri May 24, 2013 4:27 pm

Re: Addons modifying Ashes content

#7 Post by 0player »

"Talents" onl works in files you loadList like said above. You otherwise have to do explicit

Code: Select all

local Talents = require"engine.interface.ActorTalents"
somewhere in front of your line.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Addons modifying Ashes content

#8 Post by HousePet »

Without the complete code, and assuming the previous error is the one you are getting, all I can think of is that you need self and data as function arguments.
But really, three lines of code in isolation makes it really hard to debug.

function hookLoad(self, data)
My feedback meter decays into coding. Give me feedback and I make mods.

fireflutterpony
Low Yeek
Posts: 8
Joined: Wed Feb 20, 2013 7:08 am

Re: Addons modifying Ashes content

#9 Post by fireflutterpony »

Okay, yeah, I wasn't very clear. 0player's suggestion fixed things, so I'll try to lay out what I was trying to do, and what eventually worked, in case this is useful for anyone else.

I wanted to modify individual parameters of a talent. With core talents, this is pretty straightforward - just superload something like:

Code: Select all

local _M = loadPrevious(...)
Talents.talents_def.T_CHANT_OF_FORTRESS.sustain_positive = 15
where T_CHANT_OF_FORTRESS is the talents_def id of the talent I want to mess with (if the talent doesn't specify a short name, just use the normal name in all caps with spaces and ' replaced with _ - then tack T_ on the front)

and sustain_positive is the parameter I wanted to change.

The talent I wanted to modify was in the new Ashes DLC. Trying to superload changes onto something introduced by another addon fails, though. Thanks to everyone's patient explanations, this is what eventually worked:
  1. I followed wuxiangjinxing's suggestion - take "local _M = loadPrevious " out of my superload file, move the superload file (renamed to mytalentchanges.lua for this example) to tome-myaddon/data, add load.lua to tome-myaddon/hooks, add the following to load.lua:

    Code: Select all

    local class = require "engine.class"
    local DM = require("data-myaddon.mytalentchanges")
    
    class:bindHook("ToME:load", DM.hookLoad)
  • To get mytalentchanges.lua to play nice with load.lua, I wrapped my pre-existing code in the function I told load.lua to call, then add 0player's code so trying to directly reference Talents actually works:

    Code: Select all

    function hookLoad()
    local Talents = require "engine.interface.ActorTalents"
    Talents.talents_def.T_BLEAK_OUTCOME.sustain_vim = 10
    -- etc, etc
    end
    
And tada, game loads and changes show up. Thankyou to everyone for explaining this in words small enough for me to understand.

Post Reply