Skip to content

Displaying chance to learn spell with skills

GrammarsaladGrammarsalad Member Posts: 2,582
edited April 2021 in UI Modding
Hello,

I'm wondering if it is possible to display the mage's chance to learn spells (and no other int based stat) in the skills tab. I'd prefer to be able to do this with the mage only, but I'd be happy to just be able to do it.

I tried to model it after Lore. First I tried:
elseif currentTab == 3 then
	
		listItems =	{
		        { characters[currentID].attr.int.strRef, characters[currentID].attr.int.current },
			{ characters[currentID].proficiencies.lore.strRef,  characters[currentID].proficiencies.lore.current },
			{ characters[currentID].proficiencies.reputation.strRef, characters[currentID].proficiencies.reputation.current, characters[currentID].proficiencies.reputation.helpStrRef },

}


But, that just showed the intelligence value. I tried a few variations with worse results... Any help would be appreciated (even it the answer is that it just isn't possible)

Edit:

Okay, I added this:
for k, v in ipairs(characters[currentID].proficiencies.ability) do
		    table.insert(listItems, {v.strRef, v.current})
	        end

This added all attribute bonuses to the skills screen (but with wonky text). I just need to exclude all of the entries I don't want...I don't know how to do that so far...
Post edited by Grammarsalad on

Comments

  • kjeronkjeron Member Posts: 2,367
    	if characters[currentID].proficiencies.ability[11] ~= nil then
    		if characters[currentID].proficiencies.ability[11].strRef == 0xF0043E then
    			table.insert(listItems, {'', characters[currentID].proficiencies.ability[11].current,})
    		end
    	end
    
    It should always be index 11, but index 11 won't always be learn chance.
    STR/DEX/CON values are always shown (the first 8 indexes).
    Followed by the 3 INT values (highest level, max known, chance to learn), based on class.
    Followed by CHA value (reaction).
    Followed by WIS values (bonus spells), based on class and level.

    A cleric will skip the INT values, and their bonus level 1 spell slots will occupy index 11, to avoid that check the strRef.
    0xF0043E is the reserved StrRef for "Chance to Learn Spells".

    You will end up with:
    : Chance to Learn Spell: ##
    The extra ":" at the beginning is because the two lists display things differently.
  • GrammarsaladGrammarsalad Member Posts: 2,582
    edited April 2021
    kjeron wrote: »
    	if characters[currentID].proficiencies.ability[11] ~= nil then
    		if characters[currentID].proficiencies.ability[11].strRef == 0xF0043E then
    			table.insert(listItems, {'', characters[currentID].proficiencies.ability[11].current,})
    		end
    	end
    
    It should always be index 11, but index 11 won't always be learn chance.
    STR/DEX/CON values are always shown (the first 8 indexes).
    Followed by the 3 INT values (highest level, max known, chance to learn), based on class.
    Followed by CHA value (reaction).
    Followed by WIS values (bonus spells), based on class and level.

    A cleric will skip the INT values, and their bonus level 1 spell slots will occupy index 11, to avoid that check the strRef.
    0xF0043E is the reserved StrRef for "Chance to Learn Spells".

    You will end up with:
    : Chance to Learn Spell: ##
    The extra ":" at the beginning is because the two lists display things differently.

    Thank you @kjeron . could I eliminate the extra ":" at the beginning if I remove lore and reputation? Ie:
    elseif currentTab == 3 then
    	
    		listItems =	{
    	--		{ characters[currentID].proficiencies.lore.strRef,  characters[currentID].proficiencies.lore.current },
    	--		{ characters[currentID].proficiencies.reputation.strRef, characters[currentID].proficiencies.reputation.current, characters[currentID].proficiencies.reputation.helpStrRef },
    
    }
    

    Edit: I answered my own question. The answer is 'no' :(
    Post edited by Grammarsalad on
  • GrammarsaladGrammarsalad Member Posts: 2,582
    Okay, this:
    if characters[currentID].proficiencies.ability[11] ~= nil then
      if characters[currentID].proficiencies.ability[11].strRef == 0xF0043E then
    --                table.insert(listItems, {characters[currentID].proficiencies.ability[11].strRef, characters[currentID].proficiencies.ability[11].current,})
                    table.insert(listItems, {characters[currentID].attr.int.strRef, characters[currentID].proficiencies.ability[11].current,})
      end
    end
    

    Displays: Intelligence: Chance to Learn Spell: nn

    That's not bad...
  • GrammarsaladGrammarsalad Member Posts: 2,582
    As a bonus, I was able to do this for Open Doors:
    table.insert(listItems, {characters[currentID].attr.str.strRef, characters[currentID].proficiencies.ability[3].current,})
    
  • kjeronkjeron Member Posts: 2,367
    A few line below these, just above the next currentTab section, you'll see:
    for k, v in ipairs(listItems) do
    	if (v[3] == nil or v[3] == '') then
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n'
    	else
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n' .. Infinity_FetchString(v[3]) ..'\n \n'
    	end
    end
    
    Alter it as such to remove the preceding ":":
    for k, v in ipairs(listItems) do
    	if (v[1] == '') then
    		helpTextString = helpTextString .. v[2] .. '^-' .. '\n'
    	elseif (v[3] == nil or v[3] == '') then
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n'
    	else
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n' .. Infinity_FetchString(v[3]) ..'\n \n'
    	end
    end
    
  • GrammarsaladGrammarsalad Member Posts: 2,582
    edited April 2021
    kjeron wrote: »
    A few line below these, just above the next currentTab section, you'll see:
    for k, v in ipairs(listItems) do
    	if (v[3] == nil or v[3] == '') then
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n'
    	else
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n' .. Infinity_FetchString(v[3]) ..'\n \n'
    	end
    end
    
    Alter it as such to remove the preceding ":":
    for k, v in ipairs(listItems) do
    	if (v[1] == '') then
    		helpTextString = helpTextString .. v[2] .. '^-' .. '\n'
    	elseif (v[3] == nil or v[3] == '') then
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n'
    	else
    		helpTextString = helpTextString .. Infinity_FetchString( v[1])  .. ': ' .. v[2] .. '^-' .. '\n' .. Infinity_FetchString(v[3]) ..'\n \n'
    	end
    end
    

    You're the best @kjeron !

    Edit: Test: Works like a charm!!!!

    Edit2: v[1], v[2], etc.: what do those represent? Are they different, um, ways to represent a list (e.g. <TEXT>":"<TEXT> vs <TEXT> (where in the 3rd instance, a ":" is already included in the text 'chunk'? Something like that?

    Edit3: oh, duh, I see it in the code... Hey, learning! Cool!

    God, it's so obvious when I see it...

    "'^-'" means to separate text with a space, "': ' " means separate text with a colon... Edit: I'm not completely sure exactly what ^- means, but I get the basic idea...

    "if (v[1] == '') then" if the first chunk/variable-def variable = "''"
    Post edited by Grammarsalad on
  • GrammarsaladGrammarsalad Member Posts: 2,582
    kjeron wrote: »
    ...
    0xF0043E is the reserved StrRef for "Chance to Learn Spells".
    ...

    @kjeron can you tell me how I can find these values? I accidentally displayed them on my character sheet--well, the values in decimal--but I didn't realize the significance and I don't remember how I did it...
  • kjeronkjeron Member Posts: 2,367
    They are built from ENGINEST.2da.

    The engine assigns StrRef (0xF00000 + row#) to mirror the string referenced for each row of that file (ignoring the 3 header rows).
Sign In or Register to comment.