Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between creaturescripts & events #1492

Closed
ranisalt opened this issue Aug 5, 2015 · 4 comments
Closed

Difference between creaturescripts & events #1492

ranisalt opened this issue Aug 5, 2015 · 4 comments

Comments

@ranisalt
Copy link
Member

ranisalt commented Aug 5, 2015

I'm playing with some callbacks and I stumbled into a doubt: where should I put it, on creaturescripts or on events?

I don't know the true purpose of those folders, as all creature scripts, except maybe for extendedopcode, could be moved to simple events with little code changes, but the other way around is also true, events could easily be converted into creaturescripts, so what is the true difference of meaning between those 2 script types?

@Luckey1729
Copy link
Contributor

I'm sorry if it feels like I'm piggybacking off your issue, but I've been thinking about "events" versus "creaturescripts" for a while as well.

I think the general consensus here is "everything should be moved to events." I'm not sure if @marksamman has directly stated anywhere that this is the direction that he wants to go in, but I think it's been implied that a lot of new events should consider "events" over "creaturescripts."

I'm all for "the new" and getting rid of things that don't work well / could work better. But I really don't want to see creaturescripts deprecated in lieu of events. I think events address very common actions (onMove, onTurn, onLook) very well. I would be disheartened if I were told that I would have to move onLogin to events; I have a 150-line script that executes on login if a player simply has a certain storage value (think, first items.) This would end up looking very messy in an events file.

Sorry if it sounds like my exact thoughts and concerns aren't well-collected, that's probably part of the reason I haven't brought this up. I'd certainly like to hear what Mark and others think.

@ranisalt
Copy link
Member Author

ranisalt commented Aug 5, 2015

Hmmm true that, @Luckey1729, events file are a bit messy to go with large scripts. The two onDeath scripts for players account for 130 lines and the onLogin add more 45, essentially would double the player.lua events file if we merged them.

From what I see the events are only for short, simple callbacks to prevent having 20 files with 5-line functions.

@WibbenZ
Copy link
Member

WibbenZ commented Aug 5, 2015

From what I know, events was created to move things from C++ to Lua.
It might not be the best system we should move things to there own files (onGainExperience) etc to make it more readable.

And from my understanding events is only executed when it needs to, while creaturescripts either loads them all or loads them all the time (can't remember who told me this though).

@HeavenIsLost
Copy link
Contributor

And about performance? a creature event(like ondeath, onpreparedeath, etc) is only called for creatures that have been registered(with creature:addEvent). I think its better in performance than a player event because a player event will be called everytime for every single player.

@marksamman marksamman added the question Questions that needs answering but do not require code changes label Aug 9, 2015
@WibbenZ WibbenZ closed this as completed Dec 26, 2017
@WibbenZ WibbenZ removed the question Questions that needs answering but do not require code changes label Dec 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants