RichWebster Posted June 25, 2019 Share Posted June 25, 2019 I suppose we'll have to agree to disagree.ÃÂ lol dude. It's very simple. Event handlers are all functions, but not all functions are event handlers. Events are called through the papyrus engine event model or from custom events defined with SKSE. Giving your function the "Event" keyword doesn't make it an event handler, semantically or otherwise. It just makes your code more confusing.ÃÂ I didn't tell you to adopt a bad convention. If you don't like it being criticized, you don't have to post about it on discussion forums.:thumbsup: Link to comment Share on other sites More sharing options...
RichWebster Posted June 30, 2019 Share Posted June 30, 2019 FYI OP, Bethesda use custom events in their scripts as well. Do whatever feels right for your usage. Link to comment Share on other sites More sharing options...
Evangela Posted July 1, 2019 Share Posted July 1, 2019 (edited) You were both right. Events(better to use custom ones though, like above) can be declared like functions and called like functions, but actual engine events do all their work under the hood. Edited July 1, 2019 by Rasikko Link to comment Share on other sites More sharing options...
RichWebster Posted July 1, 2019 Share Posted July 1, 2019 You were both right. Events(better to use custom ones though, like above) can be declared like functions and called like functions, but actual engine events do all their work under the hood.SKSE enables you to replicate engine events (sort of) with RegisterForModEvent() and SendModEvent(), which is super handy. Link to comment Share on other sites More sharing options...
foamyesque Posted July 1, 2019 Share Posted July 1, 2019 Hell, I've defined personal events for API hooks when I've found myself working on extensibility stuff, and, very notably, the MCM scripts are set up to do the same. The key distinction is that the Events are automatically generated for *something building on your work*; they don't need to know or care what goes on under the hood, only that if they put code in their OnWhatever() code block, it will execute when Whatever happens. Link to comment Share on other sites More sharing options...
npdogg Posted July 2, 2019 Share Posted July 2, 2019 FYI OP, Bethesda use custom events in their scripts as well. Do whatever feels right for your usage. Bethesda isn't exactly a paragon of good software design or coding practices. You were both right. Events(better to use custom ones though, like above) can be declared like functions and called like functions, but actual engine events do all their work under the hood. RichWebster is talking about labelling a function with the event keyword to designate it as a "user" event. It's an abuse of the loose language semantics, not the same thing as labelling an event handler with the function keyword. Link to comment Share on other sites More sharing options...
RichWebster Posted July 2, 2019 Share Posted July 2, 2019 I think we might have had crossed wires. Link to comment Share on other sites More sharing options...
Evangela Posted July 3, 2019 Share Posted July 3, 2019 I think we can simply agree that for the sake of sanity just use the events as they are designed to be used. Link to comment Share on other sites More sharing options...
PeterMartyr Posted July 3, 2019 Share Posted July 3, 2019 People it about the human interface or convention has it is better known, example Constant are UPPER_CASE, variables are lower camelCase, etc. It makes easier to understand what is what, from an human point of view. We know the friggen Compiler doesn't Care!! Using Event for events &&&& Function for functions makes it so much easier to understand what is happening!!!!!!!! When some who is NOT YOU is reading your script. Now Papyrus is not Case sensitive, and you can have a Constant in lower case in C# which is case sensitive, but will only confuse people reading the code, not the compiler or an interpreter, if you get my gist?????? So don't rock the boat, and stick with friggen convention, for poor poor poor person who has to read your friggen Script!!!! Edit sorry I was a little piss off when i wrote the above, I wrote some papyrus after a long break, I was using SKSE StringUtil, first I wrote JavaScript, then Python, I had to look it up in the Source Code, it was not length or lens() but GetLength(string s) Anywho, when you write think about the person who will read your code. We know the compiler is very forgiving is certain cases. Use events for EVENTS, functions for FUNCTIONS, and UPPER_CASE for constants, and lastly lower camelCase for private variables. It is what I would expect to see if I was reading your code. I am sure most will agree with me(?) Even tho papyrus is not case sensitive. Link to comment Share on other sites More sharing options...
Recommended Posts