• LUA Error
    4 replies, posted
Hi, I have my own server with sledbuild in gmod only when i want to join my server i get a Lua error. The error that i get is this: [ERROR] lua/includes/modules/weapons.lua:103: attempt to call field 'Copy' (a nil value) 1. unknown - lua/includes/modules/weapons.lua:103 Does somebody know what it means and how i can fix it? I would really appreciate it. [highlight](User was banned for this post ("wrong section" - postal))[/highlight]
if you post the weapons.lua so we can see it we can help, otherwise your SOL make sure to put it in [ lua] [ /lua] (no spaces)
module( "weapons", package.seeall ) local WeaponList = {} --[[--------------------------------------------------------- Name: TableInherit( t, base ) Desc: Copies any missing data from base to t -----------------------------------------------------------]] local function TableInherit( t, base ) for k, v in pairs( base ) do if ( t[k] == nil ) then t[k] = v elseif ( k != "BaseClass" && istable(t[k]) ) then TableInherit( t[k], v ) end end t["BaseClass"] = base return t end --[[--------------------------------------------------------- Name: Register( table, string, bool ) Desc: Used to register your SWEP with the engine -----------------------------------------------------------]] function Register( t, name ) local old = WeaponList[ name ] t.ClassName = name WeaponList[ name ] = t baseclass.Set( name, t ) list.Set( "Weapon", name, { ClassName = name, PrintName = t.PrintName or t.ClassName, Category = t.Category or "Other", Spawnable = t.Spawnable, AdminOnly = t.AdminOnly, }) -- Allow all SWEPS to be duplicated, unless specified if ( !t.DisableDuplicator ) then duplicator.Allow( name ) end -- -- If we're reloading this entity class -- then refresh all the existing entities. -- if ( old != nil ) then -- -- Foreach entity using this class -- table.ForEach( ents.FindByClass( name ), function( _, entity ) -- -- Replace the contents with this entity table -- table.Merge( entity, t ) -- -- Call OnReloaded hook (if it has one) -- if ( entity.OnReloaded ) then entity:OnReloaded() end end ) end end -- -- All scripts have been loaded... -- function OnLoaded() end --[[--------------------------------------------------------- Name: Get( string ) Desc: Get a weapon by name. -----------------------------------------------------------]] function Get( name ) local Stored = GetStored( name ) if ( !Stored ) then return nil end -- Create/copy a new table local retval = table.Copy( Stored ) -- If we're not derived from ourselves (a base weapon) -- then derive from our 'Base' weapon. if ( retval.Base != name ) then local BaseWeapon = Get( retval.Base ) if ( !BaseWeapon ) then Msg( "SWEP (", name, ") is derived from non existant SWEP (", retval.Base, ") - Expect errors!\n" ) else retval = TableInherit( retval, Get( retval.Base ) ) end end return retval end --[[--------------------------------------------------------- Name: GetStored( string ) Desc: Gets the REAL weapon table, not a copy -----------------------------------------------------------]] function GetStored( name ) return WeaponList[ name ] end --[[--------------------------------------------------------- Name: GetList( string ) Desc: Get a list of all the registered SWEPs -----------------------------------------------------------]] function GetList() local result = {} for k,v in pairs(WeaponList) do table.insert(result, v) end return result end this is what is in mine weapons.lua but its really weird because i have made changes in my draw.lua because that was first a error. and i didnt get the weapons.lua error. now that i changed draw.lua i get a error from weapons.lua if you need anything else say it thnks for the help
What don't you get about putting it in [ lua][ /lua] tags? [lua]module( "weapons", package.seeall ) local WeaponList = {} --[[--------------------------------------------------------- Name: TableInherit( t, base ) Desc: Copies any missing data from base to t -----------------------------------------------------------]] local function TableInherit( t, base ) for k, v in pairs( base ) do if ( t[k] == nil ) then t[k] = v elseif ( k != "BaseClass" && istable(t[k]) ) then TableInherit( t[k], v ) end end t["BaseClass"] = base return t end --[[--------------------------------------------------------- Name: Register( table, string, bool ) Desc: Used to register your SWEP with the engine -----------------------------------------------------------]] function Register( t, name ) local old = WeaponList[ name ] t.ClassName = name WeaponList[ name ] = t baseclass.Set( name, t ) list.Set( "Weapon", name, { ClassName = name, PrintName = t.PrintName or t.ClassName, Category = t.Category or "Other", Spawnable = t.Spawnable, AdminOnly = t.AdminOnly, }) -- Allow all SWEPS to be duplicated, unless specified if ( !t.DisableDuplicator ) then duplicator.Allow( name ) end -- -- If we're reloading this entity class -- then refresh all the existing entities. -- if ( old != nil ) then -- -- Foreach entity using this class -- table.ForEach( ents.FindByClass( name ), function( _, entity ) -- -- Replace the contents with this entity table -- table.Merge( entity, t ) -- -- Call OnReloaded hook (if it has one) -- if ( entity.OnReloaded ) then entity:OnReloaded() end end ) end end -- -- All scripts have been loaded... -- function OnLoaded() end --[[--------------------------------------------------------- Name: Get( string ) Desc: Get a weapon by name. -----------------------------------------------------------]] function Get( name ) local Stored = GetStored( name ) if ( !Stored ) then return nil end -- Create/copy a new table local retval = table.Copy( Stored ) -- If we're not derived from ourselves (a base weapon) -- then derive from our 'Base' weapon. if ( retval.Base != name ) then local BaseWeapon = Get( retval.Base ) if ( !BaseWeapon ) then Msg( "SWEP (", name, ") is derived from non existant SWEP (", retval.Base, ") - Expect errors!\n" ) else retval = TableInherit( retval, Get( retval.Base ) ) end end return retval end --[[--------------------------------------------------------- Name: GetStored( string ) Desc: Gets the REAL weapon table, not a copy -----------------------------------------------------------]] function GetStored( name ) return WeaponList[ name ] end --[[--------------------------------------------------------- Name: GetList( string ) Desc: Get a list of all the registered SWEPs -----------------------------------------------------------]] function GetList() local result = {} for k,v in pairs(WeaponList) do table.insert(result, v) end return result end[/lua] your table Stored is not valid
okay thanks for the help
Sorry, you need to Log In to post a reply to this thread.