STAR TREK 2d20
  1. #1

    Synch Database between host and client

    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:

    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>
    "A saint does what is right. A leader does what is necessary."

  2. #2
    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:

    Code:
    			<hs name="noderef">
    				<script>
    					function onValueChanged()
    						window.onRefChanged();
    					end
    				</script>
    			</hs>
    Regards,
    JPG

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    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:

    Code:
    			<hs name="noderef">
    				<script>
    					function onValueChanged()
    						window.onRefChanged();
    					end
    				</script>
    			</hs>
    Regards,
    JPG
    Thank you very much! That was exactly what i needed!
    "A saint does what is right. A leader does what is necessary."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
FG Spreadshirt Swag

Log in

Log in