Forums » Community Projects

LUA Event and Data Question

Mar 22, 2008 PsyRa link
When an event triggers, is there any way to tell what, if any, variables are associated with the event?

What I am specifically looking for is the variables associated with the "PLAYER_DIED" event. I know there is a " GeneratePlayerDiedMessage(string name1, name2, int weapon)" function available, however I don't know how to find out how to identify the values to set for name1 and name2.

I have been looking at this site (http://www.vo-wiki.com/racecar/index.php?title=Main_Page) for more details, however I can't figure this out.

What I have figured out is that events like "INVENTORY_UPDATE" return a sequential number each time they are fired, but I still can't figure out how to find the details.

I have tried print,(get the number), printtable (Nothing), spickle (Errors). I have tried to sift through the Lua Reference files, but those are not exactly easy to read :(

All the forum posts I looked at seemed to assume a knowledge of how to get at this information. I even dug into all the plugins I run for examples, Nada.

Any help would be appreciated.
Mar 22, 2008 blacknet link
try something like this

function myapp.eventhandler(eventname,args)
myapp.catcher[1] = eventname
myapp.catcher[2] = args
end

then trigger it one time. /lua printtable(myapp.catcher[2])

I can tell you the player_died event is this
arg1 = killed id
arg2 = killer id
arg3 = weapon
Mar 22, 2008 slime73 link
declare("eventtest", {})

function eventtest:OnEvent(event, ...)
  purchaseprint(event)
  if ... then printtable{...} end
end

RegisterEvent(eventtest, "EVENT_NAME")
Mar 23, 2008 PsyRa link
Thanks for the help.

What a difference printtable() and printtable {}. Almost didn't notice that with () it pulls the first index record, and with {} it pulls the whole thing.

Now I get a bunch of numbers, and from blacknet's help I can tell that the results are killed ID, killer ID and weapon, but I am not sure how to tell what is what for other events. The number: value pairs aren't very intuitive.

Is there a way to identify what they represent easily, or is it trial and error?
Mar 23, 2008 blacknet link
Well many/most of them are obvious what they are. Some will be not so obvious.

The reason I assign the args to a variable is so I can play with it at my time. Meaning I can sit somewhere and go over the list to try different options and possibilities. Then when I get something I like I move on.
Apr 01, 2008 thenthdoctor link
Where can I find a list of the events? So far I only know of ENTERED_STATION and PLAYER_DOCKED ?
Apr 02, 2008 maq link