DICE PACKS BUNDLE
  1. #1

    Calling function from attached script

    Hello, I'm trying different permutations of how to call function on a field from attached script but to no avail.


    field is defined like:
    Code:
    <number_linked name="attribute">
      <source>
        <name>attributes.dexterity.user</name>
        <op>+</op>
      </source>                
    </number_linked >
    number_linked has script "number_linked.lua" attached from CoreRPG. It works great on its own.

    What I need to do is to add another source from lua script from "completely" different part of ruleset. number_linked.lua has function "AddSourceWithOp" defined. So I try do something like:

    Code:
    window.getDatabaseNode().getChild("attribute").addSourceWithOp("attributes.strength.step", "+");
    It does not allow that with message
    Code:
    attempt to call field 'addSourceWithOp' (a nil value)
    I have no idea how can I achieve this. Help?

  2. #2
    Ok.. As soon as I posted it, I figured it out.

  3. #3
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    please, please, please post your solution - even if its super simple...

    every little learn helps the rest of us!


    FG Con 6 – April 17-19th 2015 - register at www.fg-con.com for all the latest info.

  4. #4
    In fact this was elemental, if you think about it. Value you get from DB is just that - a value. Script is attached to control. So, instead of trying to run function on value for few hours (like an idiot), I should have run it on the control with code like:

    Code:
    window.attribute.addSourceWithOp("attributes.strength.step", "+");
    Ofcourse, this cannot be "completely different" place, and you have to have access path to this control. (You could also create window and controls etc. but this is nonsense, I fear)

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 Character Create Playlist

Log in

Log in