Page 1 of 1

event handling

Posted: Wed Sep 25, 2013 5:53 pm
by icesteruk
Sorry for all the posting but currently redesigning my system and I've ran into a weird issue.. I copied and pasted one of my GMCP event handling things over and it seems it doesnt want to load right..

Everything (vairbale wise) is correct but I keep getting errors such as

object:<event handler function> function:<Settings>
<attempt to call a nil value>

in the 'Registered Event Handlers" I have gmcp.Char.Vitals & gmcp.Char.Status

the code is
Code: [show] | [select all] lua
function onChar( event )

status.class = gmcp.Char.Status.class
status.guild = gmcp.Char.Status.guild
status.city = gmcp.Char.Status.city
status.name = gmcp.Char.Status.name
status.race = gmcp.Char.Status.race
status.status = (gmcp.Char.Vitals.status:lower() == "living" and true or false)
end
When I put and run this in an Alias, it runs fine without errors long as I take out the function part

Re: event handling

Posted: Wed Sep 25, 2013 5:55 pm
by Akaya
Is your script name the same as your function name? Looks like the script name will need to be onChar.

Re: event handling

Posted: Wed Sep 25, 2013 5:58 pm
by icesteruk
oh.. didn't know that.. But fixed it.. Thank you :)

Re: event handling

Posted: Wed Sep 25, 2013 6:55 pm
by Jor'Mox
An alternate strategy is to us the registerAnonymousEventHandler function to register an arbitrary function to be called when an event is raised.

Re: event handling

Posted: Mon Sep 30, 2013 6:18 am
by Omni
Jor'Mox wrote:An alternate strategy is to us the registerAnonymousEventHandler function to register an arbitrary function to be called when an event is raised.
One issue with this is that you can't unregister, so if it starts erroring, it will keep firing and unless I'm missing something, you've no way to stop it.

Re: event handling

Posted: Mon Sep 30, 2013 6:49 am
by Vadi
Well, not until you fix the function in question or put 'if true then return end' right at the top of it.