Question: self.T_FOO fails for addon talents, is this okay?

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Question: self.T_FOO fails for addon talents, is this okay?

#1 Post by Nagyhal »

Ever since I've started working with ToME, I've held the assumption that every talent in the game has its talent ID indexed by each and every actor. That is, if "FOO" is the short_name of a talent, then I can get the string "T_FOO" by looking up the "T_FOO" key (identical to the string value it returns) in the main table possessed by any actor.

Today, I learnt this is not true.

NPCs aren't indexing the talent IDs of talents added in the addons I've created, although the player character always starts with these values. They do index the talents in "talents_def" and similar tables - it's just the direct index to a talent ID that's lacking.

Because I've always accessed talent IDs this way, I've noticed that features which have worked for the player are breaking now I'm seeing NPCs try to use them.

I've looked through a number of different addons and have come to the conclusion that I'm not doing anything drastically wrong.

Passing the talent IDs directly wouldn't do me any harm, as there's no way any given function could tell the difference, but doing so would break stylistically with the code I've seen in ToME and I have the feeling things aren't supposed to be this way.

To give a direct example, I can open the Lua console and enter:

Code: Select all

=game.player.T_FLAME
    1 :=: T_FLAME  --beholder player character doesn't know flame, but has indexed the talent ID as it has all other talents
=game.player.T_FLAME_LASER
    1 :=: T_FLAME_LASER --fine
=uids[1247].name  --let's look at some random NPC
    1 :=: brown bear
=uids[1247].T_FLAME
    1 :=: T_FLAME  --bears don't cast flame, but init with the talent ID "T_FLAME" indexed anyway
=uids[1247].T_FLAME_LASER  --no output for my beholder addon talent id
When I first saw this, my instinct was to try to stick a band-aid on it.

Possessed by a fell mood, and eager to the be the first to uncover the causes of a mysterious bug, I spent most of the morning talking to my rubber duck as I waded through the Actor class's init process. While I had fun learning lots about the class system, I didn't come close to finding out why this is happening. So if it needs fixing, I'm certainly in no position to fix it.

On the other hand, maybe things are designed to work this way, and someone could explain why?

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Question: self.T_FOO fails for addon talents, is this ok

#2 Post by darkgod »

Can you show me how&where you load the talents files please ?
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

grayswandir
Uruivellas
Posts: 708
Joined: Wed Apr 30, 2008 5:55 pm

Re: Question: self.T_FOO fails for addon talents, is this ok

#3 Post by grayswandir »

It's because something's doing require 'mod.class.NPC' at the top of a talent file somewhere. I tried sticking require 'mod.class.Player' at the top of a talent file and that didn't have all the talents, either.
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Question: self.T_FOO fails for addon talents, is this ok

#4 Post by darkgod »

Why do that ??
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Re: Question: self.T_FOO fails for addon talents, is this ok

#5 Post by Nagyhal »

Sorry for not replying sooner, DarkGod.

I load all my talent files in the load.lua hooks file, like this:

Code: Select all

class:bindHook("ToME:load", function(self, data)
	ActorTalents:loadDefinition("/data-beholder-cont-beta/talents/spells.lua")
Then spells.lua has a list of things like:

Code: Select all

load("/data-beholder-cont-beta/talents/lightningeye.lua")
So, as far as I know there's nothing out of the ordinary going on here!

Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Re: Question: self.T_FOO fails for addon talents, is this ok

#6 Post by Nagyhal »

grayswandir wrote:It's because something's doing require 'mod.class.NPC' at the top of a talent file somewhere. I tried sticking require 'mod.class.Player' at the top of a talent file and that didn't have all the talents, either.
Ah, okay. I removed all instances of that and it was fixed. All talent IDs load for all actors, just as desired!
darkgod wrote:Why do that ??
The codebase I inherited did that and so far nothing had visibly broken, so it seemed natural to carry on that way.

Actually, talent files in the main ToME code do it all the time. Addon code being unable to do the same is extremely perplexing!

Thanks for your help anyway, guys! :D

Post Reply