This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Conditionals for script
Post Reply
Return to board index
Post by
GreyMouser
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?
Post by
Neffi
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
ShowHelm(0)
is the same as doing
ShowHelm(true)
.
/run ShowHelm( not IsAltKeyDown() )
That will do it.
Post by
GreyMouser
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.
Post by
Neffi
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.
http://code.google.com/p/wow-neffui/downloads/detail?name=nfSlashCmds.zip
It adds:
/eval
/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.
Also:
/in
/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.
And
/rl
to reload the UI.
Post by
22686
This post was from a user who has deleted their account.
Post by
Neffi
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
luaNumber
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
is
true in Lua; I made the assumption that perhaps ShowHelm was one of the few functions that was coded
properly
. But I don't actually know. It might accept 0 as false. Test it yourself.
Post by
22686
This post was from a user who has deleted their account.
Post by
Neffi
Well, my
not
script was so much shorter anyway. Also, it should be a couple instructions faster, just in case you run on a 33 MHz CPU.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.