Need help on a lua project

First of all,

  1. these’s files come from the original acf-svn addons. So there was some description about acf :
    -Current list of ACF devs:
    -Kafouille - Author; lost interest in ACF
    -Sestze - coder
    -TGIfallen - coder
    -Lazermaniac - Modeller/texturer
    -Amplar - Sound/balance/tuning
  2. I’m not a english man, so i can misspelling, but if you understand this text, you will understand the text bellow.
  3. My project are to make “engine chips” for acf engine, that mean to add a complete new entity with a chip models and can be wired to the engine. When I active the chip, i want the chip increase the engine Torque / engine Max rpm / engine Limit rpm.
  4. All from acfmenu ( in Q menu ) are done, I see my new chips menu under “mobility”
  5. I ask help to make working the init.lua file from “lua/entities/ACF_engine/” and init.lua from “lua/entities/ACF_Chips/”.
  6. I get some trouble to make working the variable “Id2” and the wiremod input/ouput part.
  7. The engine and chips won’t spawn in game with console error : acf Didn’t find entity duplicator records

Here the init.lua from “lua/entities/ACF_engine/”

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

include('shared.lua')

function ENT:Initialize()
	
	self.Throttle = 0
	self.Active = false
	self.IsMaster = true
	self.GearLink = {}
	self.GearRope = {}
	
	self.LastCheck = 0
	self.LastThink = 0
	self.Mass = 0
	self.PhysMass = 0
	self.MassRatio = 1
	self.Legal = true
	self.CanUpdate = true
	
	self:ChipActive = false
	
	self.Inputs = Wire_CreateInputs( self.Entity, { "Active", "Throttle", "ChipActive", "ChipID" } )
	self.Outputs = WireLib.CreateSpecialOutputs( self.Entity, { "RPM", "Torque", "Power", "Entity" , "Mass" , "Physical Mass" }, { "NORMAL" ,"NORMAL" ,"NORMAL" , "ENTITY" , "NORMAL" , "NORMAL" } )
	Wire_TriggerOutput(self.Entity, "Entity", self.Entity)
	self.WireDebugName = "ACF Engine"

end  

function MakeACF_Engine(Owner, Pos, Angle, Id)

	if not Owner:CheckLimit("_acf_misc") then return false end
	
	local Engine = ents.Create("ACF_Engine")
	local List = list.Get("ACFEnts")
	local Classes = list.Get("ACFClasses")
	if not Engine:IsValid() then return false end
	Engine:SetAngles(Angle)
	Engine:SetPos(Pos)
	Engine:Spawn()

	Engine:SetPlayer(Owner)
	Engine.Owner = Owner
	Engine.Id = Id
	Engine.Model = List["Mobility"][Id]["model"]
	Engine.SoundPath = List["Mobility"][Id]["sound"]
	Engine.Weight = List["Mobility"][Id]["weight"]
	Engine.PeakTorque = List["Mobility"][Id]["torque"]
	Engine.IdleRPM = List["Mobility"][Id]["idlerpm"]
	Engine.PeakMinRPM = List["Mobility"][Id]["peakminrpm"]
	Engine.PeakMaxRPM = List["Mobility"][Id]["peakmaxrpm"]
	Engine.LimitRPM = List["Mobility"][Id]["limitprm"]
	Engine.Inertia = List["Mobility"][Id]["flywheelmass"]*(3.1416)^2
	
	Engine.FlyRPM = 0
	Engine:SetModel( Engine.Model )	
	Engine.Sound = nil
	Engine.RPM = {}
	
	Engine:PhysicsInit( SOLID_VPHYSICS )      	
	Engine:SetMoveType( MOVETYPE_VPHYSICS )     	
	Engine:SetSolid( SOLID_VPHYSICS )
	
	Engine.Out = Engine:WorldToLocal(Engine:GetAttachment(Engine:LookupAttachment( "driveshaft" )).Pos)

	local phys = Engine:GetPhysicsObject()  	
	if (phys:IsValid()) then 
		phys:SetMass( Engine.Weight ) 
	end
	
	Engine:SetNetworkedBeamString("Type",List["Mobility"][Id]["name"])
	Engine:SetNetworkedBeamInt("Torque",Engine.PeakTorque)
	Engine:SetNetworkedBeamInt("Power",math.floor(Engine.PeakTorque * Engine.PeakMaxRPM / 9538.8))
	Engine:SetNetworkedBeamInt("MinRPM",Engine.PeakMinRPM)
	Engine:SetNetworkedBeamInt("MaxRPM",Engine.PeakMaxRPM)
	Engine:SetNetworkedBeamInt("LimitRPM",Engine.LimitRPM)
	
	undo.Create("ACF Engine")
		undo.AddEntity( Engine )
		undo.SetPlayer( Owner )
	undo.Finish()
	
	Owner:AddCount("_acf_engine", Engine)
	Owner:AddCleanup( "acfmenu", Engine )
	
	return Engine
end
list.Set( "ACFCvars", "acf_engine" , {"id"} )
duplicator.RegisterEntityClass("acf_engine", MakeACF_Engine, "Pos", "Angle", "Id")

function ENT:Update( ArgsTable )	--That table is the player data, as sorted in the ACFCvars above, with player who shot, and pos and angle of the tool trace inserted at the start
		
	local Feedback = "Engine updated"
	if self.Active then
		Feedback = "Please turn off the engine before updating it"
	return Feedback end
	if ( ArgsTable[1] != self.Owner ) then --Argtable[1] is the player that shot the tool
		Feedback = "You don't own that engine !"
	return Feedback end
	
	local Id = ArgsTable[4]	--Argtable[4] is the engine ID
	local List = list.Get("ACFEnts")
	
	if ( List["Mobility"][Id]["model"] != self.Model ) then --Make sure the models are the sames before doing a changeover
		Feedback = "The new engine needs to have the same model as the old one !"
	return end
		
	self.Id = Id
	self.SoundPath = List["Mobility"][Id]["sound"]
	self.Weight = List["Mobility"][Id]["weight"]
	self.PeakTorque = List["Mobility"][Id]["torque"]
	self.IdleRPM = List["Mobility"][Id]["idlerpm"]
	self.PeakMinRPM = List["Mobility"][Id]["peakminrpm"]
	self.PeakMaxRPM = List["Mobility"][Id]["peakmaxrpm"]
	self.LimitRPM = List["Mobility"][Id]["limitprm"]
	self.Inertia = List["Mobility"][Id]["flywheelmass"]*(3.1416)^2
	
	self:SetModel( self.Model )	
	self:SetSolid( SOLID_VPHYSICS )
	self.Out = self:WorldToLocal(self:GetAttachment(self:LookupAttachment( "driveshaft" )).Pos)

	local phys = self:GetPhysicsObject()  	
	if (phys:IsValid()) then 
		phys:SetMass( self.Weight ) 
	end
	
	self:SetNetworkedBeamString("Type",List["Mobility"][Id]["name"])
	self:SetNetworkedBeamInt("Torque",self.PeakTorque)
	self:SetNetworkedBeamInt("Power",math.floor(self.PeakTorque * self.PeakMaxRPM / 9538.8))
	self:SetNetworkedBeamInt("MinRPM",self.PeakMinRPM)
	self:SetNetworkedBeamInt("MaxRPM",self.PeakMaxRPM)
	self:SetNetworkedBeamInt("LimitRPM",self.LimitRPM)
	
	
	return Feedback
end

function ENT:TriggerInput( iname , value , Id2)
	local Id2 = self.ChipID
	local Id = ArgsTable[4]	--Argtable[4] is the engine ID
	local List = list.Get("ACFEnts")

	if (iname == "Throttle") then
		self.Throttle = math.Clamp(value,0,100)/100
	elseif (iname == "Active") then
		if (value > 0 and not self.Active) then
			self.Active = true
			self.Sound = CreateSound(self, self.SoundPath)
			self.Sound:PlayEx(0.5,100)
			self:ACFInit()
		elseif (value <= 0 and self.Active) then
			self.Active = false
			self.RPM = {}
			self.RPM[1] = self.IdleRPM
			if self.Sound then
				self.Sound:Stop()
			end
			self.Sound = nil
		end
	elseif (iname == "ChipActive") then
		if (value > 0 and not self.ChipActive) then
			self.ChipActive = true
			self.PeakTorque = List["Mobility"][Id]["torque"]+List["Mobility"][Id2]["torqueAdd"]
			self.PeakMaxRPM = List["Mobility"][Id]["peakmaxrpm"]+List["Mobility"][Id2]["peakmaxrpmAdd"]
			self.LimitRPM = List["Mobility"][Id]["limitprm"]+List["Mobility"][Id2]["limitprmAdd"]
		elseif (value <= 0 and self.ChipActive) then
			self.ChipActive = false
			self.PeakTorque = List["Mobility"][Id]["torque"]
			self.PeakMaxRPM = List["Mobility"][Id]["peakmaxrpm"]
			self.LimitRPM = List["Mobility"][Id]["limitprm"]
		end
	end		

