PDA

View Full Version : "hooks" ;)



Varsuuk
February 26th, 2020, 03:26
Was following some events triggers and saw so man hooks in CoreRPG for on start/end/etc for effects and init and actors etc.

Are they covered somewhere in some place? (if it's dev docs and I missed, I will wear... The Cone of Shame.)

No "--" descriptions but grepping to trace as I can.

damned
February 26th, 2020, 03:56
Im not sure if there is something specific to that. You might look at 5E effects it might give you some of the answers.
https://www.fantasygrounds.com/wiki/index.php/5E_Effects

Varsuuk
February 26th, 2020, 04:01
Yuppers, that page has been very useful to me :)

I meant hooks in the code for rulesets, like an example of ones in just one part of one file (the names are usually good enough to give a clue, but to see order of how some are called you need to look through call chain - plus found these all in one file looking up something from 2E - wonder how many of these are scattered around for other hooks waiting for me to stumble across :) )



...
--
-- CUSTOM EVENT HANDLING
--

local fCustomOnEffectAddStart = nil;
function setCustomOnEffectAddStart(f)
fCustomOnEffectAddStart = f;
end

local fCustomOnEffectAddIgnoreCheck = nil;
function setCustomOnEffectAddIgnoreCheck(f)
fCustomOnEffectAddIgnoreCheck = f;
end

local fCustomOnEffectAddEnd = nil;
function setCustomOnEffectAddEnd(f)
fCustomOnEffectAddEnd = f;
end

local fCustomOnEffectExpire = nil;
function setCustomOnEffectExpire(f)
fCustomOnEffectExpire = f;
end

local fCustomOnEffectDragDecode = nil;
function setCustomOnEffectDragDecode(f)
fCustomOnEffectDragDecode = f;
end

local fCustomOnEffectRollEncode = nil;
function setCustomOnEffectRollEncode(f)
fCustomOnEffectRollEncode = f;
end

local fCustomOnEffectRollDecode = nil;
function setCustomOnEffectRollDecode(f)
fCustomOnEffectRollDecode = f;
end

local fCustomOnEffectTextEncode = nil;
function setCustomOnEffectTextEncode(f)
fCustomOnEffectTextEncode = f;
end

local fCustomOnEffectTextDecode = nil;
function setCustomOnEffectTextDecode(f)
fCustomOnEffectTextDecode = f;
end

-- NOTE: These 4 custom functions should return true, if effect expired/removed
local fCustomOnEffectActorStartTurn = nil;
function setCustomOnEffectActorStartTurn(f)
fCustomOnEffectActorStartTurn = f;
end

local fCustomOnEffectActorEndTurn = nil;
function setCustomOnEffectActorEndTurn(f)
fCustomOnEffectActorEndTurn = f;
end

local fCustomOnEffectStartTurn = nil;
function setCustomOnEffectStartTurn(f)
fCustomOnEffectStartTurn = f;
end

local fCustomOnEffectEndTurn = nil;
function setCustomOnEffectEndTurn(f)
fCustomOnEffectEndTurn = f;
end

local nInitDirection
...

Trenloe
February 26th, 2020, 08:13
No documentation that I know of.

It’s a case of seeing where they’re used in the base code to see where you could use these in the layered ruleset. Some/most are used in 5E and other mainstream rulesets - see them for examples.

Varsuuk
February 26th, 2020, 12:39
OKies, cos I looked but not exhaustively and I always cringe expecting “um, Developer/API/Callbacks” page ;) (which while great, embarrasses me for not seeing it)

Cool, well, I’ve been fully commenting my headers on hooks used, eventually as I continue I may end up documenting my understanding of them (note the caveat) and will post up when have enough of it to be worthwhile.


I like the concept, used NVI (Nonvirtual Interface) a bit in my C++ based framework classes.

Moon Wizard
February 26th, 2020, 18:13
I have all the rulesets unzipped into the rulesets directory (actually sym-linked, but similar); and then I just run a directory wide search to find out where functions are used. In addition to Notepad++, I've been trying out Sublime Text 3 which allows you to add folders to a "project", and then search over the whole project or within specific folders. It also attempts to find where functions are defined, and show quick links on hover. Might be worth a look for you.

Regards,
JPG

Varsuuk
February 26th, 2020, 19:07
Moon, I have the exact same thing. In my eclipse project dir I have everything including ext’s unzipped (and I keep a local git for them - I delete old one then unzip new in same place) and in my FG working for I have symlinks (from my macbook’s parallels windows to my macOS for where eclipse and Ruleset sources are) for just CoreRPG & 2E because those are the two I often put Debug.console() logging to check order of calls etc.

As I use them, I am putting short description and Param docs on each submitted hook meth (because commenting in corerpg would be Sisyphean ;) )

Varsuuk
February 26th, 2020, 19:09
But didn’t know sublime did that show where thing. I use that all the time in Eclipse with C+* and Java and miss it since the lua plugin I use does not show “calls” or “all references”, etc. I just highlight the project and do search for the names.