View Full Version : Coding problem
Grimmbart
May 6th, 2009, 17:57
Hi
I'm making my first ruleset ans i'have a question :
I create some numberfields like this one (under)
<numberfield name="intelligence_value">
<bounds rect="245,106,24,16" />
<font name="smallcontrol" />
<hideonvalue value="0" />
<description field="intelligence_name" />
<tabtarget>
<next>str_value</next>
<prev>intelligence_name</prev>
</tabtarget>
</numberfield>
Now, i want to create another numberfield, but not editable and with the value " 'intelligence_value' * 2".
How can i do this ?
Help
Ikael
May 6th, 2009, 19:27
make another numberfield that has tag
<readonly/>
which sets it to be not-editable
the new numberfield should also have following script:
<script>
function onInit()
int = window.getDatabaseNode().createChild("intelligence_value");
int.onUpdate() = updateValue;
end
function updateValue()
setValue(window.intelligence_value.getValue()*2)
end
</script>
Which makes the new numberfield have value double the intelligence_value.
Grimmbart
May 6th, 2009, 21:07
Thank's, but your script do nothing !!
With this script, the value on screen is OK, but when i update the "intelligence_value", my local control is not updated !!
<numbercontrol name="charge" >
<font name="smallcontrol" />
<bounds rect="513,644,24,16" />
<nodrag />
<nodrop />
<noreset />
<nokeyedit />
<readonly / >
<script>
function init()
local int = window.getDatabaseNode().getChild("intelligence_value").getValue();
setValue(int);end
</script>
</numbercontrol>
Help !!!!!
Grimmbart
May 7th, 2009, 09:57
The first Nuberfield
<numberfield name="Force_valeur" >
<bounds rect="86,226,24,16" />
<font name="smallcontrol" />
<hideonvalue value="0" />
<description field="Force_nom" />
<tabtarget> <next>Charisme_valeur</next> <prev>Dexterite_valeur</prev></tabtarget>
</numberfield>
And here the second field
<stringcontrol name="chargelegere" >
<font name="smallcontrol" />
<bounds rect="110,636,70,16" />
<nodrag />
<nodrop />
<noreset />
<nokeyedit />
<readonly />
<tooltip><text>Valeur de Charge Légère</text></tooltip>
<script>
function update()
local force = window.getDatabaseNode().getChild("Force_valeur").getValue();
local charge = "1kg";
if force == 0 then
charge = "Lavette";
elseif force == 1 then
charge = "0...5 kg";
elseif force == 2 then
charge = "0...12 kg";
elseif force == 3 then
charge = "0...25 kg";
elseif force == 4 then
charge = "0...50 kg";
elseif force == 5 then
charge = "0...125 kg";
else
charge = "Waouuu !";
end
setValue(charge);
end
function onInit()
local force = window.getDatabaseNode().createChild("Force_valeur", "number");
force.onUpdate = update;
update();
end
</script>
</stringcontrol>
And now, it's OK !!
Ikael
May 7th, 2009, 10:12
Sorry I forgot the the createChild() function requires to have variable type as second parameter.
int = window.getDatabaseNode().createChild("intelligence_value", "number");
is the correct function calling
Valarian
May 7th, 2009, 12:24
Instead of a basic numberfield, you could also use the sources attribute of the modifiernumber template (common_templates). For example: Armour Class in the 3.5e extension (or d20 ruleset).
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.