这部分代码出现以下错误:
[ERROR] lua/entities/cook/init.lua:58: attempt to index global 'self' (a nil value)1. cooked - lua/entities/cook/init.lua:58
该函数从第 57 行开始,当我删除第 58 行时(local Pos = self.Entity:GetPos()
,它只会为第 61 行提供相同的错误消息。
function cooked()
local Pos = self.Entity:GetPos()
local roll = math.random(1, 5);
if roll == 5 then
self.Entity:EmitSound("phx/explode06.wav")
self.Entity:Remove()
else
local createfood = ents.Create("food")
createfood:SetPos(Pos + Vector(0,10,100))
createfood:Spawn()
self:SendLua("GAMEMODE:AddNotify(\"You finish cooking the food and package the product!\", NOTIFY_GENERIC, 4)")
end
end