View Full Version : Setting a value in a Readonly numbercontrol
Doswelk
June 13th, 2007, 15:45
I am trying to set some numbers on the character sheet that never change...
The numbercontrol has the following settings:
<nodrop />
<noreset />
<displaysign />
<readonly />
Tried the following but it didn't work:
<script>
function onInit()
if not getValue() then
setvalue(-1)
end
end
</script>
Can anyone help me with what it should be?
joshuha
June 13th, 2007, 16:05
Tried it with a capital V? Sometimes its the little things. Unless its just the copy/paste that's bad.
setValue()
Dachannien
June 13th, 2007, 18:02
It occurs to me, there should be a script error when that script gets executed, since presumably setvalue() isn't defined. But then I checked the Lua reference manual, and in there it says,
"All values different from nil and false are considered true (in particular, the number 0 and the empty string are also true)."
Since a numbercontrol's default value is 0, setvalue(-1) is never reached. But since these are presumably values that aren't set in the database, you don't need the conditional statement anyway.
Doswelk
June 13th, 2007, 19:09
It occurs to me, there should be a script error when that script gets executed, since presumably setvalue() isn't defined. But then I checked the Lua reference manual, and in there it says,
"All values different from nil and false are considered true (in particular, the number 0 and the empty string are also true)."
Since a numbercontrol's default value is 0, setvalue(-1) is never reached. But since these are presumably values that aren't set in the database, you don't need the conditional statement anyway.
I did think that, so I removed the conditional and it still did not work...
However that still probably had the setvalue entry rather than setValue (I'm not near my PC right now to test)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.