Created
February 8, 2016 20:07
-
-
Save meepen/421640b80568c51eb5f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(SERVER) then | |
net.Receive("weapon_smg1", function(len, cl) | |
local which = net.ReadUInt(4); | |
local t = net.ReadTable(); | |
local a = function(bool, msg) | |
if(not bool) then print(msg or "assertion failed"); debug.Trace(); end | |
end | |
print(which); | |
PrintTable(t); | |
print(len / 8); | |
if(which == 0) then | |
a(t.t == t); | |
a(t[1] == "a"); | |
a(t[2] == "b"); | |
a(t[3] == true); | |
a(t[4] == 3.14); | |
a(t[7] == Vector(1,2,3)); | |
a(t[8] == Angle(3,4,2)); | |
a(t.q == Matrix{ { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 } }); | |
a(t.cc == "cc"); | |
elseif(which == 1) then | |
t = t[1]; | |
a(t ~= nil); | |
a(t.t == t); | |
a(t[1] == "a"); | |
a(t[2] == "b"); | |
a(t[3] == true); | |
a(t[4] == 3.14); | |
a(t[7] == Vector(1,2,3)); | |
a(t[8] == Angle(3,4,2)); | |
a(t.q == Matrix{ { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 } }); | |
a(t.cc == "cc"); | |
elseif(which == 2) then | |
for k,v in pairs(t) do | |
assert(k == v, tostring(k) .. " ~= " .. tostring(v)); | |
end | |
end | |
print"\n" | |
end) | |
else | |
local t = {}; | |
t.t = t; | |
t[1] = "a" | |
t[2] = "b"; | |
t[3] = true; | |
t[4] = 3.14; | |
t[7] = Vector(1,2,3); | |
t[8] = Angle(3,4,2); | |
t.q = Matrix{ { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 } }; | |
t.cc = "cc"; | |
print(t.q); | |
print("recursive1", pcall(function() | |
net.Start"weapon_smg1" | |
net.WriteUInt(0, 4); | |
net.WriteTable(t); | |
net.SendToServer() | |
end)); | |
print("recursive2", pcall(function() | |
net.Start"weapon_smg1" | |
net.WriteUInt(1, 4); | |
net.WriteTable{t} | |
net.SendToServer(); | |
end)); | |
print("2=2", pcall(function() | |
net.Start"weapon_smg1" | |
net.WriteUInt(2, 4); | |
net.WriteTable{[2] = 2, [3] = 3, [4.14141414] = 4.14141414}; | |
net.SendToServer(); | |
end)); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment