-
April 25th, 2018, 18:09 #1
Referencing tokeninstance objects
I was wondering if someone could point me in the right direction. I'm not new to programming, but I am new to lua.
I wanting to use two functions from tokeninstance, onActivation and setActive. I'm not sure how to reference the functions. Trying something like:
if setActive() == true then
Debug.console('setActive called')
end
This gives me a console error "Attempt to call global 'setActive' (a nil value)". Do I have to call it like tokeninstance.setActive()? Did I miss defining it as a global?
Thanks for any help.Last edited by Wintermute; April 25th, 2018 at 18:12. Reason: minor code change
-
April 25th, 2018, 18:53 #2
These are two different types of functions - one is an event handler (onActivation) and one is a package function that you call.
See here for details of event handlers: https://www.fantasygrounds.com/wiki/...g#Using_Events
setActive() needs to be called with the token instance object - e.g. myTokenInstance.setActive(true);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!
-
April 25th, 2018, 18:56 #3
I'd recommend you do a "find in files" (use a text editor that supports this) in the CoreRPG ruleset (extract CoreRPG.pak into a temporary location - not the FG "rulesets" directory).
Search for .setactive to find some examples of how to use this function.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!
-
April 25th, 2018, 19:21 #4
I had searched the core ruleset for onActivation but not for setActive. A quick search did indeed answer most of my questions. Thanks Trenloe for pointing out the right direction.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks