in your browser.
Conditionals for script
Return to board index
I've been trying to get this to work .. /run if IsAltKeyDown() then ShowHelm(0) else ShowHelm(1) .. My goal is to show helm with button push and hide it with Alt + button push. Have had no luck so far.. /run ShowHelm(not ShowingHelm()) works to hide/show helm, but I'd like it to work using the alt button. Anyone know how to fix please?
Lua doesn't treat 0 as false, it treats it as true, since it's a non-nil, non-boolean value. Eg, it has value, even if that value is 0. So doing
is the same as doing
/run ShowHelm( not IsAltKeyDown() )
That will do it.
Thank You so much
It works perfectly and has given me ideas for future macros making. If youre ever in St Louis I owe you a beer or 12.
You may want to try this little addon out. I uploaded the temporary version I use, but I plan to make a large wealth of useful chat- and slash-command features and release a more thorough addon.
/eval /run ShowHelm(false); /run ShowHelm(true)
/eval /say you're eval!; /say u gud it 'hok
/eval look at teh cute bunny <-- if you don't use a slash-command, it just prints the words to your chat frame
Should work with any arbitrary command (except secure ones). Works exactly like normal conditionals.
/in 2.5 /say Hello!
/in 3 /roar <-- give the command a name in brackets to avoid it spamming
Add a delay to a command.
to reload the UI.
Oh, have they changed it?
ShowHelm/Cloak used to work just fine (or, as one would expect) when using 1 and 0 as the flag.
Haven't patched yet so can't really test right now :p
Well they are callouts to C, and in C 0 is false and 1 is true. I know that in the Lua source code, a 0 is a
type (-> double). That's why Lua knows to treat it as true. But I can't say whether or not WoW's source uses the proper type checking. It seems like they often treat callouts and other Lua<->C interfaces as if the scripts was also C (as evidence by most functions returning 1/nil instead of true/false like they should). Maybe ShowHelm is another function that doesn't act like it should when interfacing Lua. If they don't perform the proper checks, 0 would show up as false in the C code.
I was just going on the fact that the OP said it didn't work, because 0
true in Lua; I made the assumption that perhaps ShowHelm was one of the few functions that was coded
. But I don't actually know. It might accept 0 as false. Test it yourself.
I just confirmed that they do still work.
Only wished to know that so I could safely assume that the script OP pasted is the whole thing.
The reason it does not work is the fact that the if-statement isn't closed (i.e. missing an 'end' at the end :p).
script was so much shorter anyway. Also, it should be a couple instructions faster, just in case you run on a 33 MHz CPU.
You are not logged in. Please
to post a reply or
if you don't already have an account.
Connect with Wowhead
Other Fanbyte Sites
Hearthstone Top Decks
Final Fantasy XI
© 2021 Fanbyte