list.Set( "ACFCvars", "acf_chips" , {"id"} )
duplicator.RegisterEntityClass("acf_chips", "Id2")
end

and the init.lua from “lua/entities/ACF_Chips/”

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

include('shared.lua')

function ENT:Initialize()

	self.ChipActive = false --output , activating performance
	self.ActiveChip = false	--input , button to active chip
	
	self.TorqueAdd			--torque add
	self.MaxRPMAdd			--max rpm add
	self.LimitRPMAdd		--limit rpm add
	
	self.CanUpdate = true
	
	self.Inputs = Wire_CreateInputs( self.Entity, { "ActiveChip" } )
	self.Outputs = WireLib.CreateSpecialOutputs( self.Entity, { "ChipActive", "ChipID" }, { "NORMAL", "STRING" } )
	Wire_TriggerOutput(self.Entity, "Entity", self.Entity)
	self.WireDebugName = "ACF Chips"

end  

function MakeACF_Chips(Owner, Pos, Angle, Id)

	if not Owner:CheckLimit("_acf_misc") then return false end
	
	local Chips = ents.Create("ACF_Chips")
	local List = list.Get("ACFEnts")
	local Classes = list.Get("ACFClasses")
	if not Chips:IsValid() then return false end
	Chips:SetAngles(Angle)
	Chips:SetPos(Pos)
	Chips:Spawn()
	
	Chips:SetPlayer(Owner)
	Chips.Owner = Owner
	Chips.Id = Id
	Chips.Model = List["Mobility"][Id]["model"]
	Chips.Weight = List["Mobility"][Id]["weight"]
	
	--Chips:ChipActive = ActiveChip
	--Chips:ChipID = Id
	
	
	Chips:SetModel( Chips.Model )
	
	Chips:PhysicsInit( SOLID_VPHYSICS )      	
	Chips:SetMoveType( MOVETYPE_VPHYSICS )     	
	Chips:SetSolid( SOLID_VPHYSICS )
	
	local phys = Chips:GetPhysicsObject()  	
	if (phys:IsValid()) then 
		phys:SetMass( Chips.Weight ) 
	end
	
	Chips:SetNetworkedBeamString("Type",List["Mobility"][Id]["name"])
	Chips:SetNetworkedBeamInt("TorqueAdd",Chips.PeakTorqueAdd)
	Chips:SetNetworkedBeamInt("MaxRPMAdd",Chips.PeakMaxRPMAdd)
	Chips:SetNetworkedBeamInt("LimitRPMAdd",Chips.LimitRPMAdd)
	
	undo.Create("ACF Chips")
		undo.AddEntity( Chips )
		undo.SetPlayer( Owner )
	undo.Finish()
	
	Owner:AddCount("_acf_Chips", Chips)
	Owner:AddCleanup( "acfmenu", Chips )
	
	return Chips
end

list.Set( "ACFCvars", "acf_Chips" , {"id"} )
duplicator.RegisterEntityClass("acf_Chips", MakeACF_Chips, "Pos", "Angle", "Id")


--if updating
function ENT:Update( ArgsTable )	--That table is the player data, as sorted in the ACFCvars above, with player who shot, and pos and angle of the tool trace inserted at the start
		
	local Feedback = "Chip updated"
	if self.ActiveChip then
		Feedback = "Please turn off the chip before updating it"
	return Feedback end
	if ( ArgsTable[1] != self.Owner ) then --Argtable[1] is the player that shot the tool
		Feedback = "You don't own that chip !"
	return Feedback end
	
	local Id = ArgsTable[4]	--Argtable[4] is the engine ID
	local List = list.Get("ACFEnts")
	
	if ( List["Chips"][Id]["model"] != self.Model ) then --Make sure the models are the sames before doing a changeover
		Feedback = "The new chip needs to have the same model as the old one !"
	return end
	
	
	self.TorqueAdd = List["Mobility"][Id]["torqueAdd"]
	self.MaxRPMAdd = List["Mobility"][Id]["peakmaxrpmAdd"]
	self.LimitRPMAdd = List["Mobility"][Id]["limitprmAdd"]
	self:SetPlayer(Owner)
	self.Owner = Owner
	self.Id = Id
	self.Model = List["Mobility"][Id]["model"]
	self.Weight = List["Mobility"][Id]["weight"]
	
	--self:ChipActive = ActiveChip
	--self:ChipID = Id
	
	self:SetModel( self.Model )	
	self:SetSolid( SOLID_VPHYSICS )
	
	local phys = self:GetPhysicsObject()  	
	if (phys:IsValid()) then 
		phys:SetMass( self.Weight ) 
	end
	
	self:SetNetworkedBeamString("Type",List["Mobility"][Id]["name"])
	self:SetNetworkedBeamInt("TorqueAdd",self.PeakTorqueAdd)
	self:SetNetworkedBeamInt("MaxRPMAdd",self.PeakMaxRPMAdd)
	self:SetNetworkedBeamInt("LimitRPMAdd",self.LimitRPMAdd)
	
	
	return Feedback
end

function ENT:TriggerInput( iname , value )
	if (iname == "ActiveChip") then
		if (value > 0 and not self.ActiveChip) then
			self.ActiveChip = true
			self:ChipActive = 1
			self:ChipID = Id
			Wire_TriggerOutput(self.Entity, "ChipActive", self.ChipActive)
			Wire_TriggerOutput(self.Entity, "ChipID", self.ChipID)
		elseif (value <= 0 and self.ActiveChip) then
			self.ActiveChip = false
			self:ChipActive = 0
			self:ChipID = Id
			Wire_TriggerOutput(self.Entity, "ChipActive", self.ChipActive)
			Wire_TriggerOutput(self.Entity, "ChipID", self.ChipID)
		end
	end

end


function ENT:OnRemove()
	Wire_Remove(self.Entity)
end

function ENT:OnRestore()
    Wire_Restored(self.Entity)
end

and if you wanted the ACFMobilityList.lua form “lua/ACF/Shared/” I’ll put only the part I added in it.

--Chips V1
local EngineCV1 = {}
	EngineCV1.id = "Chip-V1"
	EngineCV1.ent = "acf_chips"
	EngineCV1.type = "Mobility"
	EngineCV1.name = "Chip version 1"
	EngineCV1.desc = "Increase engine power"
	EngineCV1.model = "models/jaanus/wiretool/wiretool_gate.mdl"
	EngineCV1.category = "Chips Small"
	EngineCV1.weight = 1
	EngineCV1.torqueAdd = 80			--How many Tq that chip add to engine
	EngineCV1.peakmaxrpmAdd = 1000   	--How many Rpm that chip add to engine  
	EngineCV1.limitprmAdd = 1000		--How many limitRPM that chip ass to engine
	if ( CLIENT ) then
		EngineCV1.guicreate = (function( Panel, Table ) ACFChipsGUICreate( Table ) end or nil)
		EngineCV1.guiupdate = function() return end
	end
MobilityTable["Chip-V1"] = EngineCV1

--Chips V2
local EngineCV2 = {}
	EngineCV2.id = "Chip-V2"
	EngineCV2.ent = "acf_chips"
	EngineCV2.type = "Mobility"
	EngineCV2.name = "Chip version 2"
	EngineCV2.desc = "Increase engine power"
	EngineCV2.model = "models/jaanus/wiretool/wiretool_gate.mdl"
	EngineCV2.category = "Chips Medium"
	EngineCV2.weight = 1
	EngineCV2.torqueAdd = 140			--How many Tq that chip add to engine
	EngineCV2.peakmaxrpmAdd = 1200   	--How many Rpm that chip add to engine  
	EngineCV2.limitprmAdd = 1200		--How many limitRPM that chip ass to engine
	if ( CLIENT ) then
		EngineCV2.guicreate = (function( Panel, Table ) ACFChipsGUICreate( Table ) end or nil)
		EngineCV2.guiupdate = function() return end
	end
MobilityTable["Chip-V2"] = EngineCV2

--Chips V3
local EngineCV3 = {}
	EngineCV3.id = "Chip-V3"
	EngineCV3.ent = "acf_chips"
	EngineCV3.type = "Mobility"
	EngineCV3.name = "Chip version 3"
	EngineCV3.desc = "Increase engine power"
	EngineCV3.model = "models/jaanus/wiretool/wiretool_gate.mdl"
	EngineCV3.category = "Chips Fat"
	EngineCV3.weight = 1
	EngineCV3.torqueAdd = 200			--How many Tq that chip add to engine
	EngineCV3.peakmaxrpmAdd = 1500   	--How many Rpm that chip add to engine  
	EngineCV3.limitprmAdd = 1500		--How many limitRPM that chip ass to engine
	if ( CLIENT ) then
		EngineCV3.guicreate = (function( Panel, Table ) ACFChipsGUICreate( Table ) end or nil)
		EngineCV3.guiupdate = function() return end
	end
MobilityTable["Chip-V3"] = EngineCV3