attempt to index value 'BaseClass'

I have an entity, i set it’s base:


ENT.Base = "base_gmodentity"

the base_gmodentity is another entity, it’s like the one from sandbox, but i just copied it, 'couz i don’t want to derive from sandbox just because one entity.

Everything works for me, but for other players not:

but they see a shadow of entity if they turn flashlight on.

base_gmodentity’s init.lua does send client side files:


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

I don’t get it, whats wrong?

I’m not sure, but base_gmodentity may use things specific to sandbox.

Try using base_anim and see what the results are.

Make sure you include cl_init and shared unique to your ENT at the top of its code.

Sandbox is not involved here.

I do.

Show us all your code.

**
base_gmodentity**
init.lua

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include('shared.lua')

shared.lua



ENT.Type = "anim"
ENT.Base = "base_anim"

ENT.PrintName		= ""
ENT.Author			= ""
ENT.Contact			= ""
ENT.Purpose			= ""
ENT.Instructions	= ""

ENT.Spawnable			= false
ENT.AdminSpawnable		= false



function ENT:SetOverlayText( text )
	self:SetNetworkedString( "GModOverlayText", text )
end

function ENT:GetOverlayText()

	local txt = self:GetNetworkedString( "GModOverlayText" )
	
	if ( txt == "" ) then
		return ""
	end
	
	if ( SinglePlayer() ) then
		return txt
	end

	local PlayerName = self:GetPlayerName()

	return txt .. "
(" .. PlayerName .. ")"
	
end



function ENT:SetPlayer( ply )

	self:SetVar( "Founder", ply )
	self:SetVar( "FounderIndex", ply:UniqueID() )
	
	self:SetNetworkedString( "FounderName", ply:Nick() )
	
end

function ENT:GetPlayer()

	return self:GetVar( "Founder", NULL )
	
end

function ENT:GetPlayerIndex()

	return self:GetVar( "FounderIndex", 0 )
	
end

function ENT:GetPlayerName()

	local ply = self:GetPlayer()
	if ( ply != NULL ) then
		return ply:Nick()
	end

	return self:GetNetworkedString( "FounderName" )
	
end

cl_init.lua

include('shared.lua')

surface.CreateFont( "coolvetica", 64, 500, true, false, "SandboxLabel" )

ENT.LabelColor = Color( 255, 255, 255, 255 )


// Default Draw Routine..
function ENT:Draw( bDontDrawModel )

	if ( LocalPlayer():GetEyeTrace().Entity == self.Entity && 
	     EyePos():Distance( self:GetPos() ) < 256 ) then
	
		if ( self.RenderGroup == RENDERGROUP_OPAQUE ) then
			self.OldRenderGroup = self.RenderGroup
			self.RenderGroup = RENDERGROUP_TRANSLUCENT
		end

		if ( self:GetOverlayText() != "" ) then
			AddWorldTip( self:EntIndex(), self:GetOverlayText(), 0.5, self:GetPos(), self.Entity  )
		end

	else
	
		if ( self.OldRenderGroup != nil ) then
		
			self.RenderGroup = self.OldRenderGroup
			self.OldRenderGroup = nil
		
		end
	
	end

	if ( !bDontDrawModel ) then self:DrawModel() end
	
end

function ENT:DrawTranslucent( bDontDrawModel )

	if ( bDontDrawModel ) then return end
	
	if (  LocalPlayer():GetEyeTrace().Entity == self.Entity && 
		  EyePos():Distance( self:GetPos() ) < 256 ) then
	
		self:DrawEntityOutline( 1 )
		
	end
	
	self:Draw()

end

function ENT:DrawOverlayText()
	
	if ( !self:SetLabelVariables() ) then return end
	
	self:DrawLabel()

end

function ENT:DrawFlatLabel( size )

	local TargetAngle 	= self:GetAngles()
	local TargetPos 	= self:GetPos() - TargetAngle:Forward() * 16
	
	TargetAngle:RotateAroundAxis( TargetAngle:Up(), 90 )
	
	cam.Start3D2D( TargetPos, TargetAngle, 0.05 * size * self.LabelScale )
	
		local Shadow = Color( 0, 0, 0, self.LabelAlpha * 255 )
		draw.DrawText( self.LabelText, self.LabelFont,  3,  3, Shadow, TEXT_ALIGN_CENTER )

		self.LabelColor.a = self.LabelAlpha * 255
		draw.DrawText( self.LabelText, self.LabelFont, 0, 0, self.LabelColor, TEXT_ALIGN_CENTER )
		
	cam.End3D2D()

end

