-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible order of operation bug in Luacore #1045
Comments
try assigning it to a variable first and checking the variable, im just
curious
…On Thu, Jun 20, 2019 at 1:12 PM amadeus1171 ***@***.***> wrote:
Consider if (heal_party and party_needs_healing()) then.
heal_party is always true.
party_needs_healing() returns true or false depending on whether or not
the party needs healing.
However, (heal_party and party_needs_healing()) always returns true.
But (heal_party and ((party_needs_healing()))) returns the correct true
or false when force order of operation using parentheses around
party_needs_healing().
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1045?email_source=notifications&email_token=AADXNDMH2K75S7422L5V7R3P3PCBBA5CNFSM4HZZQF5KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G2YWV3Q>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADXNDMOYTWP2E6UWE6YBBDP3PCBBANCNFSM4HZZQF5A>
.
|
That is pretty much impossible. If anything that would be a bug in Lua itself, since LuaCore doesn't do any of its own parsing. Also, Also, even if it was not evaluated first it should still be evaluated. From a semantic perspective the order of operations is irrelevant if the first value is I cannot stress how unlikely it is that there's something wrong here. I would really go with printing. You can keep your current structure if you do this: local check = function(value)
print(value)
return value
end
if check(heal_party) and check(party_needs_healing()) then
-- stuff
end Now it will print the first and second value (unless the first is If you're still convinced that there's an error on our end try to create a minimal working example of code that we can run directly to observe the error directly. |
Looks like I have to make a video. I'll post it in a bit. |
I would really much prefer if you either tried to narrow down the erroneous code into a minimal working sample or ran the code I posted and reported the results. Videos have rarely helped me understand a problem. But if you think it'll help, I can take a look. |
This is so weird. This code worked properly. _addon.name = 'Test'
_addon.author = 'Me'
_addon.version = '1'
_addon.commands = {'test'}
function testme()
local retVal = false
return retVal
end
windower.register_event('addon command', function(...)
local args = {...}
local cmd = ''
if true and testme() then
windower.add_to_chat(5, "testme was evaluated and not testme() return value")
else
windower.add_to_chat(5, "testme was not evaluated and testme() returned false")
end
end) |
Consider
if (heal_party and party_needs_healing()) then
.heal_party
is always true.party_needs_healing()
returns true or false depending on whether or not the party needs healing.However,
(heal_party and party_needs_healing())
always returns true.But
(heal_party and ((party_needs_healing())))
returns the correct true or false when force order of operation using parentheses aroundparty_needs_healing()
.The text was updated successfully, but these errors were encountered: