Last active
August 29, 2015 14:20
-
-
Save OmegaExtern/3e4c3efcfa9b2282fcea to your computer and use it in GitHub Desktop.
Incomplete solution for http://facepunch.com/showthread.php?t=1463733
This file contains hidden or 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
-- Run this on server, not client-side! | |
if not SERVER then | |
error('Run this on the server-side (lua_openscript)!') | |
end | |
-- Find all "func_breakable" entities, and store the result into local "func_breakables" variable. | |
local func_breakables = ents.FindByClass('func_breakable') | |
if #func_breakables < 1 then | |
-- Throws an error if none were founded. | |
error('No "func_breakable" entities were founded.') | |
end | |
-- Adds a function callback for each "func_breakable" entity in the game. | |
for k, v in pairs(func_breakables) do | |
v:AddCallback('PhysicsCollide', function(ent, data) | |
print(ent) | |
PrintTable(data) | |
if not IsValid(ent) or not IsValid(data.HitEntity) or not ent:IsPlayer() then | |
return | |
end | |
-- Do not use "v" here, instead use "data.HitEntity" which is the entity that ent is colliding with. | |
-- Assuming you have called your Player metamethod "CanPassThroughFuncBreakables", which returns either true or false. | |
-- ent is a collidee (it should be the player). | |
data.HitEntity:SetNotSolid(ent:CanPassThroughFuncBreakables()) | |
end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment