PDA

View Full Version : InitiativeManager Gone?



Mike Serfass
December 27th, 2020, 04:24
Hello,

I'm trying to add a new edge that affects initiative card draws. Simply, a level headed edge that draws three extra cards.

My call to InitiativeManager is throwing the following error:


script execution error: [string "scripts/teledrial_tweaks.lua"]:36: attempt to index global 'InitiativeManager' (a nil value)

This indicates InitiativeManager doesn't exist. I tested with the War of the Dead slow hindrance extension. I know that extension works (or used to work) for others. It gives the exact same error on the same call (InitiativeManager.registerAbilityHandler).

I have only those two extensions installed. I'm running FGU classic 4.0.6, SWADE 5.2.10, core 3.3.12A.

Was InitiativeManager removed from SWADE? Was it renamed? Is there a replacement?

Thanks!

Mike Serfass
December 27th, 2020, 07:38
I figured this out. By rooting around in the SWADE ruleset, I learned that InitiativeManager is indeed gone from the SWADE API. It has been replaced by ActionCardManager. The registerAbilityHandler and registerCardHandler functions have the same signatures and functionality as they did in InitiativeManager.

It seems like there should be a wiki on the Savage Worlds API. Is there one that I'm missing?

steveculshaw
December 28th, 2020, 19:15
I figured this out. By rooting around in the SWADE ruleset, I learned that InitiativeManager is indeed gone from the SWADE API. It has been replaced by ActionCardManager. The registerAbilityHandler and registerCardHandler functions have the same signatures and functionality as they did in InitiativeManager.

It seems like there should be a wiki on the Savage Worlds API. Is there one that I'm missing?

Many thanks for investigating and sharing.

No idea about "coding" in FGU, but interested in messing around ... will you be releasing your edge?

Mike Serfass
December 30th, 2020, 15:04
Here's the edge. It's a bit strong, so compare that to your setting's power level.
First, the edge description as it appears in my setting module:

Legendary Level Headed
Type: Legendary Edge
Requirements: Legendary, Improved Level Headed
Fighters who can keep their cool when everyone else is running for cover make deadly combatants. A hero with this Edge draws three additional Action Card in combat and chooses which to use.
Notes: Remove prior Level Headed Edges for this to work properly.

Here's the code in the lua script:

function onInit()
ActionCardManager.registerAbilityHandler("legendary-level-headed", "Legendary Level Headed", legendaryLevelHeadedHandler)
end

-- Note: This function adds too many cards if the character has either of the other level headed edges.
-- Those edges must be removed from the character.
function legendaryLevelHeadedHandler(winGroup, oCard, fDraw)
if winGroup.isIncapacitated() then
return oCard
end

-- for existing core edges, return the passed-in card because the other event handlers deal with them

if winGroup.hasAbility(Interface.getString("edge_level_headed_improved")) then
return oCard
end

if winGroup.hasAbility(Interface.getString("edge_level_headed")) then
return oCard
end

-- handle my edge

local rHandlerInfo = {
title = Interface.getString("edge_x_edge"):format("Legendary Level Headed"),
extraCards = {},
bChoose = true
}

for nIndex = 3, 1, -1 do
local oDrawnCard = fDraw()
if oDrawnCard.compareTo(oCard) > 0 then
table.insert(rHandlerInfo.extraCards, oCard)
oCard = oDrawnCard
else
table.insert(rHandlerInfo.extraCards, oDrawnCard)
end
end

return oCard, rHandlerInfo
end


One Caveat, which is noted in code comments. I haven't yet figured out how to override the level headed functions in the SWADE module. If either of the core rules level headed edges are on the character sheet, the respective function is called in the SWADE module in addition to my custom function, resulting in the character receiving too many action cards. I put a note in the edge description to remind players of this.

I have also not yet figured out how to automatically replace a lower rank edge with a higher rank edge. For instance, if you drag Improved Level Headed onto your character sheet, and Level Headed is already listed, Level Headed is removed / replaced with Improved Level Headed. I don't know how to do that with custom edges. So dragging Legendary Level Headed onto the character sheet does not replace Improved Level Headed. Hence my edge note to prompt the player to do that manually.

I hope that helps!

I also have benny edges that give the player more starting bennies. One's a racial edge, the other is a legendary edge. I'll post those if you're interested.