• Moving to next V if target is unreachable?
    2 replies, posted
I have been quite the needy person today so sorry for that, however, I have great motivation to learn. So, I am coding an entity to find other ents as v in pairs using ents.FindByClass The issue is that I cannot figure out how to change v if v is greater than 1000 units Here is example code: [CODE]if self.MelonMode == "search" then print("A Melon is in Search Mode") --start shooting any enemy melons it can see for k,v in pairs(ents.FindByClass("melon_blue")) do print("A Melon Searched For Ents") if v then print("A Melon found Ents: ") print(v) local selfEntPos = self:GetPos() if selfEntPos:Distance( v:GetPos() ) > 1000 then return false end --if its greater than 1000 then restart, but how to find a new v instead of the same? self:PlayAlertedSound() elseif v then return false end if v.MelonMode == "dead" then return end[/CODE]
Just put all of the code inside an if statement. [code] for blah blah do if v < 1000 then --Code in here end end [/code] Is that what you're after? I could not quite understand.
The target is v. If v is less than 100 units away, it will target that. If not, it would search again. Problem is when it searches again, it finds the same v. *rated myself dumb for this*
Sorry, you need to Log In to post a reply to this thread.