5E Character Create Playlist
  1. #1
    Wintermute's Avatar
    Join Date
    Nov 2013
    Location
    Pigeon Forge, Tennessee
    Posts
    335
    Blog Entries
    2

    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.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    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!

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    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!

  4. #4
    Wintermute's Avatar
    Join Date
    Nov 2013
    Location
    Pigeon Forge, Tennessee
    Posts
    335
    Blog Entries
    2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in