PDA

View Full Version : Calling function from attached script



radekg
March 3rd, 2015, 10:46
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:


<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:



window.getDatabaseNode().getChild("attribute").addSourceWithOp("attributes.strength.step", "+");

It does not allow that with message

attempt to call field 'addSourceWithOp' (a nil value)

I have no idea how can I achieve this. Help?

radekg
March 3rd, 2015, 10:55
Ok.. As soon as I posted it, I figured it out. ;)

damned
March 3rd, 2015, 12:33
please, please, please post your solution - even if its super simple...

every little learn helps the rest of us!


https://www.fg-con.com/wp-content/uploads/2015/01/fg-con-6-150-1.jpg (https://www.fg-con.com/events/)
FG Con 6 – April 17-19th 2015 - register at www.fg-con.com (https://www.fg-con.com/) for all the latest info.

radekg
March 6th, 2015, 17:22
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:



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)