PDA

View Full Version : Synch Database between host and client



Alanrockid
August 24th, 2021, 00:37
So...i have this string field where you can drag and drop any text while pressing ctrl and it will change the tooltip of the string field itself.

This changes are stored in the db.xml under the "espec_forca" node, and while it works well for the user making the changes, the other clients/host will only see this when the ruleset is reloaded. How can i make this changes update instantly? I've been trying to use onUpdate() function, but i guess i don't get it very well.

Here's the code:



<script>
function onInit()
local especializacao = window.espec_forca.getValue()

if especializacao == "" then
setTooltipText("Sem Especialização")
else
setTooltipText(especializacao)
end
end

function onDoubleClick(x,y)
local valortmp = window.pontos_forca.getValue()
local dicepool = ChatManager.d10Check(valortmp)
local diff = 6 + ModifierStack.getSum()

ActionsManager.performRoll(nil, nil, "Força", diff, bSecretRoll, dicepool)
end

function onDrop(x,y,dragdata)
local especializacao = window.espec_forca.getValue()

if Input.isControlPressed() then
window.espec_forca.setValue("Especialização: " .. dragdata.getStringData())
setTooltipText(window.espec_forca.getValue())
end
end
</script>

Moon Wizard
August 25th, 2021, 03:52
You need to have a trigger on the "espec_forca" field as well. Maybe a hidden string field with an onValueChanged event function to trigger the update? (This assumes parent node is already public.)

Here's an example from CoreRPG:



<hs name="noderef">
<script>
function onValueChanged()
window.onRefChanged();
end
</script>
</hs>


Regards,
JPG

Alanrockid
August 25th, 2021, 04:32
You need to have a trigger on the "espec_forca" field as well. Maybe a hidden string field with an onValueChanged event function to trigger the update? (This assumes parent node is already public.)

Here's an example from CoreRPG:



<hs name="noderef">
<script>
function onValueChanged()
window.onRefChanged();
end
</script>
</hs>


Regards,
JPG

Thank you very much! That was exactly what i needed! :D