API:TomeGetAchievementsSubTypeData
From RoR Wiki
UI Lua API · Tome functions
Version: WAR 1.4.8
Returns the page of an achievement subtype in the Tome of Knowledge: its description and all of its entries with their rewards.
subTypeData = TomeGetAchievementsSubTypeData(subTypeId)
Arguments
- subTypeId
number– Achievement subtype id, as in thesubtypeslist of TomeGetAchievementsTOC.
Returns
- subTypeData
table– The subtype's data, or nothing if the id is invalid or the subtype is still locked.
| Key | Type | Meaning |
|---|---|---|
id |
number |
Subtype id. |
name |
wstring |
Subtype name. |
desc |
wstring |
Subtype description. |
entries |
table |
Array of the subtype's entries, locked ones included (see below). |
Each entry table in entries:
| Key | Type | Meaning |
|---|---|---|
id |
number |
Entry id, as used by TomeGetAchievementsEntryData. |
name |
wstring |
Entry name. L"???" for a locked entry.
|
desc |
wstring |
Entry description. Empty for a locked entry. |
isUnlocked |
boolean |
Whether the entry is unlocked. The stock UI shows it as the entry's "completed" check box. |
unlockEventId |
number |
Only for unlocked entries: id of the unlock event. The stock UI uses it for the "bragging rights" context menu. |
cardId |
number |
Only for unlocked entries: id of the Tome card for the entry, or 0. The stock UI passes it to TomeGetCardData.
|
rewards |
table |
Array of reward tables (see below). Empty for a locked entry. |
Each reward table in rewards:
| Key | Type | Meaning |
|---|---|---|
rewardType |
number |
Reward type, compared by the stock UI with GameData.Tome.REWARD_* values.
|
rewardId |
number |
Id of the reward (item, ability, …) of that type. |
rewardDesc |
wstring |
Description text from the client's achievement reward string tables; empty if the table is missing. |
Details
- An entry has up to five reward slots; empty slots are left out.
- If none of an entry's reward slots has type
0, the client puts an extra reward of type0first, with an emptyrewardDescand arewardIdit looks up from its Tome unlock data for the entry (0when there is none; the stock UI hides rewards with id 0). - The picture is not part of the table; TomeSetAchievementsSubTypeImage loads it.
- Use the
isUnlockedfield of TomeGetAchievementsTOC or TomeIsAchievementsSubTypeUnlocked first: a locked subtype logs an error. - Exactly one argument must be passed.
Errors
These are written to the UI log, and the function returns nothing.
Error in function call 'TomeGetAchievementsSubTypeData': %d is not a valid Achievements subtype id.Error in function call 'TomeGetAchievementsSubTypeData': pSubTypeData for id %d is NULL .(also logged when the subtype exists but is still locked)
Example
From default/ea_tomeofknowledge/source/tomewindow_achievements.lua:
TomeWindow.Achievements.CurSubTypeData = TomeGetAchievementsSubTypeData( subTypeId )
...
LabelSetText("AchievementsSubTypeInfoName", wstring.upper( subTypeData.name ) )
TomeSetAchievementsSubTypeImage( subTypeData.id )
LabelSetText("AchievementsSubTypeInfoText1", subTypeData.desc )
...
for index, entryData in ipairs( subTypeData.entries ) do
...
ButtonSetPressedFlag( entryWindowName.."CompletedBtn", entryData.isUnlocked )
LabelSetText( entryWindowName.."Name", entryData.name )
LabelSetText( entryWindowName.."Desc", entryData.desc )
TomeWindow.SetTomeReward( entryWindowName.."Reward1", entryData.rewards[1] )
TomeWindow.SetTomeReward( entryWindowName.."Reward2", entryData.rewards[2] )
...
if( entryData.cardId and entryData.cardId ~= 0 )
then
cardData = TomeGetCardData( entryData.cardId )
...
