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

Editing Race Text and XP Penalties (TOME Addon)
http://forums.te4.org/viewtopic.php?f=45&t=47910
Page 1 of 1

Author:  Steven Aus [ Tue May 30, 2017 7:19 pm ]
Post subject:  Editing Race Text and XP Penalties (TOME Addon)

How do I edit the Race Text and XP penalties for a particular race and subrace? I have located where newBirthDescriptor is defined, but I'm not sure how to replace the text and the xp penalty if the addon is running. I'd rather just edit it after it is defined rather than superloading it. Also, it would be great to know how to edit or add just part of the text string, but that's not essential.

For example, this is what I want the description to be for Shalore:

Code:
desc = {
      "Shaloren elves have close ties with the magic of the world, and produced in the past many great mages.",
      "Yet they remain quiet and try to hide their magic from the world, for they remember too well the Spellblaze - and the Spellhunt that followed.",
      "They possess the #GOLD#Grace of the Eternals#WHITE# talent which allows them a boost of speed every once in a while.",
      "#GOLD#Stat modifiers:",
      "#LIGHT_BLUE# * -2 Strength, +1 Dexterity, +0 Constitution",
      "#LIGHT_BLUE# * +2 Magic, +3 Willpower, +1 Cunning",
      "#GOLD#Life per level:#LIGHT_BLUE# 9",
      "#GOLD#Experience penalty:#LIGHT_BLUE# 35%",
   }


and for Thalore:

Code:
desc = {
      "Thaloren elves have spent most of the ages hidden within their forests, seldom leaving them.",
      "The ages of the world passed by and yet they remained unchanged.",
      "Their affinity for nature and their reclusion have made them great protectors of the natural order, often opposing their Shaloren cousins.",
      "They possess the #GOLD#Wrath of the Woods#WHITE# talent, which allows them a boost to the damage both inflicted and resisted once in a while.",
      "#GOLD#Stat modifiers:",
      "#LIGHT_BLUE# * +2 Strength, +3 Dexterity, +1 Constitution",
      "#LIGHT_BLUE# * -2 Magic, +1 Willpower, +0 Cunning",
      "#GOLD#Life per level:#LIGHT_BLUE# 11",
      "#GOLD#Experience penalty:#LIGHT_BLUE# 25%",
   }


And of course the experience penalty field is just:

experience = 1.35,

or

experience = 1.25

respectively.


Based on my persistent dungeons addon that I made for Zizzo's T2 remake, my current hooks code is this:

Code:
local Zone = require "engine.Zone"                       -> These need to
local GameOptions = require "mod.dialogs.GameOptions"  -> be replaced

class:bindHook("TOME:load", function(self, data)
   if  type(config.settings.tome.xppenaltytweak) == 'nil' then
    config.settings.tome.xppenaltytweak = true
   end
   Birther?:edit?Definition('/data-xppenaltytweak/elf.lua') etc.
end)

Author:  Zizzo [ Wed May 31, 2017 3:00 am ]
Post subject:  Re: Editing Race Text and XP Penalties (TOME Addon)

Once you're inside the ToME:load hook, you don't really need to do anything elaborate; you can just modify the descriptor definition in place. You'll want something like:
Code:
class:bindHook("TOME:load", function(self, data)
  local Birther = require 'engine.Birther'
  local shalore = Birther:getBirthDescriptor('subrace', 'Shalore')
  shalore.experience = 1.35
  shalore.desc[8] = "#GOLD#Experience penalty:#LIGHT_BLUE# 35%"
end)

(This code is untested, of course; caveat emptor.) I've done this sort of thing before to modify talent definitions.

Author:  Steven Aus [ Wed May 31, 2017 11:20 am ]
Post subject:  Re: Editing Race Text and XP Penalties (TOME Addon)

I tested it, and even when I put the require line at the top it didn't show any change in the New Game screen. So there must be something else stopping it (I don't know whether it would still do the experience change if it didn't do the text change, but if I had to guess I would say no).

Author:  Zizzo [ Thu Jun 01, 2017 3:25 am ]
Post subject:  Re: Editing Race Text and XP Penalties (TOME Addon)

Steven Aus wrote:
I tested it, and even when I put the require line at the top it didn't show any change in the New Game screen.

[sound F/X: source diving] Ah, sorry, Birther:newBirthDescriptor() folds the desc{} table into a single string during the loading process, so table access won't work (I'm surprised it didn't throw an error, actually…). You could modify the field in place with string.gsub(), I suppose (or just replace it wholesale with another string).

Author:  Steven Aus [ Thu Jun 01, 2017 4:55 am ]
Post subject:  Re: Editing Race Text and XP Penalties (TOME Addon)

I tried replacing the whole string, and using string.gsub, however it still shows the old text. Is there anything preventing the text I'm trying to edit from being edited? And I wonder if the experience change is working? I tried starting a Thalore character but I couldn't see any place where the experience penalty was listed.

Author:  Zizzo [ Fri Jun 02, 2017 3:35 am ]
Post subject:  Re: Editing Race Text and XP Penalties (TOME Addon)

[sound F/X: testing] Well, the attached quick mockup addon appears to successfully modify the description of Shaloren in the character creation dialog (for testing, I made the word "Shaloren" blue and changed the described exp penalty to 42%).

Attachments:
tome-birth_test.zip [951 Bytes]
Downloaded 64 times

Author:  Steven Aus [ Fri Jun 02, 2017 8:27 am ]
Post subject:  Re: Editing Race Text and XP Penalties (TOME Addon)

I found the main reason it wasn't working.

I had:

class:bindHook('TOME:load', function(self, data)

instead of:

class:bindHook('ToME:load', function(self, data)

So obviously lua is case sensitive. :)


Question: why do other mods register on the character sheet online, but when I create a new game using this mod, it doesn't? Does it need to be marked by a dev or get some votes or something?

https://te4.org/games/addons/tome/racexptweak

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