I'm pretty new to lua and already stared messing around with lua. I have written the following script to print out my distance and angle to every available object in the constructer with the help of an array but there is a big problem in my way:
me = {'["game.exe"+2A]','["game.exe"+A8]','["game"+6A8]'}
botallx = {'["game.exe"+01]','["game.exe"+02]','["game.exe"+03]',
'["game.exe"+04]','["game.exe"+05]','["game.exe"+06]','["game.exe"+07]',
'["game.exe"+08]','["game.exe"+09]','["game.exe"+10]','["game.exe"+11]',
'["game.exe"+12]'}
botally = {'["game.exe"+31]','["game.exe"+32]','["game.exe"+33]',
'["game.exe"+34]','["game.exe"+35]','["game.exe"+36]','["game.exe"+37]',
'["game.exe"+38]','["game.exe"+39]','["game.exe"+30]','["game.exe"+31]',
'["game.exe"+32]'}
botallz = {'["game.exe"+51]','["game.exe"+52]','["game.exe"+53]',
'["game.exe"+54]','["game.exe"+55]','["game.exe"+56]','["game.exe"+57]',
'["game.exe"+58]','["game.exe"+59]','["game.exe"+50]','["game.exe"+51]',
'["game.exe"+52]'}
function sight_angle()
if (isKeyPressed(VK_E)) then
for i=1, 12 do
if (botallx[i] ~= nil or botally[i] ~= nil or botallz[i] ~= nil ) then
vecX=readFloat(me[1])-readFloat(botallx[i])
vecY=readFloat(me[2])-readFloat(botally[i])
vecZ=readFloat(me[3])-readFloat(botallz[i])
distance=math.sqrt(math.pow(calcZ,2)+math.pow(calcX,2))
angleX=math.deg(math.atan2(calcZ, calcX))
print ("current distance is " .. distance)
print ("current angle is " .. angleX)
else --One of the botallx, botally, botallz value was nil
print ("Can't perform calculations due to a nil value")
end
end
end
theses addresses called ["game.exe"+...] contain a float value, but some of the objects in the container of botally, botallx and botallz are nil or have nil values. So when I execute the script then the array for i=1 to 12 starts calculating the first one and gives me the angle and distance, but keeps calculating until it hits an object from the container that has a nil value and then doesn't want to carry on calculating the other objects.
Example: object 1,3,6 inside botally, botallx and botallz have values, everything else is nil. it starts calculating the first one...gives out the distance and angle, but then stops at the second and starts complaining that the calculation can't be performed because of a nil value, so it jumps back to the first object and gives me the dist and angle of it again.
But I want it to jump over that second empty nil object and continue with the 3rd object, which has a value and print the distance and angle for me, then jump over the empty 4th and 5th one and calculate the 6th one and after that, it can jump back to the first one again because the rest from 7 to 12 is nil.
but it doesn't want to do this....can somebody help me?
'), since there are some unmatched ones. The way you are showing your script here (ignoring errors in construction), there are nonilvalues in your tables. - pschulz