My first sent, getting these error messages

Any help would be appreciated, and anything you can say about the rest of the code.



entities/car_activator/init.lua:43: function arguments expected near 'local'
Folder	=	entities/car_activator
Couldn't register Scripted Entity car_activator - the Type field is empty!


Here are the init, cl_init and shared files:



AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" )  -- and shared scripts are sent.
 
include('shared.lua')
 
function ENT:SpawnFunction(ply, tr) -- Spawn function needed to make it appear on the spawn menu
	if (!tr.HitWorld) then return end
 
	local ent = ents.Create("Car_activator") -- Create the entity
	ent:SetPos(tr.HitPos + Vector(0, 0, 30)) -- Set it to spawn 50 units over the spot you aim at when spawning it
	ent:Spawn() -- Spawn it

    local  Light = ents.Create("env_sprite")
    Light:SetPos(ent:GetPos())
	Light:SetAngles(ent:GetAngles())
	Light:SetKeyValue("renderfx", 4)
	Light:SetKeyValue("rendermode", 3)
	Light:SetKeyValue("renderamt", "200")

    Light:SetKeyValue("rendercolor", "0 255 0")
    Light:SetKeyValue("model", "sprites/light_glow01.spr")
    Light:SetKeyValue("scale", 1)
	Light:SetKeyValue("glowproxysize", 20)
    Light:Spawn()
	Light:SetParent(ent) 
	
return ent -- You need to return the entity to make it work


end

function ENT:Initialize()
 
    self.SetModel("models/magnusson_device.mdl")
	self.Entity:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
	self.Entity:SetSolid( SOLID_VPHYSICS )         -- Toolbox
 
    local entphys = self.Entity:GetPhysicsObject()
	local p = ent:GetPos()
	local angle = ent:GetAngles()
	local yaw = ent:GetAngles():y
	local clk = false
	if entphys:IsValid() then
	entphys:EnableGravity(false);
		entphys:Wake()
		entphys:SetMass(1);
	end

	

end
 

 function ent:StartTouch( veh )
 	if ( veh:IsValid() and veh:IsVehicle() ) then
 	local weld = constraint.Weld(veh,ent,0,0,0,false)
	end
 end
 
 function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
 weld:Remove()

 end
 end
 -- Here's where the fun begins!
 function ENT:Think()
if(driver:IsValid()) then
 	if (driver:KeyDown(IN_ATTACK2)) then
	local clk = not clk
	end

 if (clk == true) then
 veh:SetAngle(Angle(0,yaw,0))
 veh:SetPos(p)
 
	local driver = veh.GetDriver())
	if (driver:KeyDown(IN_FORWARD)) then
	p = p+veh:GetForward()
	end
	
	if (driver:KeyDown(IN_RUN)) then
	local p = p+veh:GetForward()*10
	end
	
	if (driver:KeyDown(IN_BACK)) then
	local p = p-veh:GetForward()
	end
	
	if (driver:KeyDown(IN_MOVELEFT)) then
	local yaw = yaw+1
	end
	
	if (driver:KeyDown(IN_MOVERIGHT)) then
	local yaw = yaw-1
	end

	if (driver:KeyDown(IN_JUMP)) then
	local p = p+Vector(0,0,1)
	end
	
	if (driver:KeyDown(IN_ALT1)) then
	local p = p-Vector(0,0,1)
	end

 else 
 
 local p = veh:GetPos()+Vector(0,0,30)
 local yaw = veh:GetAngles():y
 
 end
 end
end




include('shared.lua')
 
--[[---------------------------------------------------------
   Name: Draw
   Purpose: Draw the model in-game.
   Remember, the things you render first will be underneath!
---------------------------------------------------------]]
function ENT:Draw()
    -- self.BaseClass.Draw(self)  -- We want to override rendering, so don't call baseclass.
                                  -- Use this when you need to add to the rendering.
    self:DrawEntityOutline( 1.0 ) -- Draw an outline of 1 world unit.
    self.Entity:DrawModel()       -- Draw the model.
 
end





 
ENT.Type = "Cool Shit"
ENT.Base = "base_gmodentity"
 
ENT.PrintName		= "Car Controller"
ENT.Author			= "Iskuri"
ENT.Contact			= ""
ENT.Purpose			= ""
ENT.Instructions	= ""




local yaw = ent:GetAngles():y

y is a part of the Angle table, it is not a function you call on the angle. Thus, it should look like:


local yaw = ent:GetAngles().y

OK, thanks, I didn’t realise that. Can you help me with my other issues?

Which are… ?

Oh, um… ENT.Type is not a valid field. Don’t use it.

I think you’re looking for “ENT.Category”.

Oh OK, thanks very much. I appreciate all of this help a lot! Do you know why the first function cannot find the end like it says in the error?

Both solutions I suggested should solve both of your errors that you posted.

OK, thank you very much Entoros.

[editline]07:22PM[/editline]

I am now getting this error message when I spawn:

entities/car_activator/init.lua:55: attempt to index global ‘ent’ (a nil value)

and then when I spawn the sent the model is invisible and I get hit with this repeatedly:

entities/car_activator/init.lua:34: bad argument #1 to ‘SetModel’ (Entity expected, got string)
entities/car_activator/cl_init.lua:11: attempt to call method ‘DrawEntityOutline’ (a nil value)

ENT not ent
lua is case sensitive

You call SetModel on an entity object, it’s not part of a library. Correct syntax is:


self:SetModel("modelname")

Also, there is no entity.DrawEntityOutline function. You have to define it if you want to use it.