function ENT:SetLabelVariables()

	// Override this to set the label position, return true to draw and false to not draw.
	
	self.LabelText = self:GetOverlayText()
	if ( self.LabelText == "" ) then return false end
	
	// Only draw if so close
	self.LabelDistance = EyePos():Distance( self:GetPos() )
	if ( self.LabelDistance > 256 ) then return false end
		
	// Which way should our quad face
	self.LabelAngles = self:GetAngles()
	self.LabelAngles:RotateAroundAxis( self.LabelAngles:Right(), 90 )
	
	// Make sure we're standing in front of it (so we can see it)
	local ViewNormal = EyePos() - self:GetPos()
	ViewNormal:Normalize()
	local ViewDot = ViewNormal:Dot( self.LabelAngles:Forward() )
	if ( ViewDot < 0 ) then return false end
	
	// Set the label position
	self.LabelPos = self:GetPos() + self.LabelAngles:Forward() + self.LabelAngles:Up() * 4
	
	// Alpha
	self.LabelAlpha = (1 - self.LabelDistance / 256)^0.4
	
	self.LabelFont 	= "SandboxLabel"
	self.LabelScale = 1
	
	return true

end


local matOutlineWhite 	= Material( "white_outline" )
local ScaleNormal		= Vector()
local ScaleOutline1		= Vector() * 1.05
local ScaleOutline2		= Vector() * 1.1
local matOutlineBlack 	= Material( "black_outline" )

function ENT:DrawEntityOutline( size )
	
	size = size or 1.0
	render.SuppressEngineLighting( true )
	render.SetAmbientLight( 1, 1, 1 )
	render.SetColorModulation( 1, 1, 1 )
	
		// First Outline	
		self:SetModelScale( ScaleOutline2 * size )
		SetMaterialOverride( matOutlineBlack )
		self:DrawModel()
		
		
		// Second Outline
		self:SetModelScale( ScaleOutline1 * size )
		SetMaterialOverride( matOutlineWhite )
		self:DrawModel()
		
		// Revert everything back to how it should be
		SetMaterialOverride( nil )
		self:SetModelScale( ScaleNormal )
		
	render.SuppressEngineLighting( false )
	
	local r, g, b = self:GetColor()
	render.SetColorModulation( r/255, g/255, b/255 )

end

mat_ore entity (the one who doesn’t work)

cl_init.lua

include('shared.lua')
 

function ENT:Draw()
    self.BaseClass.Draw(self)  
end

init.lua

AddCSLuaFile( "cl_init.lua" ) 
AddCSLuaFile( "shared.lua" )  
 
include('shared.lua')
 
local ent = "mat_ore"
 
function ENT:SpawnFunction(ply, tr) -- Spawn function needed to make it appear on the spawn menu
	if (!tr.HitWorld) then return end
 
	ent = ents.Create("mat_ore") -- Create the entity
	ent:SetPos(tr.HitPos + Vector(0, 0, 50)) -- Set it to spawn 50 units over the spot you aim at when spawning it
	ent:Spawn() -- Spawn it
 
	return ent -- You need to return the entity to make it work
end
 
function ENT:Initialize()
 
	self:SetModel( "models/Items/CrossbowRounds.mdl" )
	self:PhysicsInit( SOLID_VPHYSICS )      
	self:SetMoveType( MOVETYPE_VPHYSICS )   
	self:SetSolid( SOLID_VPHYSICS )       
	self:SetUseType(SIMPLE_USE)  
 
	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
end
 
function ENT:Use( activator, caller )
	if ( !activator:IsPlayer() ) then return end
	if (PickUp(activator,ent)) then
		self.Entity:Remove()
	end
end
 
function ENT:Think()

end
 

shared.lua

ENT.Type 			= "anim"
ENT.Base 			= "base_gmodentity"
 
ENT.PrintName		= "Ore."
ENT.Author			= "Fobaz"
ENT.Contact			= ""
ENT.Purpose			= "Smelt it to metal."
ENT.Instructions		= "Smelt it."

ENT.Spawnable		= false
ENT.AdminSpawnable	= false


local ent = “mat_ore”

No need for that line. And there is no need to remake base_gmodentity.

local ent = “mat_ore”

I use this string in Use function, it’s just there, because i just copy/paste one entity and change model, the line above and few other lines.

I’m remaking base_gmodentity because I’m not deriving from sandbox, and I’ll add more to it.

You can’t use a string as an entity.

I don’t.

 if (PickUp(activator,ent)) then  

PickUp writes the string ent to database. It’s just a class of entity.

Anyone?