• Lua Error while patching old Addon.
    5 replies, posted
I'm adding Elder Scrolls: Morrowind SWEPS but all of them have this error when you right-click (which is throwing the weapon). [TES:Morrowind Tantos and Katanas Reuploaded] lua/entities/ent_mor_tanto/init.lua:61: attempt to call global 'ValidEntity' (a nil value) 1. unknown - lua/entities/ent_mor_tanto/init.lua:61 Line 60: local Ent = data.HitEntity Line 61: if !(ValidEntity(Ent) or Ent:IsWorld()) then return end I'm assuming this is the function to check if it's hitting a player, npc or the world but it would seem that ValidEntity(Ent) is no longer a valid function, or that the function was updated to require a local = definition that is not in the files. How can I go about fixing this? (Or removing the throwing functionality, that'd be fine too. There are so few melee weapons that I'd rather not lose all of these SWEPS)
Use IsValid
For some reason it is still printing the same error message. Full script (for the relevant section) is as follows /*---------------------------------------------------------    Name: ENT:PhysicsCollided() ---------------------------------------------------------*/ function ENT:PhysicsCollide(data, phys)          local Ent = data.HitEntity     if (IsValid or Ent:IsWorld()) then return end --/ I've tried (IsValid), (IsValid(Ent), and !(IsValid) all still print the same error     if Ent:IsWorld() then         util.Decal("ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal)         if self.Entity:GetVelocity():Length() > 400 then             self:EmitSound("npc/roller/blade_out.wav", 60)             self:SetPos(data.HitPos - data.HitNormal * 10)             self:SetAngles(data.HitNormal:Angle() + Vector(-40, 180, 0))             self:GetPhysicsObject():EnableMotion(false)         else             self:EmitSound(self.Hit[math.random(1, #self.Hit)])         end         self:Disable()     elseif Ent.Health and self.HitEnemy == false then    // Only deal damage once.         if not(Ent:IsPlayer() or Ent:IsNPC() or Ent:GetClass() == "prop_ragdoll") then             util.Decal("ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal)             self:EmitSound(self.Hit[math.random(1, #self.Hit)])             self.HitEnemy = true         end                  local boink = ents.Create(self.Weapon)         Ent:TakeDamage(50, self:GetOwner(), boink)    // If you have a killicon for the tanto, this makes it appear.         boink:Remove()         if (Ent:IsPlayer() or Ent:IsNPC() or Ent:GetClass() == "prop_ragdoll") then             local effectdata = EffectData()             effectdata:SetStart(data.HitPos)             effectdata:SetOrigin(data.HitPos)             effectdata:SetScale(1)             util.Effect("BloodImpact", effectdata)             self:EmitSound(self.FleshHit[math.random(1,#self.Hit)])             self.HitEnemy = true         end     end     self.Entity:SetOwner(nil) end
Did you look at the Wiki example of usage on the top? You can use either IsValid(Ent) or Ent:IsValid()
As the wiki states both IsValid and Entity/IsValid can be used. Please update the file to these functions and then post the full error you still receive.
I've tried everything but Entity/IsValid and will give that a shot, the error printout remains the same regardless of the edit however. Will edit post with update and if the message changes.
Sorry, you need to Log In to post a reply to this thread.