Ok, enough talking, here is work:
selfaware.lua
+added setColor(r,g,b,a)
~persisted math.clamp, you say its faster

Originally Posted by
Syranide
Sure, as long as the code behaves the same way, I'd say it's a plus.
However, as for using math.ceil, it is way slower, but it seems that if you alias all the math-functions locally (within the file) then the difference is less noticeable and the code readability becomes preferable. I believe we already do this in some extension, vectors I think.
I did exactly that now!
player.lua
only up to line 83, due to the fact that this wount probably get SVN'ed, had talk with mods at IRC.
here is the edited part of user:
Code:
local validEntity = E2Lib.validEntity
local isOwner = E2Lib.isOwner
registerCallback("e2lib_replace_function", function(funcname, func, oldfunc)
if funcname == "isOwner" then
isOwner = func
elseif funcname == "validEntity" then
validEntity = func
end
end)
/******************************************************************************/
__e2setcost(5) -- temporary
e2function number entity:isAdmin()
if not validEntity(this) then return 0 end
if not this:IsPlayer() then return 0 end
if this:IsAdmin() then return 1 else return 0 end
end
e2function number entity:isSuperAdmin()
if not validEntity(this) then return 0 end
if not this:IsPlayer() then return 0 end
if this:IsSuperAdmin() then return 1 else return 0 end
end
/******************************************************************************/
e2function vector entity:shootPos()
if(!validEntity(this)) then return {0,0,0} end
if(this:IsPlayer() or this:IsNPC()) then
return this:GetShootPos()
else return {0,0,0} end
end
e2function vector entity:eye()
if (!validEntity(this)) then return {0,0,0} end
if (this:IsPlayer()) then
return this:GetAimVector()
else
return this:GetForward()
end
end
--- Returns a local angle describing player <this>'s view angles.
e2function angle entity:eyeAngles()
if not validEntity(this) then return { 0, 0, 0} end
local ang = this:EyeAngles()
return { ang.p, ang.y, ang.r }
end
/******************************************************************************/
e2function string entity:name()
if(!validEntity(this)) then return "" end
if(!this:IsPlayer()) then return "" end
return this:Name()
end
e2function string entity:steamID()
if(!validEntity(this)) then return "" end
if(!this:IsPlayer()) then return "" end
return this:SteamID()
end
e2function number entity:armor()
if(!validEntity(this)) then return 0 end
if(this:IsPlayer() or this:IsNPC()) then return this:Armor() else return 0 end
end
/******************************************************************************/
e2function number entity:height()
if(!validEntity(this)) then return 0 end
if(this:IsPlayer() or this:IsNPC()) then
local pos = this:GetPos()
local up = this:GetUp()
return this:NearestPoint(Vector(pos.x+up.x*100,pos.y+up.y*100,pos.z+up.z*100)).z-this:NearestPoint(Vector(pos.x-up.x*100,pos.y-up.y*100,pos.z-up.z*100)).z
else return 0 end
end
Bookmarks