Dragon_of_old
September 20th, 2025, 21:51
Hello everyone,
I was wondering if anyone could point out what I’m doing wrong with my LUA script. I am still inexperienced with working with this language. What I’m trying to accomplish for my ruleset within the character sheet is a page that is used to build the character for the game. I have created a section in the Fantasy Grounds library that stores the starting attributes and health of a given race so that the player can drag and drop it into their character sheet.
Here’s an example of how it should work. You tab over to the build part of the sheet, and there will be a spot where you can drag-and-drop a race, where it will populate the starting attribute points and starting health, where the page can calculate it out for the player.
I’m using a window list to get the drag-and-drop function. I realize that this field is being treated as a separate window from the build character page. I have searched the forums, Google, and even Google AI for a possible solution. Likely, I’m not experienced enough with Fantasy Grounds and LUA to make what I want to happen. But I’m aware that it is possible from another rule set, which is “Called of Cthulhu”, where the players can copy occupations from the library to their character sheet.
Any insight on this issue is greatly appreciated, and thank you for your help.
Here is my LUA script
--[[copy_race_information
This script copies information when a race is selected to gather starting attributes,
starting Health, and the race name. Copy them to build part of the character sheet.
It is using a window list for the information storage, so the player can drag and drop
the data for a given race for the game system.]]
function onValueChanged()
local nodeWin = window.getDatabaseNode(); -- Access the field in the window.
local listNode = window.getPath("campagin.item_list.race_list_winLis"); -- Access the window list.
local raceNAME = listNode.getChild("name").getValue(); -- Playable race name (string field).
local hpSTART = listNode.getChild("hpBASE").getValue(); -- Starting point for health (number field).
local msSTART = listNode.getChild("msBASE").getValue(); -- Starting point for Melee skill attribute (number field).
local rsSTART = listNode.getChild("rsBASE").getValue(); -- Starting point for Range skill attribute (number field).
local strSTART = listNode.getChild("strBASE").getValue(); -- Starting point for Strength attribute (number field).
local touSTART = listNode.getChild("touBASE").getValue(); -- Starting point for Toughness attribute (number field).
local agiSTART = listNode.getChild("agiBASE").getValue(): -- Starting point for Agility attribute (number field).
local perSTART = listNode.getChild("perBASE").getValue(); -- Starting point for Perception attribute (number field).
local intSTART = listNode.getChild("intBASE").getValue(); -- Starting point for Intelligence attribute (number field).
local logSTART = listNode.getChild("perBASE").getValue(); -- Starting point for Logic attribute (number field).
local disSTART = lsitNode.getChild("disBASE").getValue(); -- Starting point for Discipline attribute (number field).
local amiSTART = listNode.getChild("amiBASE").getValue(); -- Starting point for Amity attribute (number field).
nodeWin.getChild("raceDST").setValue(raceNAME); -- This copies the playable race name.
nodeWin.getChild("hpSRT").setValue(hpSTART); -- This copies the starting points for health.
nodeWin.getChild("msRACE").setValue(msSTART); -- This copies starting value Melee skill attribute.
nodeWin.getChild("rsRACE").setValue(rsSTART); -- This copies starting value Range skill attribute.
nodeWin.getChild("strRACE").setValue(strSTART); -- This copies starting value Strength attribute.
nodeWin.getChild("touRACE").setValue(touSTART); -- This copies starting value Toughness attribute.
nodeWin.getChild("agiRACE").setValue(agiSTART); -- This copies starting value Agility attribute.
nodeWin.getChild("perRACE").setValue(perSTART); -- This copies starting value Perception attribute.
nodeWin.getChild("intRACE").setValue(intSTART); -- This copies starting value Intelligence attribute.
nodeWin.getChild("logRACE").setValue(logSTART); -- This copies starting value Logic attribute.
nodeWin.getChild("disRACE").setValue(disRACE); -- This copies starting value Discipline attribute.
nodeWin.getChild("amiRACE").setValue(amiRACE); -- This copies starting value Amity attribute.
end
I was wondering if anyone could point out what I’m doing wrong with my LUA script. I am still inexperienced with working with this language. What I’m trying to accomplish for my ruleset within the character sheet is a page that is used to build the character for the game. I have created a section in the Fantasy Grounds library that stores the starting attributes and health of a given race so that the player can drag and drop it into their character sheet.
Here’s an example of how it should work. You tab over to the build part of the sheet, and there will be a spot where you can drag-and-drop a race, where it will populate the starting attribute points and starting health, where the page can calculate it out for the player.
I’m using a window list to get the drag-and-drop function. I realize that this field is being treated as a separate window from the build character page. I have searched the forums, Google, and even Google AI for a possible solution. Likely, I’m not experienced enough with Fantasy Grounds and LUA to make what I want to happen. But I’m aware that it is possible from another rule set, which is “Called of Cthulhu”, where the players can copy occupations from the library to their character sheet.
Any insight on this issue is greatly appreciated, and thank you for your help.
Here is my LUA script
--[[copy_race_information
This script copies information when a race is selected to gather starting attributes,
starting Health, and the race name. Copy them to build part of the character sheet.
It is using a window list for the information storage, so the player can drag and drop
the data for a given race for the game system.]]
function onValueChanged()
local nodeWin = window.getDatabaseNode(); -- Access the field in the window.
local listNode = window.getPath("campagin.item_list.race_list_winLis"); -- Access the window list.
local raceNAME = listNode.getChild("name").getValue(); -- Playable race name (string field).
local hpSTART = listNode.getChild("hpBASE").getValue(); -- Starting point for health (number field).
local msSTART = listNode.getChild("msBASE").getValue(); -- Starting point for Melee skill attribute (number field).
local rsSTART = listNode.getChild("rsBASE").getValue(); -- Starting point for Range skill attribute (number field).
local strSTART = listNode.getChild("strBASE").getValue(); -- Starting point for Strength attribute (number field).
local touSTART = listNode.getChild("touBASE").getValue(); -- Starting point for Toughness attribute (number field).
local agiSTART = listNode.getChild("agiBASE").getValue(): -- Starting point for Agility attribute (number field).
local perSTART = listNode.getChild("perBASE").getValue(); -- Starting point for Perception attribute (number field).
local intSTART = listNode.getChild("intBASE").getValue(); -- Starting point for Intelligence attribute (number field).
local logSTART = listNode.getChild("perBASE").getValue(); -- Starting point for Logic attribute (number field).
local disSTART = lsitNode.getChild("disBASE").getValue(); -- Starting point for Discipline attribute (number field).
local amiSTART = listNode.getChild("amiBASE").getValue(); -- Starting point for Amity attribute (number field).
nodeWin.getChild("raceDST").setValue(raceNAME); -- This copies the playable race name.
nodeWin.getChild("hpSRT").setValue(hpSTART); -- This copies the starting points for health.
nodeWin.getChild("msRACE").setValue(msSTART); -- This copies starting value Melee skill attribute.
nodeWin.getChild("rsRACE").setValue(rsSTART); -- This copies starting value Range skill attribute.
nodeWin.getChild("strRACE").setValue(strSTART); -- This copies starting value Strength attribute.
nodeWin.getChild("touRACE").setValue(touSTART); -- This copies starting value Toughness attribute.
nodeWin.getChild("agiRACE").setValue(agiSTART); -- This copies starting value Agility attribute.
nodeWin.getChild("perRACE").setValue(perSTART); -- This copies starting value Perception attribute.
nodeWin.getChild("intRACE").setValue(intSTART); -- This copies starting value Intelligence attribute.
nodeWin.getChild("logRACE").setValue(logSTART); -- This copies starting value Logic attribute.
nodeWin.getChild("disRACE").setValue(disRACE); -- This copies starting value Discipline attribute.
nodeWin.getChild("amiRACE").setValue(amiRACE); -- This copies starting value Amity attribute.
end