LUA错误:尝试调用方法“(nil值)

时间:2018-07-30 15:57:32

标签: function lua garrys-mod

我编写的简单代码有些麻烦:

SWEP.PrintName          = "Gestionnaire d'alarmes Administrateur"           
SWEP.Author         = "Frass"
SWEP.Instructions       = "Clic Gauche : Ouvrir le gestionnaire"

SWEP.Spawnable = true
SWEP.AdminOnly = true

SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = false
SWEP.Primary.Ammo       = "none"

SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"

SWEP.Weight         = 5
SWEP.AutoSwitchTo       = false
SWEP.AutoSwitchFrom     = false

SWEP.Slot           = 1
SWEP.SlotPos            = 2
SWEP.DrawAmmo           = false
SWEP.DrawCrosshair      = true


SWEP.ViewModel          = "models/weapons/v_pistol.mdl"
SWEP.WorldModel         = "models/weapons/w_pistol.mdl"

local ShootSound = Sound( "buttons/button14.wav" )

function SWEP:PrimaryAttack()

    self:TabletMenu()

end


function TabletMenu() (reduced, there's a lot of code inside)

当我尝试在GMOD中使用SWEP时,控制台会给我这个错误:

[ERROR] lua/weapons/alarmtabletld.lua:44: attempt to call method 'TabletMenu' (a nil value)
  1. unknown - lua/weapons/alarmtabletld.lua:44

我真的不明白这是怎么回事... 一些帮助可能真的很好!

1 个答案:

答案 0 :(得分:0)

您正在调用TabletMenu表中不存在的SWEP函数。也许是在其他地方定义的吗?