PDA

View Full Version : Error on client: "setValue: Unable to create node"



lokiare
September 15th, 2014, 21:12
On the rule set I'm developing I'm having an odd error happen. When a player that is connected rolls an attack while targeting an creature or dropping a roll on a token on the map or a creature on the combat tracker, it throws the following error:


Script Error: [string "scripts/manager_action_attack.lua"]:428: setValue: Unable to create node

The lines in question are:


-- Get the node and type for the target
local sTargetType, nodeTarget = ActorManager.getTypeAndNode(rTarget);
local sSourceType, nodeSource = ActorManager.getTypeAndNode(rSource);
local sourceName = DB.getValue(nodeSource, "name", "no name");

DB.setValue(nodeTarget, sourceName .. "resistChance", "number", rAction.nFirstDie);


rAction.nFirstDie is the result of a die roll.

I have no clue why this happens because if I connect locally on the same computer with a different instance of fantasy grounds it works without a problem.

I've used the debug console to get some of the values of the variables and here is the result:


Runtime Notice: s'Manager_action_attack->onAttack(): sourceName: Moe; rAction.nFirstDie: 13; sTargetType: ct; nodeTarget: not nil'

My only thoughts is that the client is trying to save the value to the database and it doesn't have access to it. If that is so, how would I get around that limitation to temporarily save the value so that the damage roll can access it?

The manager_action_attack is almost identical to the 4E one for reference. Thanks for your assistance.

Trenloe
September 15th, 2014, 21:39
I would imagine the issue is because the player FG client can't change the target node, i.e. the player side doesn't own it.

The way to change database values that aren't owned by the player is via OOB Messaging, which allows the player to essentially kick-off a script on the GM side. The GM side code can change the database, because the GM has complete access to the database.

You can see this in action in the 4E script you reference. The notifyApplyAttack function sets up the info for the OOB message OOB_MSGTYPE_APPLYATK, which when executed via the Comm.deliverOOBMessage command (last line of the notifyApplyAttack function) will run the handleApplyAttack function on the GM side - which essentially runs the applyAttack function, but the key thing here is that it is running on the GM side so can make changes to the database.

notifyApplyAttack is called from onAttack (which I think is where you are getting your error) - can you move your code into the OOB handling (applyAttack) passing the data needed through the OOB messaging process?

OOB messaging takes a little while to get your head around it - all of the data has to be passed in the msgOOB record structure (or readily available on the GM side - e.g. in the database) as the code will run on the GM instance of FG, so any variables etc. setup on the player side won't be accessible on the GM side.

In summary, for the OOB_MSGTYPE_APPLYATK OOB process in the 4E manager_action_attack.lua file:

During the player side result handler onAttack, OOB messaging is initiated by "notifyApplyAttack" (this will only be kicked off if there is a target).
notifyApplyAttack constructs the msgOOB record data that will be passed to the GM side, including msgOOB.type = OOB_MSGTYPE_APPLYATK (which is the type of the OOB message - needed on the GM side to determine what to do when the message is received) and then calls Comm.deliverOOBMessage.
The GM side gets the OOB message with msgOOB.type = OOB_MSGTYPE_APPLYATK, which has been registered in the OOB handler to run handleApplyAttack: OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_APPLY ATK, handleApplyAttack);
handleApplyAttack is ran on the GM side, it gets the data it needs out of the msgOOB record structure (rSource, rTarget, description, results, secret) and runs the applyAttack function which delivers the result of the attack to all connected clients.

So, you could put your new code in applyAttack, or (perhaps better for ease of future maintenance) make a new OOB message to handle what you want to do.