function ex_change_echo()
if not tonumber(gmcp.Char.Vitals.nl) == lastXP then
if tonumber(gmcp.Char.Vitals.nl) > lastXP then
echo("\n"..
tonumber(gmcp.Char.Vitals.nl) - lastXP .."experience gained!")
else
echo("\n"..lastXP - tonumber(gmcp.Char.Vitals.nl).."experience lost!")
end
end
end
lastXP = tonumber(gmcp.Char.Vitals.nl)
I have gmcp.Char.Vitals as the event handler, but nothing happens when I gain any experience. can anyone tell me why this isin't working?
Achaea EXP Show, not working?
Re: Achaea EXP Show, not working?
First, you'll need to fix the function to accept the proper arguments, second you'll have to make sure everything you want done is actually inside the function call:
Let that run, then check the errors dialog in the editor window and see what it says.
Code: Select all
function ex_change_echo(event,args)
if not tonumber(gmcp.Char.Vitals.nl) == lastXP then
if tonumber(gmcp.Char.Vitals.nl) > lastXP then
echo(string.format("\n%i experience gained!", (tonumber(gmcp.Char.Vitals.nl) - lastXP)))
else
echo(string.format("\n%i experience lost!", lastXP))
end
end
lastXP = tonumber(gmcp.Char.Vitals.nl)
end
Last edited by Rakon on Sun Sep 04, 2011 5:33 pm, edited 1 time in total.
Re: Achaea EXP Show, not working?
This?
object:<event handler function> function:<exp_
Or this?
LUA: ERROR running script exp_change_echo (exp_change_echo) ERROR:
object:<event handler function> function:<exp_
Or this?
LUA: ERROR running script exp_change_echo (exp_change_echo) ERROR:
Re: Achaea EXP Show, not working?
Neither of those are very helpful, actually.
Also, I note that your error starts out with: function <exp_ , where as the function you posted and I edited starts out function ex_ . I would check that you're calling the right function as expected.
I changed my post above, the code section. Try using that.
Also, I note that your error starts out with: function <exp_ , where as the function you posted and I edited starts out function ex_ . I would check that you're calling the right function as expected.
I changed my post above, the code section. Try using that.
Re: Achaea EXP Show, not working?
Well, I'm looking at Errors, an Debug, and then stuff that comes up in the prompt...
LUA: ERROR running script prompt detector (Trigger64) ERROR:[string "function Trigger64()..."]:4:
attempt to perform arithmetic on global 'maxHealth' (a nil value)
[ERROR:] object:<event handler function> function:<exp_change_echo>
<>
[ERROR:] object:<prompt detector> function:<Trigger64>
<[string "function Trigger64()..."]:4: attempt to perform arithmetic on global 'maxHealth'
(a nil value)>
System Message:
GMCP event <gmcp.Char> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Char.Vitals> display(gmcp) to see the full content
Re: Achaea EXP Show, not working?
This line is the problem. The reason it isn't working is the order the operators are called. "not" has a higher order than "==" and is thus evaluated first. Thus, your line is, spelt out with brackets:Orlendr wrote: if not tonumber(gmcp.Char.Vitals.nl) == lastXP then
if (not tonumber(gmcp.Char.Vitals.nl)) == lastXP then
The bracket (not tonumber...) will always evaluate as false, since the "not" of a number is false. So your comparison is actually: if false == lastXP then
So your script will only run if lastXP is set to false, which it never is.
What you want instead is:
if not (tonumber(gmcp.char.Vitals.nl) == lastXP) then
Or spelt more shortly:
if tonumber(gmcp.char.Vitals.nl) ~= lastXP then
Use one of those two and it should work.
Re: Achaea EXP Show, not working?
Tried the first, still nothing, should I restart Mudlet first or something? Or try the second one?
Re: Achaea EXP Show, not working?
Oh one further thing. You need to initialise lastXP for the first time, otherwise it's still nil. So put this on top of the script, before the function:
lastXP = lastXP or tonumber(gmcp.Char.Vitals.nl)
That way, if lastXP is still undefined, it will be set to your current XP.
lastXP = lastXP or tonumber(gmcp.Char.Vitals.nl)
That way, if lastXP is still undefined, it will be set to your current XP.
Re: Achaea EXP Show, not working?
It's giving me an error...
expected to close at line 1 near function
?
expected to close at line 1 near function
?