Page 1 of 1

Hello! about modyfing existing files

Posted: Tue Jan 28, 2014 6:48 pm
by Vatticson
Hi! I'm new to this game and also to Lua, I'm beginning to learn it :)

So, I've followed the ToME wikia about how to make an addon. The thing is, I wanted to change the description of the warrior class to something silly (just to try it it works!). So, I've created a directory for my addon (tome-yeahmola), and inside of it the needed directories for the warrior class, like this:

"...TalesMajEyal/addons/tome-yeahmola/superload/data/birth/classes/warrior.lua"

I thought following the wiki example, when it changes the mana_sustain attribute from Arcane Power with a single line, modyfing other things would be as easy. But I'm wrong of course! the game doesn't work with my AddOn (it got stuck in the loading screen). The following is written inside my warrior.lua file:

Code: Select all

local _M = loadPrevious(...)

BirthDescriptors.birthdescriptors_def.BD_WARRIOR.desc = {"Warrior are so ugly you should bite a car"}

return _M

So here's my problem :_D, I don't have any clue about what I should write to reach that class property. Is there any guide which tells it more clearly? Could you help me with this pleaaaase? :mrgreen:


Yours sincerely,
Vatticson

Re: Hello! about modyfing existing files

Posted: Wed Jan 29, 2014 4:27 am
by stinkstink
If an addon you're creating is causing the game to fail to load, you can usually search te4_log.txt for Lua Error to get a general idea of what's causing the problem.

Re: Hello! about modyfing existing files

Posted: Wed Jan 29, 2014 4:29 am
by The Revanchist
I don't have the best experience, but perhaps you could try calling the class in a data/birth/whatever.lua, and "inserting" the new description there?

For an example, the Arcanum class pack pretty much replaces the Alchemist, so you could look there for general advice,

Best of luck,
The Revanchist :)

Re: Hello! about modyfing existing files

Posted: Wed Jan 29, 2014 5:45 am
by Marson
The newTalent() function in \engine\interface\ActorTalents.lua takes Arcane Power and turns it into T_ARCANE_POWER with lines 64 and 79

Code: Select all

34   Talents = self,
...
64   t.short_name = t.short_name:upper():gsub("[ ']", "_")
...
79   t.id = "T_"..t.short_name
80   self.talents_def[t.id] = t
and lines 34 and 80 pull it together so that self.talents_def[t.id] is the same as Talents.talents_def.T_ARCANE_POWER

In \engine\Birther.lua, there is:

Code: Select all

55   t.short_name = t.short_name:upper():gsub("[ ]", "_")
but that doesn't come into play further below:

Code: Select all

65   self.birth_descriptor_def[t.type][t.name] = t
So in order to access t.desc, (I think) you need to change your BirthDescriptors.birthdescriptors_def.BD_WARRIOR.desc to Birther.birth_descriptor_def.class.Warrior.desc

Re: Hello! about modyfing existing files

Posted: Thu Jan 30, 2014 3:08 am
by HousePet
Oh yeah, I was going to explain what was wrong with this code last night, but then I didn't get around to turning the computer on.

Re: Hello! about modyfing existing files

Posted: Thu Jan 30, 2014 10:03 am
by HousePet
getBirthDescriptor("class", "Warrior").desc = {"Warrior are so ugly, you should bite a car."}

Re: Hello! about modyfing existing files

Posted: Sat Feb 01, 2014 1:30 pm
by Vatticson
Marson wrote:The newTalent() function in \engine\interface\ActorTalents.lua takes Arcane Power and turns it into T_ARCANE_POWER with lines 64 and 79

Code: Select all

34   Talents = self,
...
64   t.short_name = t.short_name:upper():gsub("[ ']", "_")
...
79   t.id = "T_"..t.short_name
80   self.talents_def[t.id] = t
and lines 34 and 80 pull it together so that self.talents_def[t.id] is the same as Talents.talents_def.T_ARCANE_POWER

In \engine\Birther.lua, there is:

Code: Select all

55   t.short_name = t.short_name:upper():gsub("[ ]", "_")
but that doesn't come into play further below:

Code: Select all

65   self.birth_descriptor_def[t.type][t.name] = t
So in order to access t.desc, (I think) you need to change your BirthDescriptors.birthdescriptors_def.BD_WARRIOR.desc to Birther.birth_descriptor_def.class.Warrior.desc
That didn't worked, but thanks to you i've found that function (string.gsub) and i've studied it and tried to understand it, so that's cool for my code learning :) Thanks!
getBirthDescriptor("class", "Warrior").desc = {"Warrior are so ugly, you should bite a car."}
It works, thank you ^^.

Re: Hello! about modyfing existing files

Posted: Sat Feb 01, 2014 4:14 pm
by Marson
That probably should have been

Birther.birth_descriptor_def["class"]["Warrior"].desc

but I had a Mad Cow moment. The function HousePet posted is even better, as it does error checking.