Soandso2
Well-known member
- Joined
- Mar 13, 2023
- RedCents
- 937¢
So, my main loop starts like this:
But it used to start like this:
The second version crashed multiple times due to "compare nil with a number", in the second if-statement. But after having changed it to the first version... no more crashes.
The "compare nil with a number" error occurs when the target has died and target.PctHPs() result in nil instead of it's current HP.
First of all, what is wrong with the second version of the code?
And is there a way to prevent "compare number with nil" if the target dies before the script actually tries to evaluate the condition?
EDIT: Forgot to mention that me and target in the code are shortened versions of mq.TLO.Me and mq.TLO.Target etc. The Lua WORKS, I am just showing the parts that sometimes crash.
Lua:
while true do
if me.Combat() and target() then
if not stopBellow and target.PctHPs() < 90 and me.AltAbilityReady("Boastful Bellow")() and target.Buff("Boastful Bellow L").ID() == nil then
But it used to start like this:
Lua:
while true do
if me.Combat() and target() and target.PctHPs() < 90 then
if not stopBellow and me.AltAbilityReady("Boastful Bellow")() and target.Buff("Boastful Bellow L").ID() == nil then
The second version crashed multiple times due to "compare nil with a number", in the second if-statement. But after having changed it to the first version... no more crashes.
The "compare nil with a number" error occurs when the target has died and target.PctHPs() result in nil instead of it's current HP.
First of all, what is wrong with the second version of the code?
And is there a way to prevent "compare number with nil" if the target dies before the script actually tries to evaluate the condition?
EDIT: Forgot to mention that me and target in the code are shortened versions of mq.TLO.Me and mq.TLO.Target etc. The Lua WORKS, I am just showing the parts that sometimes crash.


