Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Event.lua for develop #1346

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions lua/pac3/core/client/parts/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,122 @@ PART.OldEvents = {
end,
},


is_no_draw = {
callback = function(self, ent)
ent = try_viewmodel(ent)
return ent:GetNoDraw()
end,
},

is_no_target = {
callback = function(self, ent)
ent = try_viewmodel(ent)
return ent:IsFlagSet( FL_NOTARGET )
end,
},


// This is a function to grab any and all network variables and try to run them with the correct type, as it's possible to have GetNWInt("Pac", 1) and "GetNWString("Pac" ValueHere")
// This code is designed to try and run things correctly and detect specific types of Network Variables, Since GetNWVar does not have the varable display in the table, but GetNW2var does.
// It's also useful if a player doesn't know what the displayed function is as a Networked Variable.
WolfKann marked this conversation as resolved.
Show resolved Hide resolved

get_networked = {
arguments = {{name = "string"}, {result = "string"}},
userdata = {{enums = function()
return LocalPlayer():GetNWVarTable()
end}},

callback = function(self, ent, name, result)
ent = try_viewmodel(ent)
local anyvar = ent:GetNWVarTable()[name]

if isstring(anyvar) then
return self:StringOperator(anyvar, result)
elseif isnumber(anyvar) then
return self:NumberOperator(anyvar, tonumber(result) or 0)
elseif isbool(anyvar) then
return anyvar == tobool(result)
end
end,
},

//These are left in so that if a player knows what a variable is as a network, they can manually and directly get it
//In the rare event the operation above has two of the same named variabels (which is rare and stupid, but can happen, so it's better to nip it in the butt instead of trying to argue over it.)

get_networked_string = {
arguments = {{name = "string"}, {result = "string"}},
userdata = {{enums = function()
local base_tbl = LocalPlayer():GetNWVarTable()
local enum_tbl = {}
for k,v in pairs(base_tbl) do
if isstring(v) then
enum_tbl[k] = k
end
end
return enum_tbl
end}},
callback = function(self, ent, name, result)
ent = try_viewmodel(ent)
return self:StringOperator(ent:GetNWString(tostring(name)), tostring(result))
end,
},

get_networked_int = {
arguments = {{name = "string"}, {num = "number"}},
userdata = {{enums = function()
local base_tbl = LocalPlayer():GetNWVarTable()
local enum_tbl = {}
for k,v in pairs(base_tbl) do
if isnumber(v) then
enum_tbl[k] = k
end
end
return enum_tbl
end}},
callback = function(self, ent, name, num)
ent = try_viewmodel(ent)
return self:NumberOperator(ent:GetNWInt(tostring(name)), tonumber(num))
end,
},

get_networked_bool = {
arguments = {{name = "string"}, {bool = "string"}},
userdata = {{enums = function()
local base_tbl = LocalPlayer():GetNWVarTable()
local enum_tbl = {}
for k,v in pairs(base_tbl) do
if isbool(v) then
enum_tbl[k] = k
end
end
return enum_tbl
end}},
callback = function(self, ent, name, bool)
ent = try_viewmodel(ent)
return ent:GetNWBool(tostring(name)) == tobool(bool)
end,
},

get_networked_float = {
arguments = {{name = "string"}, {float = "number"}},
userdata = {{enums = function()
local base_tbl = LocalPlayer():GetNWVarTable()
local enum_tbl = {}
for k,v in pairs(base_tbl) do
if isnumber(v) then
enum_tbl[k] = k
end
end
return enum_tbl
end}},
callback = function(self, ent, name, float)
ent = try_viewmodel(ent)
return self:NumberOperator(ent:GetNWFloat(tostring(name)), tonumber(float))
end,
},


client_spawned = {
operator_type = "number", preferred_operator = "below",
tutorial_explanation = "client_spawned supposedly activates for some time after you spawn",
Expand Down
Loading