ToME: the Tales of Maj'Eyal
http://forums.te4.org/

Hello! about modyfing existing files
http://forums.te4.org/viewtopic.php?f=45&t=40345
Page 1 of 1

Author:  Vatticson [ Tue Jan 28, 2014 6:48 pm ]
Post subject:  Hello! about modyfing existing files

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:
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

Author:  stinkstink [ Wed Jan 29, 2014 4:27 am ]
Post subject:  Re: Hello! about modyfing existing files

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.

Author:  The Revanchist [ Wed Jan 29, 2014 4:29 am ]
Post subject:  Re: Hello! about modyfing existing files

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 :)

Author:  Marson [ Wed Jan 29, 2014 5:45 am ]
Post subject:  Re: Hello! about modyfing existing files

The newTalent() function in \engine\interface\ActorTalents.lua takes Arcane Power and turns it into T_ARCANE_POWER with lines 64 and 79

Code:
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:
55   t.short_name = t.short_name:upper():gsub("[ ]", "_")


but that doesn't come into play further below:

Code:
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

Author:  HousePet [ Thu Jan 30, 2014 3:08 am ]
Post subject:  Re: Hello! about modyfing existing files

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.

Author:  HousePet [ Thu Jan 30, 2014 10:03 am ]
Post subject:  Re: Hello! about modyfing existing files

getBirthDescriptor("class", "Warrior").desc = {"Warrior are so ugly, you should bite a car."}

Author:  Vatticson [ Sat Feb 01, 2014 1:30 pm ]
Post subject:  Re: Hello! about modyfing existing files

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:
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:
55   t.short_name = t.short_name:upper():gsub("[ ]", "_")


but that doesn't come into play further below:

Code:
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!

Quote:
getBirthDescriptor("class", "Warrior").desc = {"Warrior are so ugly, you should bite a car."}


It works, thank you ^^.

Author:  Marson [ Sat Feb 01, 2014 4:14 pm ]
Post subject:  Re: Hello! about modyfing existing files

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/