Hello! about modyfing existing files

Moderator: Moderator

Post Reply
Message
Author
Vatticson
Posts: 2
Joined: Tue Jan 28, 2014 6:39 pm

Hello! about modyfing existing files

#1 Post 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

stinkstink
Spiderkin
Posts: 543
Joined: Sat Feb 11, 2012 1:12 am

Re: Hello! about modyfing existing files

#2 Post 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.

The Revanchist
Uruivellas
Posts: 762
Joined: Sun Nov 03, 2013 12:14 am

Re: Hello! about modyfing existing files

#3 Post 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 :)

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: Hello! about modyfing existing files

#4 Post 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

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

Re: Hello! about modyfing existing files

#5 Post 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.
My feedback meter decays into coding. Give me feedback and I make mods.

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

Re: Hello! about modyfing existing files

#6 Post by HousePet »

getBirthDescriptor("class", "Warrior").desc = {"Warrior are so ugly, you should bite a car."}
My feedback meter decays into coding. Give me feedback and I make mods.

Vatticson
Posts: 2
Joined: Tue Jan 28, 2014 6:39 pm

Re: Hello! about modyfing existing files

#7 Post 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 ^^.

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: Hello! about modyfing existing files

#8 Post 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.

Post Reply