meathome
May 7th, 2010, 13:55
Hi again, I am beginning to fell bad about posting so many questions...
I have discovered a strange problem.
When the charactersheet is open in the gm-s window and the players window and either one of them clicks on the checkboxes too fast then the values become desynchronised
I have 1 numberfield with the following code and 4 checkboxes.
The checkboxes are added as datasources and the intetion is to add or remove 5 points to the numberfield.
When I test it on my own machine everything works fine, but when testing it with a remote player I get the desynchronisation errors... After a few tries the values in the numberfield dont match anymore and I have no idea why or how I can solve this.
Here is the code:
local trainingCount;
function onInit()
addSource("trained1");
addSource("trained2");
addSource("trained3");
addSource("trained4");
trainingCount=0;
trainingCount=sources["trained1"].getValue()
+sources["trained2"].getValue()
+sources["trained3"].getValue()
+sources["trained4"].getValue();
if trainingCount~=0 then
setReadOnly(true);
else
setReadOnly(false);
end
end
function onSourceUpdate()
local newCount=0;
newCount=sources["trained1"].getValue()
+sources["trained2"].getValue()
+sources["trained3"].getValue()
+sources["trained4"].getValue();
newCount=newCount-trainingCount;
if newCount~=0 then
setValue(getValue()+newCount*5);
trainingCount=trainingCount+newCount;
end
if trainingCount~=0 then
setReadOnly(true);
else
setReadOnly(false);
end
end
function onValueChanged()
playerId=window.getDatabaseNode().getParent().getP arent().getName();
sNode="charsheet." .. playerId .. ".skills"
tSkills=DB.findNode(sNode).getChildren();
for k, w in pairs(tSkills) do
if w.getChild("stat").getValue()==window.label.getValue() then
w.getChild("stat").setValue(window.label.getValue());
end
end
return true;
end
Thanks for any help
I have discovered a strange problem.
When the charactersheet is open in the gm-s window and the players window and either one of them clicks on the checkboxes too fast then the values become desynchronised
I have 1 numberfield with the following code and 4 checkboxes.
The checkboxes are added as datasources and the intetion is to add or remove 5 points to the numberfield.
When I test it on my own machine everything works fine, but when testing it with a remote player I get the desynchronisation errors... After a few tries the values in the numberfield dont match anymore and I have no idea why or how I can solve this.
Here is the code:
local trainingCount;
function onInit()
addSource("trained1");
addSource("trained2");
addSource("trained3");
addSource("trained4");
trainingCount=0;
trainingCount=sources["trained1"].getValue()
+sources["trained2"].getValue()
+sources["trained3"].getValue()
+sources["trained4"].getValue();
if trainingCount~=0 then
setReadOnly(true);
else
setReadOnly(false);
end
end
function onSourceUpdate()
local newCount=0;
newCount=sources["trained1"].getValue()
+sources["trained2"].getValue()
+sources["trained3"].getValue()
+sources["trained4"].getValue();
newCount=newCount-trainingCount;
if newCount~=0 then
setValue(getValue()+newCount*5);
trainingCount=trainingCount+newCount;
end
if trainingCount~=0 then
setReadOnly(true);
else
setReadOnly(false);
end
end
function onValueChanged()
playerId=window.getDatabaseNode().getParent().getP arent().getName();
sNode="charsheet." .. playerId .. ".skills"
tSkills=DB.findNode(sNode).getChildren();
for k, w in pairs(tSkills) do
if w.getChild("stat").getValue()==window.label.getValue() then
w.getChild("stat").setValue(window.label.getValue());
end
end
return true;
end
Thanks for any help