Thread: Beginner Question on Functions
-
May 25th, 2020, 21:52 #1
- Join Date
- Apr 2020
- Posts
- 36
Beginner Question on Functions
Okay, so I am fairly new to working in LUA and definitely in programming with Fantasy Grounds. I want to make a simple change to a function within the CoreRPG ruleset function addEffect. The original funtion:
Code:function addEffect(sUser, sIdentity, nodeCT, rNewEffect, bShowMsg) ... end
Code:rNewEffect.nGMOnly = 1;
SO, the question is, how to I hijack this function to add my own code? Is there a tutorial about doing this?
I would really appreciate a point in the right direction, thanks!
-
May 25th, 2020, 22:59 #2
addEffect has a couple of places where you can call custom functions: fCustomOnEffectAddStart or fCustomOnEffectAddEnd. Both of these pass rNewEffect so you can add/change the contents of that LUA table.
These custom functions are set using EffectManager.setCustomOnEffectAddStart(function) or EffectManager.setCustomOnEffectAddEnd(function)
Look in the 5E ruleset, scripts\manager_effect_5e.lua for an example of setCustomOnEffectAddStart.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 25th, 2020, 23:25 #3
- Join Date
- Apr 2020
- Posts
- 36
Thank you!
Amazing. It reduced my code from copying an entire function to the following:
Code:function onInit() EffectManager.setCustomOnEffectAddStart(customAddEffect); end function customAddEffect(rNewEffect) -- ALWAYS add effects as GM Only rNewEffect.nGMOnly = 1; end
Any idea where I find these types of functions? Is it just a matter of going through the ruleset code or are they documented somewhere?
-
May 25th, 2020, 23:54 #4Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks