Advertisement
epitaque_

Untitled

Sep 13th, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. -- Problem: nothing is printing even though I have a function that prints something and is fired whenever a nettable is changed
  2.  
  3. -- Nettable File: herolinewars\scripts\custom_net_tables.txt
  4. <!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
  5. {
  6.     custom_net_tables =
  7.     [
  8.         "income"
  9.     ]
  10. }
  11.  
  12. -- Lua code
  13. CustomNetTables:SetTableValue( "income", tostring(playerID), { gold=GameMode.PlayerIncomes[playerID] } );
  14.  
  15. -- Javascript code to set callback
  16. CustomNetTables.SubscribeNetTableListener("income", OnTableChanged);
  17.  
  18. -- OnTableChanged Javascript function
  19. function OnTableChanged(table_name, key, data)
  20. {
  21.     $.Msg("The income nettable has changed. Table_name: " + table_name + "PlayerID: " + key + ", gold: " + data.gold);
  22.     if(table_name != "income")
  23.     {
  24.         $.Msg("Returning because it isnt the Income nettable.");
  25.         return;
  26.     }
  27.     var panel = $("#Player_" + key + "_" + "Gold");
  28.    
  29.     $.Msg("panel = " + panel)
  30.    
  31.     if(panel === undefined)
  32.     {
  33.         $.Msg("Panel is undefined, adding a new player.");
  34.         AddPlayer({PlayerID: key});
  35.     }
  36.     panel.text = Math.round10(data.gold, -2);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement