Maglev Spawner, cant make the SEnt Dupe Support dupe.RegisterEntClass()

I am using a RegiterEntClass function, that is storing my Sent for Dupe support.
I call my creator is as follows:



Module = MakeMaglevModule(Ply,Pos,Ang,[ ARGS ])


Where “ARGS” are the cvar values stored in local vars (… Like Type - my controller algorithm, Info Enable, PID Parameters … and so on) with
the precise, only and same order ( one after the other ), as in storing like :



local a = self:GetClientNubmer("some_cvar_number")
local b = self:GetClientInfo("some_cvar_sting")
-- ...
Module = MakeMaglevModule(Ply,Pos,Ang,a,b....)


In the “MakeMaglevModule” function i am calling “ENT:Setup”, which args have same names like “ARGS”, but with “m” suffix on the front like so:



Module:Setup(mType,mPID,mEnableInfo, .....)
-- Like ma,mb and so on ...


After that i am storing the sent with the “RegisterEntClass” function in the Dupe libraty like so :



duplicator.RegisterEntityClass("gmod_maglevmodule",MakeMaglevModule,"Pos","Ang","PID","Type","EnableInfo",........)


Where “…” are the rest of the “MakeMaglevModule” argument names like strings. Today if my internet works, i will upload the video i made yesterday.
The Duping error still persist in the console at the end of it.

And one more thing.

In shared.lua in ENT:Setup, i got the creator of the sensor Objects



self.Sensors* = NewMaglevRanger(Len,Pos,Dir)


They have the method “Draw”, which just renders a Line and Sphere in the 3D Space.
That method i can’t call serverside, so i have to use a Hook, because i can’t send a table
of “Sensor” objects ( … the Maglev Rangers ) in to “ENT:Draw()”, so is it like so ? ( in autorun server )



-- 1)
hook.Add("Draw","Draw_Maglev_Sensors_With_Lines",MaglevRangerDraw)
-- 2) Maybe i should use a for -  pairs LOOP for achieving the right thing here,
--     so all of my sensors should be drawn  ...
hook.Add("Draw","Draw_Maglev_Sensors_With_Lines",Sensors*:MaglevRangerDraw)


Regards DVD !

Post the error. Post the MakeMaglevModule function.

Sure do but when i get home :slight_smile: wanted to describe the problem 1-st…

My “MakeMaglev” function is



if SERVER then
	
	function onRemoveMaglev(self, KeyF, KeyR, KeyOn)
		numpad.Remove(KeyF);
		numpad.Remove(KeyR);
		numpad.Remove(KeyOn);
	end
	
	function MakeMaglevModule(
	Ply,
	Pos,     
	Ang,
	KeyF,	  
	KeyR,	  
	KeyOn,
	Modovr,
	DebSens,
	On, 
	InfoOn,   
	HaloOn,  
	Fwd,
	Up,     
	NumFor,  
	Levers,  
	Mass,    
	PidMul,  
	MagModel,   
	MagMode,    
	ZOffset, 
	PidUD,   
	PidLR,   
	PidP,    
	PidY,    
	PidR,    
	To)   
		if (not Ply:CheckLimit("maglevmodules")) then
			return nil;
		end
		local Module = ents.Create( "gmod_maglevmodule" )
		if(Module:IsValid()) then --- ENT Dependent Methods
			Module:SetCollisionGroup(COLLISION_GROUP_NONE );
			Module:SetNotSolid(false)
			Module:SetPos(Pos)
			Module:SetAngles(Ang)
			Module:Setup(
				Modovr,
				DebSens,
				On, 
				InfoOn,   
				HaloOn,  
				Fwd,
				Up,     
				NumFor,  
				Levers,  
				Mass,    
				PidMul,  
				MagModel,   
				MagMode,    
				ZOffset, 
				PidUD,   
				PidLR,   
				PidP,    
				PidY,    
				PidR,    
				To
			)
			Module:SetModel(MagModel)
			Module:Spawn()
			Module:Activate()
			Module:SetPlayer(Ply)
			Module:SetMaterial("phoenix_storms/fender_chrome")
			Module:SetColor( Color( 200, 255, 200, 255 ) )
			Module:SetRenderMode( RENDERMODE_TRANSALPHA )
			Module:SetCollisionGroup(COLLISION_GROUP_NONE );
			Module:SetNotSolid(false)
			Module.KeyF   = KeyF
			Module.KeyR   = KeyR
			Module.KeyOn  = KeyOn
			Module.NumDir = 0
			Module:CallOnRemove("MaglevNumpadCleanupOnRemove",onRemoveMaglev,
			    numpad.OnDown( Ply, KeyOn, "MaglevPower_On"        , Module ),
			    numpad.OnDown( Ply, KeyF , "MaglevForceForward_On" , Module ),
			    numpad.OnUp  ( Ply, KeyF , "MaglevForceForward_Off", Module ),
			    numpad.OnDown( Ply, KeyR , "MaglevForceReverse_On" , Module ),
			    numpad.OnUp  ( Ply, KeyR , "MaglevForceReverse_Off", Module )
			)
			if(Module:GetPhysicsObject():IsValid()) then --- PhysObj Dep Methods
				Module:GetPhysicsObject():SetMass(Mass)
				Ply:AddCount("maglevmodules", Module)
				return Module;
			end
			return nil
		end
		return nil
	end	
	duplicator.RegisterEntityClass( "gmod_maglevmodule", MakeMaglevModule, 
	"Pos",     
	"Ang",
	"KeyF",	  
	"KeyR",	  
	"KeyOn",
	"Modovr",
	"DebSens",
	"On", 
	"InfoOn",   
	"HaloOn",  
	"Fwd",
	"Up",     
	"NumFor",  
	"Levers",  
	"Mass",    
	"PidMul",  
	"MagModel",   
	"MagMode",    
	"ZOffset", 
	"PidUD",   
	"PidLR",   
	"PidP",    
	"PidY",    
	"PidR",    
	"To")
end


Aditional ENT Fields:



ENT.KeyF	= 45
ENT.KeyR	= 39
ENT.KeyOn	= 42
ENT.Modovr  = 0
ENT.DebSens = 0
ENT.On      = 0
ENT.InfoOn  = 0
ENT.HaloOn  = 0
ENT.FwdL    = Vector(0,0,0)
ENT.UpL     = Vector(0,0,0)
ENT.NumFor  = 1000
ENT.Levers  = Vector(0,0,0)
ENT.Mass    = 300
ENT.PidMul  = 0
ENT.MagModel= ""
ENT.MagMode = 0
ENT.ZOffset = 0
ENT.StateUD = {}
ENT.StateLR = {}
ENT.StateP  = {}
ENT.StateY  = {}
ENT.StateR  = {}
ENT.To      = 100
ENT.NumDir	= 0
ENT.Sensors = {}


The “ENT:Setup” function



function ENT:Setup(
				mModovr,
				mDebSens,
				mOn, 
				mInfoOn,   
				mHaloOn,  
				mFwd,
				mUp,     
				mNumFor,  
				mLevers,  
				mMass,    
				mPidMul,  
				mMagModel,   
				mMagMode,    
				mZOffset, 
				mPidUD,   
				mPidLR,   
				mPidP,    
				mPidY,    
				mPidR,    
				mTo )   


The method for drawing my sensors located in “shared.lua”



        function self:MagRanDraw()
          render.DrawLine(rPos, rPos + rLen * rDir, Color(0,0,255,255), true)
          render.DrawSphere(rPos,3,4,4,Color(255,0,0,255))
        end


Do I need such code for drawin’ my sensors located in the bottom of “init.lua” file ??



function MaglevSensorsDebug(ent)
   if((ent:GetClass() == "gmod_maglevmodule") and (ent.DebSens ~= 0))
      for k,_ in pairs(ent.Sensors) do
          ent.Sensors[k]:MagRanDraw() 
      end
   end
end

 -- Hook it on ENT:Draw()

hook.Add("Draw","Draw_Maglev_Sensors_With_Lines",MaglevSensorsDebug)


[editline]4th February 2014[/editline]

A video with the functionality and the DUPING ERROR persists in my Youtube channel.
Search for “dvdvideo1234” or http://www.youtube.com/user/dvdvideo1234
And then search for LUA Monorail Maglev … its the first video :smiley:

Regards DVD !

The duping erros is :




[ERROR] addons/advduplicator/lua/autorun/server/advdupe.lua:1231: attempt to index a nil value
  1. LimitedGhost - addons/advduplicator/lua/autorun/server/advdupe.lua:1231
   2. AddToGhost - addons/advduplicator/lua/weapons/gmod_tool/stools/adv_duplicator.lua:511
    3. Think - addons/advduplicator/lua/weapons/gmod_tool/stools/adv_duplicator.lua:285
     4. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:194




Hey if i recall correctly, I think i have to overlap SEnt’s custom fields and MakeMaglev Function.
How do i do that ?

I need an answer here don’t leave me hanging …

I believe you are missing this part from your MAKE function:

Try default duplicator, not adv dupe, and post the error then.

10x WORKS ! with 1 and 2