augustgames
March 27th, 2024, 02:20
So I am still learning and playing and I wanted to make a calculation of one field affect another. I used onValue change for strength_value. This works PERFECTLY.
function onValueChanged()
local sPwr = getDatabaseNode().getParent().getChild("pwr_value").getValue()
local sStr = getDatabaseNode().getParent().getChild("strength_value").getValue()
-- strength_value sStr
if sStr >= 1 and sStr <= 3 then getDatabaseNode().getParent().getChild("str_mod").setValue(-4 + sPwr)
elseif sStr >= 4 and sStr <= 5 then getDatabaseNode().getParent().getChild("str_mod").setValue(-3 + sPwr)
elseif sStr >= 6 and sStr <= 7 then getDatabaseNode().getParent().getChild("str_mod").setValue(-2 + sPwr)
elseif sStr >= 8 and sStr <= 9 then getDatabaseNode().getParent().getChild("str_mod").setValue(-1 + sPwr)
elseif sStr >= 10 and sStr <= 11 then getDatabaseNode().getParent().getChild("str_mod").setValue(0 + sPwr)
elseif sStr >= 12 and sStr <= 13 then getDatabaseNode().getParent().getChild("str_mod").setValue(1 + sPwr)
elseif sStr >= 14 and sStr <= 15 then getDatabaseNode().getParent().getChild("str_mod").setValue(2 + sPwr)
elseif sStr >= 16 and sStr <= 17 then getDatabaseNode().getParent().getChild("str_mod").setValue(3 + sPwr)
elseif sStr >= 18 and sStr <= 19 then getDatabaseNode().getParent().getChild("str_mod").setValue(4 + sPwr)
elseif sStr >= 20 and sStr <= 21 then getDatabaseNode().getParent().getChild("str_mod").setValue(5 + sPwr)
elseif sStr >= 22 and sStr <= 23 then getDatabaseNode().getParent().getChild("str_mod").setValue(6 + sPwr)
elseif sStr >= 24 and sStr <= 25 then getDatabaseNode().getParent().getChild("str_mod").setValue(7 + sPwr)
end
end
However, if I run the same code on the same page and run it from a button (+-) in pic 60384 I get an error that says "[3/26/2024 6:16:08 PM] [ERROR] Script execution error: [string "C:charsheet_main:update_stat"]:3: attempt to index a nil value". I have tried to research this with no answer. Idea?
function onButtonPress()
local sPwr = getDatabaseNode().getParent().getChild("pwr_value").getValue()
local sStr = getDatabaseNode().getParent().getChild("strength_value").getValue()
-- strength_value sStr
if sStr >= 1 and sStr <= 3 then getDatabaseNode().getParent().getChild("str_mod").setValue(-4 + sPwr)
elseif sStr >= 4 and sStr <= 5 then getDatabaseNode().getParent().getChild("str_mod").setValue(-3 + sPwr)
elseif sStr >= 6 and sStr <= 7 then getDatabaseNode().getParent().getChild("str_mod").setValue(-2 + sPwr)
elseif sStr >= 8 and sStr <= 9 then getDatabaseNode().getParent().getChild("str_mod").setValue(-1 + sPwr)
elseif sStr >= 10 and sStr <= 11 then getDatabaseNode().getParent().getChild("str_mod").setValue(0 + sPwr)
elseif sStr >= 12 and sStr <= 13 then getDatabaseNode().getParent().getChild("str_mod").setValue(1 + sPwr)
elseif sStr >= 14 and sStr <= 15 then getDatabaseNode().getParent().getChild("str_mod").setValue(2 + sPwr)
elseif sStr >= 16 and sStr <= 17 then getDatabaseNode().getParent().getChild("str_mod").setValue(3 + sPwr)
elseif sStr >= 18 and sStr <= 19 then getDatabaseNode().getParent().getChild("str_mod").setValue(4 + sPwr)
elseif sStr >= 20 and sStr <= 21 then getDatabaseNode().getParent().getChild("str_mod").setValue(5 + sPwr)
elseif sStr >= 22 and sStr <= 23 then getDatabaseNode().getParent().getChild("str_mod").setValue(6 + sPwr)
elseif sStr >= 24 and sStr <= 25 then getDatabaseNode().getParent().getChild("str_mod").setValue(7 + sPwr)
end
end
ignore the space between the v and a in "strength_value". I am not sure why it is showing up that way.
function onValueChanged()
local sPwr = getDatabaseNode().getParent().getChild("pwr_value").getValue()
local sStr = getDatabaseNode().getParent().getChild("strength_value").getValue()
-- strength_value sStr
if sStr >= 1 and sStr <= 3 then getDatabaseNode().getParent().getChild("str_mod").setValue(-4 + sPwr)
elseif sStr >= 4 and sStr <= 5 then getDatabaseNode().getParent().getChild("str_mod").setValue(-3 + sPwr)
elseif sStr >= 6 and sStr <= 7 then getDatabaseNode().getParent().getChild("str_mod").setValue(-2 + sPwr)
elseif sStr >= 8 and sStr <= 9 then getDatabaseNode().getParent().getChild("str_mod").setValue(-1 + sPwr)
elseif sStr >= 10 and sStr <= 11 then getDatabaseNode().getParent().getChild("str_mod").setValue(0 + sPwr)
elseif sStr >= 12 and sStr <= 13 then getDatabaseNode().getParent().getChild("str_mod").setValue(1 + sPwr)
elseif sStr >= 14 and sStr <= 15 then getDatabaseNode().getParent().getChild("str_mod").setValue(2 + sPwr)
elseif sStr >= 16 and sStr <= 17 then getDatabaseNode().getParent().getChild("str_mod").setValue(3 + sPwr)
elseif sStr >= 18 and sStr <= 19 then getDatabaseNode().getParent().getChild("str_mod").setValue(4 + sPwr)
elseif sStr >= 20 and sStr <= 21 then getDatabaseNode().getParent().getChild("str_mod").setValue(5 + sPwr)
elseif sStr >= 22 and sStr <= 23 then getDatabaseNode().getParent().getChild("str_mod").setValue(6 + sPwr)
elseif sStr >= 24 and sStr <= 25 then getDatabaseNode().getParent().getChild("str_mod").setValue(7 + sPwr)
end
end
However, if I run the same code on the same page and run it from a button (+-) in pic 60384 I get an error that says "[3/26/2024 6:16:08 PM] [ERROR] Script execution error: [string "C:charsheet_main:update_stat"]:3: attempt to index a nil value". I have tried to research this with no answer. Idea?
function onButtonPress()
local sPwr = getDatabaseNode().getParent().getChild("pwr_value").getValue()
local sStr = getDatabaseNode().getParent().getChild("strength_value").getValue()
-- strength_value sStr
if sStr >= 1 and sStr <= 3 then getDatabaseNode().getParent().getChild("str_mod").setValue(-4 + sPwr)
elseif sStr >= 4 and sStr <= 5 then getDatabaseNode().getParent().getChild("str_mod").setValue(-3 + sPwr)
elseif sStr >= 6 and sStr <= 7 then getDatabaseNode().getParent().getChild("str_mod").setValue(-2 + sPwr)
elseif sStr >= 8 and sStr <= 9 then getDatabaseNode().getParent().getChild("str_mod").setValue(-1 + sPwr)
elseif sStr >= 10 and sStr <= 11 then getDatabaseNode().getParent().getChild("str_mod").setValue(0 + sPwr)
elseif sStr >= 12 and sStr <= 13 then getDatabaseNode().getParent().getChild("str_mod").setValue(1 + sPwr)
elseif sStr >= 14 and sStr <= 15 then getDatabaseNode().getParent().getChild("str_mod").setValue(2 + sPwr)
elseif sStr >= 16 and sStr <= 17 then getDatabaseNode().getParent().getChild("str_mod").setValue(3 + sPwr)
elseif sStr >= 18 and sStr <= 19 then getDatabaseNode().getParent().getChild("str_mod").setValue(4 + sPwr)
elseif sStr >= 20 and sStr <= 21 then getDatabaseNode().getParent().getChild("str_mod").setValue(5 + sPwr)
elseif sStr >= 22 and sStr <= 23 then getDatabaseNode().getParent().getChild("str_mod").setValue(6 + sPwr)
elseif sStr >= 24 and sStr <= 25 then getDatabaseNode().getParent().getChild("str_mod").setValue(7 + sPwr)
end
end
ignore the space between the v and a in "strength_value". I am not sure why it is showing up that way.