Entity:GetInternalVariable
Description
An interface for accessing internal key values on entities.
See Entity:GetSaveTable for a more detailed explanation. See Entity:SetSaveValue for the opposite of this function.
Arguments
Returns
Example
Get how long it has been since the player was damaged.
local meta = FindMetaTable( "Player" )
function meta:GetLastDamageTime()
return self:GetInternalVariable( "m_flLastDamageTime" )
end
print( Entity( 1 ):GetLastDamageTime() )
Output:
-31.965000152588
Example
Determine if a door is locked or not (server side).
Output: Returns
true
if the door is locked.Example
Determines whether the door is open or not (server side).
function DoorIsOpen( door )
local doorClass = door:GetClass()
if ( doorClass == "func_door" or doorClass == "func_door_rotating" ) then
return door:GetInternalVariable( "m_toggle_state" ) == 0
elseif ( doorClass == "prop_door_rotating" ) then
return door:GetInternalVariable( "m_eDoorState" ) ~= 0
else
return false
end
end
Output: Returns
true
if the door is open.