- Joined
- Mar 23, 2019
- RedCents
- 8,961¢
- Pronouns
- He/Him
I'm in the process of porting a macro over to Lua and I've run up against a lot of woes in working with return types from TLOs.
For all the methods I've been working with, it looks like those that would normally return "some value" or NULL - don't return an object type nil, but rather an object of type userdata. You have to pass the returned userdata to the global tostring() method and compare the value against a static string "null".
In Lua "truthiness", false == false, nil == false, and everything else is true...
So in this codeblock, regardless of what is returned (either the spell or userdata containing "null") it equates to true and we always see "Death Punch!"
For all the methods I've been working with, it looks like those that would normally return "some value" or NULL - don't return an object type nil, but rather an object of type userdata. You have to pass the returned userdata to the global tostring() method and compare the value against a static string "null".
In Lua "truthiness", false == false, nil == false, and everything else is true...
So in this codeblock, regardless of what is returned (either the spell or userdata containing "null") it equates to true and we always see "Death Punch!"
C-like:
if mq.TLO.Me.Spell("Death-Fu Death Punch") then
print("Death Punch!")
else
print("Death Block!")
end

