Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Problem: nothing is printing even though I have a function that prints something and is fired whenever a nettable is changed
- -- Nettable File: herolinewars\scripts\custom_net_tables.txt
- <!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
- {
- custom_net_tables =
- [
- "income"
- ]
- }
- -- Lua code
- CustomNetTables:SetTableValue( "income", tostring(playerID), { gold=GameMode.PlayerIncomes[playerID] } );
- -- Javascript code to set callback
- CustomNetTables.SubscribeNetTableListener("income", OnTableChanged);
- -- OnTableChanged Javascript function
- function OnTableChanged(table_name, key, data)
- {
- $.Msg("The income nettable has changed. Table_name: " + table_name + "PlayerID: " + key + ", gold: " + data.gold);
- if(table_name != "income")
- {
- $.Msg("Returning because it isnt the Income nettable.");
- return;
- }
- var panel = $("#Player_" + key + "_" + "Gold");
- $.Msg("panel = " + panel)
- if(panel === undefined)
- {
- $.Msg("Panel is undefined, adding a new player.");
- AddPlayer({PlayerID: key});
- }
- panel.text = Math.round10(data.gold, -2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement