-
April 23rd, 2025, 02:22 #1
Could use some help with my LUA Scrip code
Hello everyone,
I'm working on creating a rule set using the Ruleset wizard for the XML part, but I'm having an issue with my LUA script. So I have a window where my players will be able to create custom spells for my game system, and this window facilitates that part.
So I'm trying to do it mechanically, when the player clicks a checkbox for the "random turns" line of the window, the Lua script takes the value of -8 from one number field and places it in the total number field. But I keep getting this error.
Attachment 64130
I am still very unfamiliar with Lua, so I may be missing an elementary step in making this script work.
Attachment 64131
Here is my current script.
function onValueChanged()
local infoGet = window.getDatabaseNode();
local RTcheck = infoGet.getChild("r_t_check").getValue();
local ptsDef= infoGet.getChild("defaul_score").getValue();
local ptsVal = infoGet.getChild("2_base_pts_num_fie").getValue();
local putPTS = infoGet.getChild("2_tol").setValue(ptsVal);
if RTcheck == 0 then
RTcheck = ptsDef
elseif RTcheck == 1 then
RTcheck = ptsVal
end
end
Any insight is welcomed, thank you for your time
-
April 23rd, 2025, 04:31 #2
Let's start by cleaning up the code:
Code:function onValueChanged()
local infoGet = window.getDatabaseNode(); local RTcheck = DB.getValue(infoGet, "r_t_check", ""); -- Not sure of data type but you can change "" to 0 for a nil return local ptsDef= DB.getValue(infoGet, "defaul_score", ""); -- Same as above local ptsVal = DB.getValue(infoGet, "2_base_pts_num_fie", ""); -- Same as above local putPTS = DB.setValue(infoGet, "2_tol", "string", ptsVal);; -- Assuming a string type hereif RTcheck == 0 thenendRTcheck = ptsDefelseif RTcheck == 1 thenRTcheck = ptsValendDominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
-
April 23rd, 2025, 04:33 #3
Also, the discord has a coding_help channel you are free to ask away in and we can help in real time.
https://discord.gg/7y2Fs6yqDominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
-
April 23rd, 2025, 05:52 #4
-
April 28th, 2025, 21:31 #5
I appreciate your help earlier.
I decided to go in a different direction. The player will have a number field where they can insert a number, which will multiply the score. The total is input in another field.
Here is the new error code I'm getting.
error.jpg
This is the code
function onValueChanged()
local nodeWin = window.getDatabaseNode(); -- This is looking up the window
local buyPTS = DB.getValue(nodeWin, "1_buy", 0); -- This is getting the value from the player
local ptsTOT = math.floor(10*buyPTS); -- This is calculating the score value against the player's input
nodeWin.getChild("1_tot").setValue(ptsTOT); -- This is placing the results of the previous line in the "Pts cost" number field
end
Any insight would be helpful.
-
April 28th, 2025, 22:01 #6
nodeWin.getChild("1_tot").setValue(ptsTOT);
-->
DB.setValue(nodeWin, "1_tot", "number", ptsTOT);Last edited by Moon Wizard; April 28th, 2025 at 22:27.
Dominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
-
April 28th, 2025, 22:31 #7
-
April 28th, 2025, 22:54 #8
I would suggest checking out the wiki for more information on using the API's and such for the program
https://fantasygroundsunity.atlassia...s/996644582/DBDominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks