Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Table handling issue
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
| Posted by
| Fadedparadox
USA (91 posts) Bio
|
| Date
| Reply #15 on Fri 08 Feb 2013 02:11 AM (UTC) |
| Message
| There is one last issue I didn't address. You have several options. The problem is that any missing key will evaluate to nil, not false. nil == false evaluates to false. Several options include...
1) Set taraaffliction to contain every affliction, set to false. Set them to true as you afflict, false as you know they're cured.
2) use NOT. NOT changes true to false and false to true. it also changes 'nil' to true. You would do that like so:
if tarafflictions[v] == false then
changed to:
if not tarafflictions[v] then
Either option works! | | Top |
|
| Posted by
| Fadedparadox
USA (91 posts) Bio
|
| Date
| Reply #16 on Fri 08 Feb 2013 02:17 AM (UTC) Amended on Fri 08 Feb 2013 02:23 AM (UTC) by Fadedparadox
|
| Message
| This is just one possible result:
venom_priority = {
"slickness",
"asthma",
"deaf_strip",
"sensitivity",
"powersap",
"blindness",
"relapsing",
"clumsiness",
}
tarafflictions = {}
tarafflictions.slickness = true
function doattack()
for k, v in ipairs(venom_priority) do
if not tarafflictions[v] then
Note ( "Venom: " .. v )
break
end -- if
end -- for
end -- func
Another possbility!
venom_priority = {
"slickness",
"asthma",
"deaf_strip",
"sensitivity",
"powersap",
"blindness",
"relapsing",
"clumsiness",
}
tarafflictions = {}
for k, v in pairs(venom_priority) do
tarafflictions[v] = false
end -- for
tarafflictions.slickness = true
function doattack()
for k, v in ipairs(venom_priority) do
if tarafflictions[v] == false then
Note ( "Venom: " .. v )
break
end -- if
end -- for
end -- func
In fact, you can put
for k, v in pairs(venom_priority) do
tarafflictions[v] = false
end -- for
In a function to reset the table.
For the first example, you can reset it by simply doing:
| | Top |
|
| Posted by
| Dyron
(17 posts) Bio
|
| Date
| Reply #17 on Fri 08 Feb 2013 03:20 AM (UTC) |
| Message
| Thank you so much for the examples Fadedparadox. I at least understand more of what you are saying, As for your examples, I've tried them.. without the:
It refuses to call the tarafflictions variable. How do I make it call that variable that's called globally? | | Top |
|
| Posted by
| Fadedparadox
USA (91 posts) Bio
|
| Date
| Reply #18 on Sun 10 Feb 2013 02:51 AM (UTC) |
| Message
|
Dyron said:
Thank you so much for the examples Fadedparadox. I at least understand more of what you are saying, As for your examples, I've tried them.. without the:
It refuses to call the tarafflictions variable. How do I make it call that variable that's called globally?
I'm not certain what you mean. tarafflictions is, in the example, global so can be called from within another function/etc, or globally.
Can you give an example of what will not work? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #19 on Sun 10 Feb 2013 08:37 PM (UTC) |
| Message
|
Dyron said:
It refuses to call the tarafflictions variable. How do I make it call that variable that's called globally?
Your use of language is confusing me. You don't "call" variables. Are you saying the variable has a different value to what you expect? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Dyron
(17 posts) Bio
|
| Date
| Reply #20 on Mon 11 Feb 2013 04:10 PM (UTC) |
| Message
| | I got it figured out, thanks guys. Now on to the next problem of not being able to process gmcp. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
74,666 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top