【发布时间】:2021-05-03 16:26:39
【问题描述】:
好吧,我有一段代码,它是一个用于 garrysmod Darkrp 的杂草盆系统,它允许您创建 4 个花盆并通过计时器倒计时完成种植种子。 然而,一旦另一个罐子上,它就会取消其他罐子,我不确定我该如何解决这个问题。
欢呼动态
if hitEnt:GetClass() == "seed_weed" then
if self.Entity:GetNWBool("Plantable") == true then
self.Entity:SetNWBool("Plantable", false)
hitEnt:Remove()
self.Entity:SetModel("models/nater/weedplant_pot_planted.mdl")
timer.Create("Stage2_", GrowTime/7, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing1.mdl")
end)
timer.Create("Stage3_", GrowTime/6, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing2.mdl")
end)
timer.Create("Stage4_", GrowTime/5, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing3.mdl")
end)
timer.Create("Stage5_", GrowTime/4, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing4.mdl")
end)
timer.Create("Stage6_", GrowTime/3, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing5.mdl")
end)
timer.Create("Stage7_", GrowTime/2, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing6.mdl")
end)
timer.Create("Stage8_", GrowTime/1, 1, function()
self.Entity:SetModel("models/nater/weedplant_pot_growing7.mdl")
self.Entity:SetNWBool("Usable", true)
end)
end
end
end
function ENT:OnRemove()
timer.Destroy("Stage2_")
timer.Destroy("Stage3_")
timer.Destroy("Stage4_")
timer.Destroy("Stage5_")
timer.Destroy("Stage6_")
timer.Destroy("Stage7_")
timer.Destroy("Stage8_")
end
【问题讨论】:
-
将您的代码缩减为minimal reproducible example!请阅读How to Ask 并展示您的调试尝试
-
请注意,我们甚至不知道 self 是什么
标签: lua garrys-mod