Need help
I cannot make this work :(
Lua Code:
Conclusion: Little addon to hide friendly player names (not NPCs) when resting. Lua Code:
|
I'm saying this from memory so take it with a grain of salt but I believe the cvars are string type not number.
So try setting them to "1" and "0" respectively. You also do not need to test explicitly for true. Code:
If IsResting() then |
Quote:
Getting this error: Quote:
|
Quote:
You can remove the '== true' to save some space, too (as Dridzt suggested). use: Lua Code:
|
I feel so stupid right now :o
Thank you, both of you! :D |
Actually, move the variables line out of the event script entirely. As it stands, you're setting those variables over and over, each time one of the events fire.
|
Edited #1 with the conclusion. Thank you all :-)
|
I'd suggest using a table instead. It'll be easier to read, and easier to extend in the future.
Also, there's no need to listen for zone change events if you only want to respond to changes in the rest state. Code:
local cvars = { |
I don't quite understand these two lines:
Lua Code:
Specifically I don't understand the IsResting() and 1 or 0 And the _ symbol. Could you try and explain them for me? |
_ is a variable name used by programmer convention as a throwaway variable.
Variables holding values you don't care to reuse are named _ for convenience (other programmers can at a glance know that a value stored in a variable named _ will be discarded). It could be any other valid variable name, there's nothing special about the name of the variable itself other than programmers know the value will not be used further on. As to your first question value gets assigned the result of the logical operation on the right. http://www.lua.org/pil/3.3.html |
Quote:
That linked helped a lot, still a bit confusing though :rolleyes: |
These two lines are functionally identical:
Code:
local value = IsResting() and 1 or 0 Code:
local value |
All times are GMT -6. The time now is 10:24 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI