Mantis Bug Squashing Help

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Mantis Bug Squashing Help

Post by demonnic »

the index should not be 'pairs', no. look over the code, the Cure index: should be the name of an affliction. I bet if you display those tables, they'll not be what you think they are. That's how I found it in my system. You do want to use the pairs() function for iterating, but the table shouldn't be returning the string 'pairs' as the index.

User avatar
Jules
Posts: 118
Joined: Sun Oct 11, 2009 5:41 pm
Location: Plymouth State University - Sophomore

Re: Mantis Bug Squashing Help

Post by Jules »

I made the changes that you suggested, declaring the list and the sub-lists accordingly outside of the section where I fill them... And it works! I'm thinking that the "Cure indes: pairs" thing was just a result of the phpTable() mixup, because it now returns the affliction that it's iterating through.

However, I received an error message when the script tried to reset the balance:
Lua error:[string "mantis.healingBalances[balance] = true"]:1: table index is
nil
Which is weird, since it shouldn't be nil, it should be false. And the function that resets the balance should be okay with that:

Code: Select all

function MantisResetBalance(balance)
  if mantis.healingBalances[balance] == false then
    tempTimer(2, [[mantis.healingBalances[balance] = true]])
  end
end
I don't want to have to change my resetting balance function to nil instead of false if I don't have to, but I will if that seems to be the only option.

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Mantis Bug Squashing Help

Post by demonnic »

Jules wrote: However, I received an error message when the script tried to reset the balance:
Lua error:[string "mantis.healingBalances[balance] = true"]:1: table index is
nil
Which is weird, since it shouldn't be nil, it should be false. And the function that resets the balance should be okay with that:

Code: Select all

function MantisResetBalance(balance)
  if mantis.healingBalances[balance] == false then
    tempTimer(2, [[mantis.healingBalances[balance] = true]])
  end
end
I don't want to have to change my resetting balance function to nil instead of false if I don't have to, but I will if that seems to be the only option.
Code: [show] | [select all] lua
tempTimer(2, function() mantis.healingBalances[balance] = true end) 
--or
tempTimer(2, [[mantis.healingBalances[]]..balance..[[] = true]])
--or
tempTimer(2, "mantis.healingBalances["..balance.."] = true")
This is because the string is evaluated when the tempTimer goes off, not when it is set. Hence why the closures/anonymous functions for tempTimer were included, so you didn't have to do all that escaping. Otherwise, it looks for the global variable balance to fill mantis.healingBalances[balance].


Edit: because I forgot you need to use function() and not function

User avatar
Jules
Posts: 118
Joined: Sun Oct 11, 2009 5:41 pm
Location: Plymouth State University - Sophomore

Re: Mantis Bug Squashing Help

Post by Jules »

Ahah! That does make sense... I think. Though I don't quite understand closures all that well, I'll figure it out eventually. Thank you, Demonnic! I'll make it mandatory then to have the latest version of Mudlet to use Mantis... Which isn't all that terrible.

Post Reply